Skip to content
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

Crash in erg_hep_get_dist #893

Closed
jameswilburlewis opened this issue Jun 22, 2024 · 2 comments
Closed

Crash in erg_hep_get_dist #893

jameswilburlewis opened this issue Jun 22, 2024 · 2 comments
Assignees
Labels
bug Something isn't working ERG particles

Comments

@jameswilburlewis
Copy link
Contributor

When generating particle products for the HEP instrument, there is a crash in erg_hep_get_dist:


    def test_hep_theta(self):
        del_data('*')
        # Load HEP-e Lv.2 3-D flux data
        timespan('2017-04-05 21:45:00', 2.25, keyword='hours')
        pyspedas.erg.hep( trange=[ '2017-04-05 21:45:00', '2017-04-05 23:59:59'], datatype='3dflux' )
        # Calculate and plot energy spectrum
        vars = erg_hep_part_products( 'erg_hep_l2_FEDU_L', 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/hep_part_products.py", line 21, in test_hep_theta
    vars = erg_hep_part_products( 'erg_hep_l2_FEDU_L', 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_hep_part_products.py", line 123, in erg_hep_part_products
    dist_all_time_range =  erg_hep_get_dist(in_tvarname, time_indices, species=species, units=units_lc, exclude_azms= not include_allazms)
  File "/Users/jwl/PycharmProjects/pyspedas/pyspedas/erg/satellite/erg/particle/erg_hep_get_dist.py", line 348, in erg_hep_get_dist
    phi0_1_reform = np.reshape(phissi.T, [1, 1, dim_array[2], n_times])
  File "/Users/jwl/PycharmProjects/pyspedas/venv/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 285, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/Users/jwl/PycharmProjects/pyspedas/venv/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 59, in _wrapfunc
    return bound(*args, **kwds)
ValueError: cannot reshape array of size 160635 into shape (1,1,15,1013)

@jameswilburlewis jameswilburlewis added bug Something isn't working particles ERG labels Jun 22, 2024
@jameswilburlewis
Copy link
Contributor Author

It works if you don't pass a trange argument to hep_part_products(). There seems to be some confusion about whether n_times should be the number of samples of the original input variable, or the number of samples after applying the time range. In IDL, this step uses the full range of the variable, while in Python it uses the reduced sample count after applying the trange.

@jameswilburlewis jameswilburlewis self-assigned this Jul 4, 2024
@jameswilburlewis
Copy link
Contributor Author

Fixed an indexing problem with phi and elevation angle arrays (needed to be trimmed to number of samples actually being processed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ERG particles
Projects
None yet
Development

No branches or pull requests

1 participant