Skip to content

ENH: create custom ensembles without a file and without a date - #1231

Open
MateusStano wants to merge 2 commits into
developfrom
enh/custom-ensemble-without-file
Open

MateusStano wants to merge 2 commits into
developfrom
enh/custom-ensemble-without-file

Conversation

@MateusStano

Copy link
Copy Markdown
Member

Related to #1209 and #1141. This is the #1141 item of the v1.14.0 checklist.

Pull request type

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

Checklist

Current behavior

Environment.create_ensemble (new in this release, from #1141) works, but:

  1. The file it writes only loads for the date and hour of the Environment that created it.
  2. It raises an error if the Environment has no date, even though the profiles have none.
  3. It always writes a file (custom_ensemble.nc in the current folder), so running the same cell twice raises FileExistsError.
  4. Below the lowest point of a profile the values are held constant, and the docs do not say so.

New behavior

  1. A saved custom ensemble loads on an Environment with any launch date, or with none. Its dataset already carried source = "RocketPy Environment.create_ensemble"; the loader now reads that and skips the date check. An ensemble file from anywhere else still checks the launch date.
  2. create_ensemble no longer needs a date.
  3. No file by default. create_ensemble(profiles) builds the ensemble in a netCDF dataset that only exists in memory and loads it through the same code as a file. Pass file_name to also save it; the method returns the path, or None when nothing was saved.
  4. The docs and the docstring say to start the profiles at or below ground level. The docs example started 100 m above its launch site, so it was lowered.

Also:

  • set_date and set_location leave an ensemble made from profiles as it is. Before, they tried to load it again from its file.
  • env.info() does not print a time period for these ensembles.

Breaking change

  • No

create_ensemble was never released. Its file_name default changes from "custom_ensemble.nc" to None.

Additional information

Found while testing and not fixed here, since it also happens on develop for any ensemble: select_ensemble_member fails on an Environment that was saved and loaded again (TypeError: list indices must be integers or slices, not tuple).

🤖 Generated with Claude Code

MateusStano and others added 2 commits November 20, 2026 14:11
- `Environment.create_ensemble` keeps the ensemble in memory by default.
  A file is only written when `file_name` is given.
- An ensemble created from profiles has no date: the Environment does not
  need one, and a saved ensemble loads for any launch date. Ensemble files
  from elsewhere still check the launch date.
- `set_date` and `set_location` leave such an ensemble as it is, and the
  prints skip its time period.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MateusStano
MateusStano requested a review from a team as a code owner November 20, 2026 17:11
@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.48936% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.57%. Comparing base (9bf63a0) to head (6aef260).

Files with missing lines Patch % Lines
rocketpy/environment/environment.py 90.90% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1231      +/-   ##
===========================================
+ Coverage    86.55%   86.57%   +0.02%     
===========================================
  Files          131      131              
  Lines        18248    18271      +23     
===========================================
+ Hits         15794    15818      +24     
+ Misses        2454     2453       -1     

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

1 participant