spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
154 stars 59 forks source link

Crash plotting empty HPCA energy spectra #492

Closed ericthewizard closed 1 year ago

ericthewizard commented 1 year ago

Plotting HPCA energy spectra for a time range when there's no data leads to an error:

import pyspedas
pyspedas.mms.hpca(trange=['2016-10-16/5:00', '2016-10-16/6:00'], datatype='ion')

from pyspedas.mms.hpca.mms_hpca_calc_anodes import mms_hpca_calc_anodes
mms_hpca_calc_anodes(fov=[0, 360], probe='1')

from pyspedas.mms.hpca.mms_hpca_spin_sum import mms_hpca_spin_sum
mms_hpca_spin_sum()

from pytplot import tplot
tplot('mms1_hpca_hplus_flux_elev_0-360_spin')

Traceback (most recent call last): File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 1193, in _on_timer ret = func(*args, *kwargs) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/backends/backend_macosx.py", line 68, in callback_func callback() File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/backends/backend_macosx.py", line 88, in _draw_idle self.draw() File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/backends/backend_macosx.py", line 50, in draw super().draw() File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 405, in draw self.figure.draw(self.renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/artist.py", line 74, in draw_wrapper result = draw(artist, renderer, args, **kwargs) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/figure.py", line 3082, in draw mimage._draw_list_compositing_images( File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 3100, in draw mimage._draw_list_compositing_images( File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images a.draw(renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/collections.py", line 2148, in draw self.update_scalarmappable() File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/collections.py", line 891, in update_scalarmappable self._mapped_colors = self.to_rgba(self._A, self._alpha) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/cm.py", line 511, in to_rgba x = self.norm(x) File "/Users/eric/.pyenv/versions/3.10.4/lib/python3.10/site-packages/matplotlib/colors.py", line 1694, in call raise ValueError("Invalid vmin or vmax") ValueError: Invalid vmin or vmax

ericthewizard commented 1 year ago

This should be fixed in pytplot-mpl-temp v2.1.43