Skip to content

More extensive fix for MMS EIS variable name changes #1230

@jameswilburlewis

Description

@jameswilburlewis

Anansa Keaton recently contributed a PR trying to make MMS EIS spin averaging and omnidirectional spectra working, but it wasn't a complete solution, and the EIS unit tests were failing.

The issue is changes to variable names between older and newer CDFs. Sometimes they include the data level in the variable name, sometimes not, depending on which CDF versions were loaded. We need to identify the set of changed names, the code that touches them, and make sure the code looks for all alternative spellings when doing get_data, and uses consistent names for store_data calls to minimize the amount of code that needs naming flexibility.

Here's what Anansa identified so far:

mms_eis_omni.py:

    # FIXME
    # The variable names may change between older and newer CDFs. (the level may or may not appear in the name)
    # Any changes here might need to propagate to other code

    prefix = 'mms' + probe + '_epd_eis_' + data_rate + '_' + level + '_'

    if data_units == 'flux':
        units_label = '1/(cm^2-sr-s-keV)'
    elif data_units == 'cps':
        units_label = '1/s'
    elif data_units == 'counts':
        units_label = 'counts'

[...]

    # FIXME
    # The variable name may differ here between older and newer CDFs (the level may or may not be present)
    # Any changes here will probably need to propagate to several other routines.

    telescopes = tnames(pattern=prefix + species_str + '_*' + data_units + '_t?'+suffix)

mms_eis_spin_avg.py:

    # FIXME
    # The variable names may change between older and newer CDFs. (the level may or may not appear in the name)
    # Any changes here might need to propagate to other code

    prefix = 'mms' + probe + '_epd_eis_' + data_rate + '_' + level + '_'
[...]
    # FIXME
    # The variable names may change between older and newer CDFs. (the level may or may not appear in the name)
    # Any changes here might need to propagate to other code
    spin_data = get_data(prefix + datatype + '_spin' + suffix)
    if spin_data is None:
        logging.error('Error, problem finding EIS spin variable to calculate spin-averages')
        return

But we also have to watch out in other places like here, in mms_eis_pad.py, where the name changes from mms_eis_omni might need to propagate:

                omni_times, omni_data, omni_energies = get_data(prefix + datatype_id + '_' + species_id + '_' + data_units + '_omni' + suffix)
                erange = get_data(prefix + datatype_id + '_' + species_id + '_energy_range' + suffix)

We should also add unit tests for EIS with times before and after the variable names changed, to ensure it works in both cases.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions