spedas / pyspedas

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

Crash in erg_lepe_get_dist #892

Closed jameswilburlewis closed 15 hours ago

jameswilburlewis commented 1 week ago

When generating products from LEP-e 3dflux data, there is a crash in erg_lepe_get_dist:

    def test_lepe_theta(self):
        del_data('*')
        # Load LEP-e Lv.2 3-D flux data
        timespan('2017-04-05 21:45:00', 2.25, keyword='hours')
        pyspedas.erg.lepe( trange=[ '2017-04-05 21:45:00', '2017-04-05 23:59:59'], datatype='3dflux' )
        # Calculate and plot energy spectrum
        vars = erg_lep_part_products( 'erg_lepe_l2_3dflux_FEDU', outputs='theta', trange=[ '2017-04-05 21:45:00', '2017-04-05 23:59:59'] )
Traceback (most recent call last):
  File "/Users/jwl/PycharmProjects/pyspedas/pyspedas/erg/tests/lepe_part_products.py", line 20, in test_lepe_theta
    vars = erg_lep_part_products( 'erg_lepe_l2_3dflux_FEDU', outputs='theta', trange=[ '2017-04-05 21:45:00', '2017-04-05 23:59:59'] )
  File "/Users/jwl/PycharmProjects/pyspedas/pyspedas/erg/satellite/erg/particle/erg_lep_part_products.py", line 135, in erg_lep_part_products
    dist_all_time_range =  erg_lepe_get_dist(in_tvarname, time_indices, species=species, units=units_lc)
  File "/Users/jwl/PycharmProjects/pyspedas/pyspedas/erg/satellite/erg/particle/erg_lepe_get_dist.py", line 180, in erg_lepe_get_dist
    _, id_array = tree.query(enec0_array_temp_repeat)
  File "/Users/jwl/PycharmProjects/pyspedas/venv/lib/python3.9/site-packages/scipy/spatial/_kdtree.py", line 475, in query
    d, i = super().query(x, k, eps, p, distance_upper_bound, workers)
  File "_ckdtree.pyx", line 788, in scipy.spatial._ckdtree.cKDTree.query
  File "_ckdtree.pyx", line 1620, in scipy.spatial._ckdtree.num_points
ValueError: x must consist of vectors of length 2 but has shape (1, 64, 1)

There's something different about the lepe CDFs -- the load routine calls cdf_to_tplot with notplot=True, because of some issue making tplot variables from the CDF variables. It's possible that something is still going wrong when the lepe load routine does its own conversion to tplot variables.

jameswilburlewis commented 15 hours ago

Just a couple of indexing bugs, should be fixed now!