Skip to content

grib1-to-grib2: Add option to set type=fc,strem=oper as a control for…#257

Merged
dsarmany merged 4 commits intodevelopfrom
feature/override-control-forecast
Apr 9, 2026
Merged

grib1-to-grib2: Add option to set type=fc,strem=oper as a control for…#257
dsarmany merged 4 commits intodevelopfrom
feature/override-control-forecast

Conversation

@dsarmany
Copy link
Copy Markdown
Collaborator

@dsarmany dsarmany commented Apr 1, 2026

…ecast

Description

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

🌈🌦️📖🚧 Documentation 🚧📖🌦️🌈
https://sites.ecmwf.int/docs/dev-section/multio/pull-requests/PR-257

Copy link
Copy Markdown
Contributor

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 new CLI option to grib1-to-grib2 to mark converted forecasts as “control” by forcing number=0 and setting related ensemble metadata during re-encoding.

Changes:

  • Adds a --control boolean option to the tool CLI.
  • Plumbs the option into runtime configuration (control_) and applies control-forecast metadata edits during conversion.
  • Introduces a validation guard to restrict --control usage to specific MARS contexts.

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

Comment on lines +1058 to +1062
// TODO: Move this logic into the encoder
// TODO: numberOfForecastsInEnsemble needs a default in the encoder
if (control_) {
if (not(mars.stream.get() == "oper") and (mars.type.get() == "fc")) {
throw eckit::UserError(
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

--control currently only affects the re-encode path. If the input message is GRIB2 and copyGrib2Messages_ is true, the message is copied verbatim and the control settings are silently ignored. Consider forcing re-encoding (or emitting an explicit error/warning) when control_ is set so the option reliably takes effect.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is okay and by design. We can already force re-encoding by passing the option --all.

}
mars.number.set(0);
misc.typeOfEnsembleForecast.set(1);
misc.numberOfForecastsInEnsemble.set(51);
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

misc.numberOfForecastsInEnsemble.set(51) is a hard-coded ensemble size and will overwrite any value extracted from the input/mappings. If the input already provides numberOfForecastsInEnsemble, prefer keeping it; otherwise consider making the default configurable (or deriving it from context) to avoid emitting incorrect metadata for non-51-member ensembles.

Suggested change
misc.numberOfForecastsInEnsemble.set(51);
if (!misc.numberOfForecastsInEnsemble.isSet()) {
misc.numberOfForecastsInEnsemble.set(51);
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a special case when the option --control is passed, which is meant to be used only if we want to override the non-ensemble input message. This key will be inferred from the input message and passed correctly when this option is not used.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.28%. Comparing base (210c956) to head (08f2ff0).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
src/multio/tools/grib1-to-grib2.cc 0.00% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #257      +/-   ##
===========================================
- Coverage    56.30%   56.28%   -0.03%     
===========================================
  Files          321      321              
  Lines        21177    21188      +11     
  Branches      1684     1688       +4     
===========================================
+ Hits         11924    11925       +1     
- Misses        9253     9263      +10     

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

dsarmany and others added 4 commits April 9, 2026 07:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dsarmany dsarmany force-pushed the feature/override-control-forecast branch from aae5a8a to 08f2ff0 Compare April 9, 2026 07:52
@dsarmany dsarmany merged commit 6178fe7 into develop Apr 9, 2026
140 of 142 checks passed
@dsarmany dsarmany deleted the feature/override-control-forecast branch April 9, 2026 07:55
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.

3 participants