X Tutup
Skip to content

ENH: Compatibility with MERRA-2 atmosphere reanalysis files #825#877

Merged
Gui-FernandesBR merged 10 commits intoRocketPy-Team:developfrom
IDL-IMTA-Students:enh/merra2-support
Nov 27, 2025
Merged

ENH: Compatibility with MERRA-2 atmosphere reanalysis files #825#877
Gui-FernandesBR merged 10 commits intoRocketPy-Team:developfrom
IDL-IMTA-Students:enh/merra2-support

Conversation

@Monta120
Copy link

@Monta120 Monta120 commented Nov 26, 2025

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)
  • ReadMe, Docs and GitHub updates

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has 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

  • No

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.

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.30%. Comparing base (9cf3dd4) to head (b2662b3).
⚠️ Report is 7 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM to me, let's see if the pylint problem is solved

@github-project-automation github-project-automation bot moved this from Backlog to Next Version in LibDev Roadmap Nov 27, 2025
@Gui-FernandesBR Gui-FernandesBR merged commit 02c1827 into RocketPy-Team:develop Nov 27, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from Next Version to Closed in LibDev Roadmap Nov 27, 2025
@Gui-FernandesBR Gui-FernandesBR linked an issue Nov 27, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Closed

Development

Successfully merging this pull request may close these issues.

ENH : Compatibility with MERRA-2 atmosphere reanalysis files

2 participants

X Tutup