Skip to content

SWE L2 - use correct energy ordering for PSD #1639

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

Conversation

jtniehof
Copy link

Change Summary

Change the energy ordering in swe_l2.calculate_phase_space_density to account for the fact that swe_l1b_science.populate_full_cycle_data puts the output data in energy order, not scan order.

Since intensities are made from PSD, this fixed the intensities as well.

Overview

We noticed in making fake L2 files from ACE that the calculated PSDs were pretty nonphysical. calculate_phase_space_density uses get_particle_energy to look up energies, which are returned in the "checkerboard" energy sweep order. But populate_full_cycle_data uses the actual energies to put data into an appropriate energy bin ordered by swe_constants.ESA_VOLTAGE_ROW_INDEX_DICT

This may conflict with #1620. Dupe of #1638 because apparently PR's aren't syncing with force pushes anymore....

Updated Files

  • swe/l2/swe_l2.py
    • Sort the energies by energy, so that they're in the correct order. This doesn't exactly match what's being done in populate_full_cycle_data...to exactly match that, it should probably use values from swe_constants.ESA_VOLTAGE_ROW_INDEX_DICT, but that seems pretty fragile to LUT changes. Alternatively, this probably should sort by the known energy sweep pattern and catch any problems after the fact, but we don't have that explicitly stored anywhere.
    • There's a commented-out assertion that all energies for a given sector are the same. It's really just for illustration and I'm guessing it'll be pulled out before merging, but may help the reviewer.
  • tests/swe/test_swe_l2.py
    • Add a check to test_swe_l2 (the functional) that the ratio of PSD to count rate is the same where the energy is the same. This is done for one particular time step and CEM where I've verified there are counts in all the angle and energy bins. This test fails with the code on dev and passes with the change.

Testing

See updates to test_swe_l2.py above

@jtniehof
Copy link
Author

#1620 makes this unnecessary and incorporates the test, so closing. Thanks!

@jtniehof jtniehof closed this May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant