ENH: Add native Meteomatics API support to the Environment class#1079
Open
Gui-FernandesBR wants to merge 1 commit into
Open
ENH: Add native Meteomatics API support to the Environment class#1079Gui-FernandesBR wants to merge 1 commit into
Gui-FernandesBR wants to merge 1 commit into
Conversation
Adds a new "meteomatics" atmospheric model to Environment.set_atmospheric_model, porting and generalizing the implementation from the EuRoC-Dev repository. - fetchers.py: fetch_meteomatics_token + fetch_atmospheric_data_from_meteomatics authenticate with username/password (short-lived token), query temperature, pressure and wind components by height above ground level, grouping the parameters to respect the account's per-request limit. - environment.py: process_meteomatics_atmosphere converts the height-AGL data to above-sea-level profiles using the Environment elevation; set_atmospheric_model gains username/password kwargs (falling back to METEOMATICS_USERNAME / METEOMATICS_PASSWORD env vars); save/load handles the new model type. - Network requests use timeouts, do not retry deterministic 4xx failures, and surface actionable RuntimeError messages. - Tests fully mock the API (no real requests, no charges); docs and changelog updated. Closes #545 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gui-FernandesBR
force-pushed
the
enh/545-meteomatics-api
branch
from
July 21, 2026 12:00
2c5b291 to
64030a3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class Meteomatics Weather API support to RocketPy’s Environment, following the existing “fetcher + process_*_atmosphere” integration style and enabling fully mocked tests/docs for the new workflow.
Changes:
- Implement Meteomatics authentication + grouped profile fetching in
rocketpy/environment/fetchers.py. - Add
Environment.process_meteomatics_atmosphere()and wire"meteomatics"intoset_atmospheric_model()and (de)serialization metadata handling. - Add unit tests (fully mocked), user docs, and a changelog entry for the new API support.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
rocketpy/environment/fetchers.py |
Adds Meteomatics token and atmospheric-profile fetching logic with retries/timeouts and parameter grouping. |
rocketpy/environment/environment.py |
Adds Meteomatics atmospheric model processing and integrates it into the Environment model selection and restore path. |
tests/unit/environment/test_fetchers.py |
Adds mocked unit tests covering Meteomatics token retrieval, grouping/parsing, and error handling. |
tests/unit/environment/test_environment.py |
Adds unit tests validating Meteomatics integration behavior in Environment (profiles, env-var credentials, edge cases). |
docs/user/environment/3-further/other_apis.rst |
Documents Meteomatics usage and configuration options for users. |
CHANGELOG.md |
Records the feature addition in the changelog. |
Comment on lines
+721
to
+726
| if max_altitude <= min_altitude: | ||
| raise ValueError("max_altitude must be greater than min_altitude.") | ||
|
|
||
| token = fetch_meteomatics_token(username, password) | ||
|
|
||
| date_string = date.strftime("%Y-%m-%dT%H:%M:%SZ") |
| If credentials are missing, if no launch date is set, or if the API | ||
| returns no usable data. | ||
| """ | ||
| model = model if isinstance(model, str) else "mix" |
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
CHANGELOG.mdhas been updatedDescription
Closes #545.
Brings native Meteomatics weather-API support into the
Environmentclass,porting and generalizing the implementation that already lived in the
EuRoC-Devrepository. The API model mirrors the existing Windy integration(a fetcher + a
process_*_atmospheremethod).Usage:
Credentials fall back to the
METEOMATICS_USERNAME/METEOMATICS_PASSWORDenvironment variables when the kwargs are omitted.
What was added
rocketpy/environment/fetchers.pyfetch_meteomatics_token— authenticates with username/password andobtains a short-lived access token.
fetch_atmospheric_data_from_meteomatics— queries temperature, pressureand both wind components at several heights above ground level, grouping
parameters to respect the account's per-request limit.
rocketpy/environment/environment.pyprocess_meteomatics_atmosphere— converts the height-AGL data toabove-sea-level profiles using the
Environmentelevation and sets thepressure/temperature/wind functions.
set_atmospheric_modelgainsusername/passwordkwargs and a"meteomatics"case;to_dict/from_dictround-trips the new type.Notes on the two points raised in the issue
done via
type="Meteomatics".layer (the
requests.getcall in the fetcher tests, and the fetcher itselfin the Environment tests), so no real requests are made.
Robustness
RuntimeErrormessages (invalid model, out-of-range altitude, badcredentials, malformed response); transient/5xx errors are retried with
backoff.
Authentication note
Meteomatics does not use a static API token: you authenticate with a personal
username + password and a short-lived bearer token is generated automatically.
That is what the
username/passwordarguments carry.