-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cftime 1.3.0 has value error that 1.2.0 doesn not #210
Comments
This looks to be related to #202, which caused the |
You don't say what code actually triggers this error, but as @spencerkclark suggested it looks to be coming from matplotlib, or the nc-time-axis toolkit. That code appears to trying to create a calendar instance with year zero for a calendar in which there is no year zero. cftime-1.3.0 checks for this, but previous versions did not. |
Hi , Sorry I didn't provide more info. Here is a test notebook that throws the error , only for a particular time sequence (the third plot throws the error which is odd) The netcdf file can be downloaded here: #################################### cftime.version Thanks |
this confirms that the problem is related to SciTools/nc-time-axis#51. nc-time-axis needs be updated to work with cftime >= 1.3.0 |
When updating to cftime=1.3.0, xarray plot throws a value error now. (downgrading to 1.2.0 doesn not have the same problem)
datetime variable looks like
array(cftime.DatetimeNoLeap(2114, 12, 16, 0, 0, 0, 0), dtype=object)
ValueError Traceback (most recent call last)
~/anaconda3/lib/python3.8/site-packages/ipykernel/pylab/backend_inline.py in show(close, block)
41 display(
42 figure_manager.canvas.figure,
---> 43 metadata=_fetch_figure_metadata(figure_manager.canvas.figure)
44 )
45 finally:
~/anaconda3/lib/python3.8/site-packages/ipykernel/pylab/backend_inline.py in _fetch_figure_metadata(fig)
178 if _is_transparent(fig.get_facecolor()):
179 # the background is transparent
--> 180 ticksLight = _is_light([label.get_color()
181 for axes in fig.axes
182 for axis in (axes.xaxis, axes.yaxis)
~/anaconda3/lib/python3.8/site-packages/ipykernel/pylab/backend_inline.py in (.0)
181 for axes in fig.axes
182 for axis in (axes.xaxis, axes.yaxis)
--> 183 for label in axis.get_ticklabels()])
184 if ticksLight.size and (ticksLight == ticksLight[0]).all():
185 # there are one or more tick labels, all with the same lightness
~/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py in get_ticklabels(self, minor, which)
1318 if minor:
1319 return self.get_minorticklabels()
-> 1320 return self.get_majorticklabels()
1321
1322 def get_majorticklines(self):
~/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py in get_majorticklabels(self)
1274 def get_majorticklabels(self):
1275 'Return a list of Text instances for the major ticklabels.'
-> 1276 ticks = self.get_major_ticks()
1277 labels1 = [tick.label1 for tick in ticks if tick.label1.get_visible()]
1278 labels2 = [tick.label2 for tick in ticks if tick.label2.get_visible()]
~/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py in get_major_ticks(self, numticks)
1429 'Get the tick instances; grow as necessary.'
1430 if numticks is None:
-> 1431 numticks = len(self.get_majorticklocs())
1432
1433 while len(self.majorTicks) < numticks:
~/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py in get_majorticklocs(self)
1346 def get_majorticklocs(self):
1347 """Get the array of major tick locations in data coordinates."""
-> 1348 return self.major.locator()
1349
1350 def get_minorticklocs(self):
~/anaconda3/lib/python3.8/site-packages/nc_time_axis/init.py in call(self)
136 def call(self):
137 vmin, vmax = self.axis.get_view_interval()
--> 138 return self.tick_values(vmin, vmax)
139
140 def tick_values(self, vmin, vmax):
~/anaconda3/lib/python3.8/site-packages/nc_time_axis/init.py in tick_values(self, vmin, vmax)
154 # appropriate.
155 years = self._max_n_locator.tick_values(lower.year, upper.year)
--> 156 ticks = [cftime.datetime(int(year), 1, 1) for year in years]
157 elif resolution == 'MONTHLY':
158 # TODO START AT THE BEGINNING OF A DECADE/CENTURY/MILLENIUM as
~/anaconda3/lib/python3.8/site-packages/nc_time_axis/init.py in (.0)
154 # appropriate.
155 years = self._max_n_locator.tick_values(lower.year, upper.year)
--> 156 ticks = [cftime.datetime(int(year), 1, 1) for year in years]
157 elif resolution == 'MONTHLY':
158 # TODO START AT THE BEGINNING OF A DECADE/CENTURY/MILLENIUM as
cftime/_cftime.pyx in cftime._cftime.datetime.init()
cftime/_cftime.pyx in cftime._cftime.assert_valid_date()
ValueError: invalid year provided in cftime.datetime(0, 1, 1, 0, 0, 0, 0, calendar='gregorian')
The text was updated successfully, but these errors were encountered: