deeplycloudy / lmatools

Python code for working with VHF Lightning Mapping Array data
BSD 2-Clause "Simplified" License
22 stars 23 forks source link

matplotlib v3.4.2 and onwards do not have a dates.mx2num function #35

Closed gewitterblitz closed 1 year ago

gewitterblitz commented 2 years ago

lmatools/lmatools/vis/multiples_nc.py imports the mx2num function from matplotlib.dates

from matplotlib.dates import mx2num, date2num, DateFormatter

This function was deprecated for some time and has been removed since matplotlib release v3.4.2

Should we make the required changes in multiples_nc.py script?

gewitterblitz commented 2 years ago

This change in matplotlib api creates backward incompatibility in lmatools. For example, here is the error message I get:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_24811/1303470875.py in <module>
      6 import matplotlib.pyplot as plt
      7 
----> 8 from lmatools.grid.grid_collection import LMAgridFileCollection
      9 from lmatools.flash_stats import plot_energy_from_area_histogram, get_energy_spectrum_bins,  bin_center, plot_energies
     10 

~/lmatools/lmatools/grid/grid_collection.py in <module>
     12     from scipy.io.netcdf import NetCDFFile
     13 
---> 14 from lmatools.vis.multiples_nc import centers_to_edges
     15 
     16 class LMAgridFileCollection(object):

~/lmatools/lmatools/vis/multiples_nc.py in <module>
     20 from matplotlib.cm import get_cmap
     21 from matplotlib.ticker import FuncFormatter
---> 22 from matplotlib.dates import mx2num, date2num, DateFormatter #mx2num, date2num, DateFormatter
     23 from matplotlib.backends.backend_agg import FigureCanvasAgg
     24 

ImportError: cannot import name 'mx2num' from 'matplotlib.dates' (/home/sharm261/.conda/envs/cent7/2020.02-py37/vortexse_analysis/lib/python3.8/site-packages/matplotlib/dates.py)
wx4stg commented 1 year ago

this is fixed in #37

deeplycloudy commented 1 year ago

Thanks @wx4stg , and sorry for my slow reply @gewitterblitz. Yes, we should update it; in fact, it seems that mx2num isn't even used by the script, so it's an easy fix. Once #37 goes through we can close this.

deeplycloudy commented 1 year ago

Closing now that #37 is merged.