ENH: Compatibility with MERRA-2 atmosphere reanalysis files #825#877
Merged
Gui-FernandesBR merged 10 commits intoRocketPy-Team:developfrom Nov 27, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #877 +/- ##
===========================================
+ Coverage 80.27% 80.30% +0.02%
===========================================
Files 104 106 +2
Lines 12769 12985 +216
===========================================
+ Hits 10250 10427 +177
- Misses 2519 2558 +39 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Gui-FernandesBR
requested changes
Nov 26, 2025
Member
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
I loved the PR! It is simples, straightforward and easy to read!!
Just a few details more and we will be able to merge it.
this one will def be included in the next release
Gui-FernandesBR
approved these changes
Nov 27, 2025
Member
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
LGTM to me, let's see if the pylint problem is solved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request type
Checklist
black rocketpy/ tests/) has passed locallypytest tests -m slow --runslow) have passed locallyCHANGELOG.mdhas been updated (if relevant)Current behavior
Currently, RocketPy's Environment class primarily supports ERA-5, GFS, and ECMWF reanalysis files. Users attempting to load MERRA-2 files from NASA encounter errors because:
-The variable names differ (e.g., T instead of temperature, lev instead of level).
-MERRA-2 provides Surface Geopotential (PHIS) in units of Energy (m2/s2), whereas RocketPy expects Surface Geopotential Height in Meters (m). Loading the raw value results in an elevation error by a factor of gravity (~9.81).
New behavior
This PR implements full support for MERRA-2 atmosphere reanalysis files:
New Dictionary Mapping: Added MERRA2 to WeatherModelMapping with the correct variable keys (T, U, V, H, lev).
Automatic Unit Conversion: Implemented logic in environment.py to detect the specific surface_geopotential key (mapped to PHIS). When present, the code automatically divides the value by standard gravity to convert it to geometric height (meters).
Validation: Added "MERRA2" to the list of accepted models in set_atmospheric_model.
Testing: Added a new test fixture (merra2_file_path) that generates a temporary, binary NetCDF file strictly adhering to the NASA MERRA-2 specification (Bosilovich 2016). This ensures the feature is tested against a realistic file structure without adding large binary files to the repository.
Documentation: Updated CHANGELOG.md, the reanalysis.rst user guide, and the docstrings for set_atmospheric_model.
Breaking change
Additional information
The new logic uses an elif block to handle the unit conversion, ensuring that existing models (ERA-5, GFS) continue to use the standard code path without modification.