cedadev / cis

Home of the Community Intercomparison Suite.
www.cistools.net
GNU Lesser General Public License v3.0
46 stars 18 forks source link

Error plotting empty timeseries #27

Open duncanwp opened 4 years ago

duncanwp commented 4 years ago

When plotting a time-series with all the data-points masked matplotlib throws an error about the date conversion:

...
  File "/Users/watson-parris/miniconda3/envs/cis_env3/lib/python3.7/site-packages/cis/plotting/plot.py", line 126, in format_datetime
    date_time = num2date(x)
  File "/Users/watson-parris/miniconda3/envs/cis_env3/lib/python3.7/site-packages/matplotlib/dates.py", line 522, in num2date
    return _from_ordinalf(x, tz)
  File "/Users/watson-parris/miniconda3/envs/cis_env3/lib/python3.7/site-packages/matplotlib/dates.py", line 321, in _from_ordinalf
    'expects datetime objects.'.format(ix))
ValueError: Cannot convert -1 to a date.  This often happens if non-datetime values are passed to an axis that expects datetime objects.

CIS should catch this and produce an informative error when trying to plot empty datasets.