Skip to content

ENH: Create ensembles from user-defined profiles - #1141

Open
ting-hong-shieh wants to merge 3 commits into
RocketPy-Team:developfrom
ting-hong-shieh:codex/enh-environment-create-ensemble-604
Open

ENH: Create ensembles from user-defined profiles#1141
ting-hong-shieh wants to merge 3 commits into
RocketPy-Team:developfrom
ting-hong-shieh:codex/enh-environment-create-ensemble-604

Conversation

@ting-hong-shieh

Copy link
Copy Markdown

Closes #604.

Pull request type

  • Code changes (bugfix, features)
  • ReadMe, Docs and GitHub updates

Checklist

  • Tests for the changes have been added
  • Docs have been reviewed and updated
  • Ruff and Pylint pass locally
  • CHANGELOG.md — no action needed; an LLM workflow auto-updates it after merge

Current behavior

Environment can load ensemble weather files, but users cannot combine their own atmospheric profiles into the NetCDF layout expected by the ensemble loader.

New behavior

Environment.create_ensemble accepts two or more user-defined pressure, temperature, eastward-wind and northward-wind profiles for one location. It:

  • validates each member and determines a common pressure grid;
  • interpolates temperature and wind onto that grid;
  • writes a CF-annotated, GEFS-compatible NetCDF file;
  • loads the file and activates member 0; and
  • preserves the file for later use with type="Ensemble" and dictionary="GEFS".

The loader now also reports a zero-hour interval for static datasets that contain one valid time.

Breaking change

  • No

Verification

  • pytest tests/unit/environment -q — 163 passed, 6 skipped
  • ruff check rocketpy/environment/environment.py rocketpy/environment/tools.py tests/unit/environment/test_environment.py
  • pylint rocketpy/environment/environment.py rocketpy/environment/tools.py tests/unit/environment/test_environment.py — 10.00/10
  • Sphinx warnings-as-errors build for the ensemble documentation page

@ting-hong-shieh
ting-hong-shieh marked this pull request as ready for review August 13, 2026 04:24
@ting-hong-shieh
ting-hong-shieh requested a review from a team as a code owner August 13, 2026 04:24
@Gui-FernandesBR Gui-FernandesBR linked an issue Aug 13, 2026 that may be closed by this pull request
Comment thread rocketpy/environment/environment.py Outdated
raise ValueError(f"Member {member} '{variable}' heights must be unique.")
return profile

def create_ensemble( # pylint: disable=too-many-branches,too-many-locals,too-many-statements

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could you please not disable the pylint rules? Instead, try to split the method into smaller ones

Suggested change
def create_ensemble( # pylint: disable=too-many-branches,too-many-locals,too-many-statements
def create_ensemble(

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.80%. Comparing base (e0ff281) to head (41d5d53).
⚠️ Report is 50 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1141      +/-   ##
===========================================
+ Coverage    82.18%   83.80%   +1.62%     
===========================================
  Files          122      129       +7     
  Lines        16355    17085     +730     
===========================================
+ Hits         13441    14318     +877     
+ Misses        2914     2767     -147     

☔ View full report in Codecov by Harness.
📢 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

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Environment.create_ensemble method

2 participants