spedas / pyspedas

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

Possible unintended code in erg_hep_part_products #919

Closed jameswilburlewis closed 2 weeks ago

jameswilburlewis commented 2 weeks ago

In erg_hep_part_products there's a large chunk of code for sorting energy or fac_energy spectra outputs by energy values:


    #  ;;Sort a data array by energy for (fac-)energy spectra
    if ('erg_lepe_' in in_tvarname)  and (made_et_spec):
        if 'energy' in outputs_lc:
            t_plot_name = in_tvarname+'_energy' + suffix
            get_data_energy = get_data(t_plot_name)
            energy_meta_data = get_data(t_plot_name, metadata=True)
        elif 'fac_energy' in outputs_lc:
            t_plot_name = in_tvarname+'_energy_mag' + suffix
            get_data_energy = get_data(t_plot_name)
            energy_meta_data = get_data(t_plot_name, metadata=True)

        if get_data_energy is not None:

            arange_time_indices = np.arange(get_data_energy[0].size)
            time_indices_repeat = np.repeat(np.array([arange_time_indices]).T, get_data_energy[1].shape[1], axis=1)

        [.et cetera]

Note the prefix 'erg_lepe' being tested for, even though this is for the hep instrument! I think this code was inadvertently copied from lep_part_products. The IDL SPEDAS routine doesn't do any energy level sorting on hep data, but has a similar construct in its version of lep_part_products. I think this chunk of code can be removed....it's certainly not doing anything since the variable name test will never succeed....