Skip to content

Rbsp magephem update #1153

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Rbsp magephem update #1153

wants to merge 8 commits into from

Conversation

xnchu
Copy link
Contributor

@xnchu xnchu commented Apr 10, 2025

Refactor magephem_read Module for Clarity and Consistency
• Standardized variable naming conventions for improved readability and maintainability.
• Renamed data columns to use camel case with underscores (e.g., Julian Date → JulianDate).
• Enhanced error handling for more robust data reading.
• Adjusted return values to provide lists instead of keys for easier downstream use.

Enhance RBSP Module with New magephem_ect Functionality
• Added magephem_ect function to support loading ECT magnetic field line mapping ephemeris data from HDF5 and text files.
• Integrated new magephem_read module for handling both file formats.
• Updated RBSP config to include remote ECT data directory.
• Refactored existing magephem function for improved clarity and consistency.
• Added unit tests covering magephem_ect data loading to ensure reliability across formats.

xnchu added 2 commits April 9, 2025 21:22
…larity

- Updated variable names in the magephem_read.py file to follow a consistent naming convention, improving readability and maintainability.
- Renamed columns to use camel case and underscores for better clarity (e.g., "Julian Date" to "JulianDate").
- Enhanced error handling in the data reading functions to ensure robustness against missing variables.
- Adjusted return statements to provide lists instead of keys for better usability in downstream processing.
- Refactored the magephem_ect function to include additional parameters (notplot, prefix, suffix) in the magephem_read_h5 and magephem_read_txt calls, improving flexibility in data handling.
- Cleaned up import statements for better organization and readability.
- Ensured that the function remains robust for various data formats while maintaining compatibility with existing workflows.
@jameswilburlewis
Copy link
Contributor

It looks like there was a test failure related to the latest changes to pyspedas/projects/rbsp/magephem_read.py : the test is looking for a variable CD_MLAT, but it looks like that column might have been renamed in the PR?

======================================================================
ERROR: test_load_magephem_ect_txt_data (__main__.LoadTestCases.test_load_magephem_ect_txt_data)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/pyspedas/pyspedas/pyspedas/projects/rbsp/tests/tests.py", line 145, in test_load_magephem_ect_txt_data
    magephem_ect_vars = pyspedas.projects.rbsp.magephem_ect(trange=["2018-11-05", "2018-11-08"], probe="a", cadence="1min", coord="op77q", filetype="txt")
  File "/home/runner/work/pyspedas/pyspedas/pyspedas/projects/rbsp/magephem.py", line 205, in magephem_ect
    tvars_o = magephem_read_txt(sorted(files), varnames=varnames, notplot=notplot, prefix=prefix, suffix=suffix)
  File "/home/runner/work/pyspedas/pyspedas/pyspedas/projects/rbsp/magephem_read.py", line 783, in magephem_read_txt
    raise ValueError(f"The variable {name} is not in the txt file. \n {file}")
ValueError: The variable CD_MLAT is not in the txt file. 
 rbsp_data/rbspa/MagEphem/definitive/2018/rbspa_def_MagEphem_OP77Q_20181105_v3.0.0.txt

xnchu added 5 commits April 10, 2025 14:40
- Modified unit tests in LoadTestCases to replace outdated variable names (CD_MLAT, CD_MLON, CD_MLT) with the updated naming convention (CDMAG_MLAT, CDMAG_MLON, CDMAG_MLT) for consistency with recent data handling improvements.
- Ensured that the tests continue to validate the existence of necessary data after the renaming.
- Changed the default value of the last_version parameter in the download function to True, ensuring that the latest file is downloaded by default when multiple matches are found.
- Updated the function documentation to reflect this change, clarifying the behavior of the last_version parameter.
- Added logging to indicate whether local files were found, improving traceability during the download process.
- Modified the test_wildcard method to set last_version parameter to False in the download function, ensuring that all matching files are considered during the test.
- Cleaned up the code by removing unnecessary blank lines and ensuring consistent use of double quotes for strings.
- Added a newline at the end of the file for better formatting.
@jameswilburlewis
Copy link
Contributor

Please don't default last_version to True in download.py. It will adversely affect performance for many missions that don't have multiple CDF versions.

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.

2 participants