When reading NetCDF file directly in GriddedData class, attribute ts_type is not assigned. Causes error in quickplot_map:
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/helpers.py in datetime2str(time, ts_type)
224
225 def datetime2str(time, ts_type=None):
--> 226 conv = TS_TYPE_DATETIME_CONV[ts_type]
227 if is_year(time):
228 return str(time)
KeyError: 'Unknown'
Assigning ts_type via
data.suppl_info['ts_type'] = 'daily'
beforehand fixes this problem, but then, other problem occurs, that may be due to the fact that datetime conversion (pandas, datetime64?) does not work properly for my paleo time data (year 905), raising the following issue:
OutOfBoundsDatetime Traceback (most recent call last)
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/griddeddata.py in quickplot_map(self, time_idx, xlim, ylim, **kwargs)
1208 t = cftime_to_datetime64(self.time[time_idx])[0]
-> 1209 tstr = datetime2str(t, self.ts_type)
1210 except:
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/helpers.py in datetime2str(time, ts_type)
228 return str(time)
--> 229 time = to_pandas_timestamp(time).strftime(conv)
230 return time
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/helpers.py in to_pandas_timestamp(value)
196 elif isinstance(value, (str, np.datetime64, datetime, date)):
--> 197 return pd.Timestamp(value)
198 else:
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps.Timestamp.new()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.convert_to_tsobject()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.get_datetime64_nanos()
pandas/_libs/tslibs/np_datetime.pyx in pandas._libs.tslibs.np_datetime.check_dts_bounds()
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 901-01-01 12:00:00
During handling of the above exception, another exception occurred:
OutOfBoundsDatetime Traceback (most recent call last)
in
----> 1 fig = data.quickplot_map(time_idx=0)
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/griddeddata.py in quickplot_map(self, time_idx, xlim, ylim, **kwargs)
1210 except:
1211 tstr = datetime2str(self.time_stamps()[time_idx],
-> 1212 self.ts_type)
1213 fig.axes[0].set_title("{} ({}, {})".format(self.name,
1214 self.var_name, tstr))
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/helpers.py in datetime2str(time, ts_type)
227 if is_year(time):
228 return str(time)
--> 229 time = to_pandas_timestamp(time).strftime(conv)
230 return time
231
~/anaconda3/envs/negi_course/lib/python3.6/site-packages/pyaerocom/helpers.py in to_pandas_timestamp(value)
195 return value
196 elif isinstance(value, (str, np.datetime64, datetime, date)):
--> 197 return pd.Timestamp(value)
198 else:
199 try:
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps.Timestamp.new()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.convert_to_tsobject()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.get_datetime64_nanos()
pandas/_libs/tslibs/np_datetime.pyx in pandas._libs.tslibs.np_datetime.check_dts_bounds()
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 901-01-01 12:00:00