Skip to content

Conversation

@uniKorqi422
Copy link

ERA5 → RocketPy: Full Integration

After 18+ hours of debugging, we now have a complete, reusable workflow to run EnvironmentAnalysis with real ERA5 data.

What's Included

  • docs/notebooks/era5_to_rocketpy_patch.py: Full patcher
  • Dummy pressure file with 2×2 grid

Proof

(upload your plot)

Captain Amanda Wech — from garage to orbit in one night.

Closes #864

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a utility script for preprocessing ERA5 NetCDF weather data to ensure compatibility with RocketPy's EnvironmentAnalysis module. The script addresses missing variables and grid indexing issues that can occur when using ERA5 data directly.

  • Adds functions to patch ERA5 surface data files with required/optional variables
  • Creates dummy pressure level files to work around RocketPy indexing bugs
  • Implements grid snapping to find nearest lat/lon coordinates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Gui-FernandesBR Gui-FernandesBR changed the base branch from master to develop November 2, 2025 18:43
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.

This PR doesn't make a lot of sense to me... The added file seems to be misplaced, lacking a clear purpose to be included in the repo.

Is this a new feature, utility or a bugfix? I honestly do not know.

@uniKorqi422
Copy link
Author

uniKorqi422 commented Nov 4, 2025

Hi Gui, thanks for the honest feedback—it's exactly what helps turn a rough draft into something solid. You're absolutely right: the docs/notebooks/ location is for demos, not reusable tools, so this script does feel adrift there. Let me rewind and give you the full mission log.

I was running the official RocketPy simulations (keron and mandoica) to get familiar with the codebase. But when I fed them real ERA5 data, they crashed hard:

  • valid_timetime mismatch → KeyError
  • Missing v10, u100, v100IndexError
  • Grid bounds (lon_index - 1 = -1) → IndexError
  • No u, v, t, z at pressure levels → spline failure

These weren't edge cases—they were reproducible crashes on fresh ERA5 NetCDFs. I spent 18 hours debugging, building dummy pressure files, and patching the data until the rocket finally flew instead of exploding on the pad.

This PR is a utility born from those bugfixes (#864)—a script to preprocess ERA5 files for EnvironmentAnalysis compatibility without touching core code. The notebook proves it works; the script is for reuse.

You're the experts—I’m all ears on smoothing these bumps. Maybe you’ve got a cleaner way, or this is a known pain point waiting for a fix. Either way, I built this to get my rocket airborne without help.

Proposed iterate:

  • Move to utils/era5_preprocessor.py (done)
  • Add Copilot fixes (context manager, u10 check, haversine, fallback for optionals—done)

Tested: Ran keron with patched ERA5—no crashes, full flight path.

What do you think of utils/era5/ as home? Or is there a better fit?

Closes #864 — and hopefully saves the next contributor 18 hours of debugging. 😅

Thanks for iterating!

@uniKorqi422
Copy link
Author

uniKorqi422 commented Nov 4, 2025

Side note, bear with me as I am also learning the ropes of PR's that are actual PR's and not just to change my introduction or to just use GitHub for coding tutorials. I also work backwards a lot of the time, so please don't take my mis-steps as being pushy, I'm fumbling my way around. Thank you so much for your patience. My AI's are being pushy with me as well and I'm also having to pull them back a bit so that I understand Git's processes, appreciate your help. Just excited to make rockets fly, something I didn't think was open to anyone into software engineering. Thanks again.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #866   +/-   ##
========================================
  Coverage    80.27%   80.27%           
========================================
  Files          104      104           
  Lines        12769    12769           
========================================
  Hits         10250    10250           
  Misses        2519     2519           

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Documentation Issues: Atmospheric Model, Colab Links, CSV Thrust Curves, Parachute Triggers, Flight Variables, and Dependency Notes

2 participants