Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8d515eb
mars2grib: infrastructure for iteration concept
MircoValentiniECMWF Apr 13, 2026
7ba5269
mars2grib: infrastructure for modelError concept
MircoValentiniECMWF Apr 28, 2026
5513c61
mars2grib: split level concept Hybrid into ModelSingleLevel and Model…
MircoValentiniECMWF Apr 28, 2026
0dc7650
mars2grib: Register new section2 templates {20,25,38,39}
MircoValentiniECMWF Apr 28, 2026
e26d506
mars2grib: add ERA6 re-encoding support (covariance params, ensemble …
MircoValentiniECMWF Apr 29, 2026
a76081e
Run clang-format
MircoValentiniECMWF Apr 29, 2026
a97f29f
mars2grib: add brightnessTemperature variant to satellite concept
MircoValentiniECMWF May 12, 2026
a9662da
mars2grib: improve documentation
MircoValentiniECMWF May 12, 2026
d373abf
mars2grib: fix recipe for LocalSectionNumbe=37
MircoValentiniECMWF May 12, 2026
6a524a5
mars2grib: add default for numberOfFrequencies
MircoValentiniECMWF May 14, 2026
6165d43
mars2grib: resolve typeOfGeneratingProcess=4 for ensemble statistics …
dsarmany May 13, 2026
8b468de
mars2grib: route type=ses to PDT=2 (derived ensemble forecast)
dsarmany May 13, 2026
9bffc96
Fix multiple bugs for encoding of BrightnessTemperature
MircoValentiniECMWF May 26, 2026
86c19ee
mars2grib: bugfix, fix BrightnessTemperatureEnsembleMean
MircoValentiniECMWF May 27, 2026
910e227
mars2grib: split brightness temperature into its own concept
MircoValentiniECMWF Jun 1, 2026
057f2d2
mars2grib: extend model-error concept handling
MircoValentiniECMWF Jun 1, 2026
38ce55d
mars2grib: keep samples valid during packing setup
MircoValentiniECMWF Jun 1, 2026
3f05214
WIP: route temporal concepts through unified ProductTime
MircoValentiniECMWF May 5, 2026
9e35b3b
WIP: align deductions docs with as-built ProductTime migration
MircoValentiniECMWF May 5, 2026
acb30f8
mars2grib: Add nested error handling for all matchers
MircoValentiniECMWF May 5, 2026
98468c3
mars2grib: Run clang format
MircoValentiniECMWF May 5, 2026
43839cd
mars2grib: Add documentation for all matchers
MircoValentiniECMWF May 5, 2026
b9ba761
Run clang-format
MircoValentiniECMWF Jun 1, 2026
facb338
Bugfix: fix code deleted during rebase
MircoValentiniECMWF Jun 1, 2026
3f34b98
mars2grib: documentation alignment for concepts
MircoValentiniECMWF Jun 1, 2026
c861d18
mars2grib: Fix documentation of deductions
MircoValentiniECMWF Jun 1, 2026
fd1ede6
mars2grib: improvements in time management
MircoValentiniECMWF Jun 2, 2026
046ecf8
mars2grib: revert packing modifications due to ecCodes inconsistency
MircoValentiniECMWF Jun 11, 2026
6ea2054
mars2grib: fix typo in grib key name
MircoValentiniECMWF Jun 11, 2026
e1d6715
mars2grib: Fix productTime bugs
MircoValentiniECMWF Jun 11, 2026
f72bb24
mars2grib: Add check for fakeDoubleLoop
MircoValentiniECMWF Jun 11, 2026
6ac1096
mars2grib: Add error handling to all the relevant code for productTime
MircoValentiniECMWF Jun 11, 2026
d5f7c94
mars2grib: Update the markdown specification of productTime
MircoValentiniECMWF Jun 11, 2026
d3f27b0
mars2grib: fix rebase typo
MircoValentiniECMWF Jun 12, 2026
2b99900
mars2grib: Run clang-format
MircoValentiniECMWF Jun 12, 2026
39f1fad
mars2grib: fix typo in satellite encoding
MircoValentiniECMWF Jun 25, 2026
9aa3b90
mars2grib: improve error message
MircoValentiniECMWF Jun 27, 2026
15e4191
mars2grib: add strike-probability concept infrastructure
MircoValentiniECMWF Jun 27, 2026
f6c4ffb
mars2grib: cosmetic improvements
MircoValentiniECMWF Jun 27, 2026
446c3a3
mars2grib: Improve significanceOfReferenceTime mapping
MircoValentiniECMWF Jun 27, 2026
4175b17
mars2grib: infrastructure for referencePeriod concept
MircoValentiniECMWF Jun 29, 2026
2ecd431
mars2grib: first draft of referencePeriod matcher
MircoValentiniECMWF Jun 29, 2026
a01946f
mars2grib: WIP improve support for efi/efic/sot fields
MircoValentiniECMWF Jun 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions share/metkit/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3603,6 +3603,24 @@
- 228240
- 228246
- 228247
- - levtype: sfc
- - 254001
- 254002
- 254003
- 254004
- 254005
- 254006
- 254007
- 254008
- 254009
- 254010
- 254011
- 254012
- 254013
- 254014
- 254015
- 254016
- 254017
- - class: od
levtype: al
stream: elda
Expand Down
19 changes: 15 additions & 4 deletions src/metkit/mars2grib/backend/concepts/AllConcepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
/// compile-time registry engine.
///

///
/// @ingroup mars2grib_backend_concepts
///

#pragma once

// System includes
Expand All @@ -93,25 +97,30 @@
#include "metkit/mars2grib/utils/generalUtils.h"

#include "metkit/mars2grib/backend/concepts/analysis/analysisConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/brightness-temperature/brightnessTemperatureConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/composition/compositionConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/data-type/dataTypeConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/derived/derivedConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/destine/destineConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/ensemble/ensembleConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/generating-process/generatingProcessConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/iteration/iterationConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/level/levelConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/longrange/longrangeConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/mars/marsConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/model-error/modelErrorConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/nil/nilConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/origin/originConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/packing/packingConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/param/paramConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/point-in-time/pointInTimeConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/reference-period/referencePeriodConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/reference-time/referenceTimeConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/representation/representationConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/satellite/satelliteConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/shape-of-the-earth/shapeOfTheEarthConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/statistics/statisticsConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/strike-probability/strikeProbabilityConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/tables/tablesConceptDescriptor.h"
#include "metkit/mars2grib/backend/concepts/wave/waveConceptDescriptor.h"

Expand Down Expand Up @@ -170,8 +179,10 @@ using TypeList = metkit::mars2grib::backend::compile_time_registry_engine::TypeL
///
using AllConcepts =
TypeList<AnalysisConcept, CompositionConcept, DataTypeConcept, DerivedConcept, DestineConcept, EnsembleConcept,
GeneratingProcessConcept, LevelConcept, LongrangeConcept, MarsConcept, NilConcept, OriginConcept,
PackingConcept, ParamConcept, PointInTimeConcept, ReferenceTimeConcept, RepresentationConcept,
SatelliteConcept, ShapeOfTheEarthConcept, StatisticsConcept, TablesConcept, WaveConcept>;
GeneratingProcessConcept, LevelConcept, LongrangeConcept, IterationConcept, MarsConcept, NilConcept,
OriginConcept, PackingConcept, ParamConcept, PointInTimeConcept, ReferenceTimeConcept,
RepresentationConcept, SatelliteConcept, ShapeOfTheEarthConcept, StatisticsConcept, TablesConcept,
WaveConcept, ModelErrorConcept, BrightnessTemperatureConcept, StrikeProbabilityConcept,
ReferencePeriodConcept>;

} // namespace metkit::mars2grib::backend::concepts_::detail
} // namespace metkit::mars2grib::backend::concepts_::detail
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
///
/// This header is safe to include in performance-critical translation units.
///
///
/// @ingroup mars2grib_backend_concepts
///

#pragma once

// System includes
Expand Down
4 changes: 4 additions & 0 deletions src/metkit/mars2grib/backend/concepts/GeneralRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
///
/// This header must remain lightweight and safe to include transitively.
///
///
/// @ingroup mars2grib_backend_concepts
///

#pragma once

// System includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
///
/// This header is safe to include transitively in performance-critical code.
///
///
/// @ingroup mars2grib_backend_concepts
///

#pragma once

// System includes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

///
/// @file AnalysisConcept.h
/// @file analysisConceptDescriptor.h
/// @brief Compile-time registry entry for the GRIB `analysis` concept.
///
/// This header defines `AnalysisConcept`, the **compile-time descriptor**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

///
/// @file analysisOp.h
/// @file analysisEncoding.h
/// @brief Implementation of the GRIB `analysis` concept operation.
///
/// This header defines the applicability rules and execution logic for the
Expand Down Expand Up @@ -150,7 +150,7 @@ void AnalysisOp(const MarsDict_t& mars, const ParDict_t& par, const OptDict_t& o
MARS2GRIB_LOG_CONCEPT(analysis);

// Structural validation
validation::match_LocalDefinitionNumber_or_throw(opt, out, {36L});
validation::match_LocalDefinitionNumber_or_throw(opt, out, {36L, 37L, 38L, 39L});

// Deductions
long offsetToEndOf4DvarWindowVal = deductions::resolve_offsetToEndOf4DvarWindow_or_throw(mars, par, opt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/// @note
/// This header is part of the **concept definition layer**.
/// Runtime behavior is implemented separately in the corresponding
/// `analysis.h` / `analysisOp` implementation.
/// `analysisEncoding.h` implementation.
///
/// @ingroup mars2grib_backend_concepts
///
Expand Down
60 changes: 55 additions & 5 deletions src/metkit/mars2grib/backend/concepts/analysis/analysisMatcher.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,74 @@
/*
* (C) Copyright 2025- ECMWF and individual contributors.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation nor
* does it submit to any jurisdiction.
*/

///
/// @file analysisMatcher.h
/// @brief Entry-level matcher for the GRIB `analysis` concept.
///
/// This header defines the runtime matcher used by the concept registry to
/// decide whether the **analysis concept** is active for a MARS request.
///
/// The matcher follows the standard mars2grib matching contract:
/// - return a local concept variant index when the concept is active,
/// - return `compile_time_registry_engine::MISSING` when it is not active,
/// - wrap runtime failures as nested `Mars2GribMatcherException` instances.
///
/// @ingroup mars2grib_backend_concepts
///
#pragma once

// System include
#include <cstddef>
#include <exception>

// Utils
#include "metkit/mars2grib/backend/concepts/analysis/analysisEnum.h"
#include "metkit/mars2grib/utils/dictionary_traits/dictionary_access_traits.h"
#include "metkit/mars2grib/utils/generalUtils.h"
#include "metkit/mars2grib/utils/mars2gribExceptions.h"

namespace metkit::mars2grib::backend::concepts_ {

///
/// @brief Match the `analysis` concept variant.
///
/// The concept is active when the MARS request contains `anoffset`.
///
/// @tparam MarsDict_t Type of the MARS input dictionary
/// @tparam OptDict_t Type of the options dictionary
///
/// @param[in] mars MARS input dictionary
/// @param[in] opt Options dictionary
///
/// @return Local variant index for `AnalysisType::Default`, or
/// `compile_time_registry_engine::MISSING` when the concept is inactive.
///
/// @throws metkit::mars2grib::utils::exceptions::Mars2GribMatcherException
/// If matcher evaluation fails. Lower-level exceptions are preserved through
/// `std::throw_with_nested`.
///
template <class MarsDict_t, class OptDict_t>
std::size_t analysisMatcher(const MarsDict_t& mars, const OptDict_t& opt) {
using metkit::mars2grib::utils::dict_traits::has;
try {
using metkit::mars2grib::utils::dict_traits::has;

if (has(mars, "anoffset")) {
return static_cast<std::size_t>(AnalysisType::Default);
}
if (has(mars, "anoffset")) {
return static_cast<std::size_t>(AnalysisType::Default);
}

return compile_time_registry_engine::MISSING;
return compile_time_registry_engine::MISSING;
}
catch (...) {
std::throw_with_nested(
utils::exceptions::Mars2GribMatcherException("Unable to match `analysis` concept", Here()));
}
}

} // namespace metkit::mars2grib::backend::concepts_
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* (C) Copyright 2025- ECMWF and individual contributors.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/

/// @file brightnessTemperatureConceptDescriptor.h
/// @brief Compile-time registry entry for the GRIB `brightnessTemperature` concept.
///
/// This header defines `BrightnessTemperatureConcept`, the **compile-time
/// descriptor** that registers the GRIB `brightnessTemperature` concept into
/// the mars2grib compile-time registry engine.
///
/// The descriptor provides:
/// - The concept name
/// - The mapping between variants and their symbolic names
/// - The set of callbacks associated with each encoding phase
/// - The entry-level matcher used to activate the concept
///
/// This file contains **no runtime logic**. All decisions are resolved at
/// compile time through template instantiation.
///
/// @ingroup mars2grib_backend_concepts

#pragma once

// System includes
#include <string_view>

// Registry engine
#include "metkit/mars2grib/backend/compile-time-registry-engine/RegisterEntryDescriptor.h"
#include "metkit/mars2grib/backend/compile-time-registry-engine/common.h"
#include "metkit/mars2grib/utils/generalUtils.h"

// Core concept includes
#include "metkit/mars2grib/backend/concepts/brightness-temperature/brightnessTemperatureEncoding.h"
#include "metkit/mars2grib/backend/concepts/brightness-temperature/brightnessTemperatureEnum.h"
#include "metkit/mars2grib/backend/concepts/brightness-temperature/brightnessTemperatureMatcher.h"

namespace metkit::mars2grib::backend::concepts_ {

// Importing the compile-time registry engine namespace locally to avoid
// excessive verbosity in template-heavy code. This is restricted to an
// internal scope and not exposed through public headers.
using namespace metkit::mars2grib::backend::compile_time_registry_engine;

/// @brief Compile-time descriptor for the `brightnessTemperature` concept.
///
/// `BrightnessTemperatureConcept` registers the GRIB `brightnessTemperature`
/// concept into the compile-time registry engine.
///
/// The descriptor defines:
/// - The canonical concept name
/// - The mapping from variant enum values to symbolic names
/// - The callbacks associated with each encoding phase
/// - The entry-level matcher used to detect applicability
///
/// All functions in this descriptor are `constexpr` and are evaluated
/// entirely at compile time.
struct BrightnessTemperatureConcept : RegisterEntryDescriptor<BrightnessTemperatureType, BrightnessTemperatureList> {

/// @brief Return the canonical name of the concept.
///
/// This name is used for:
/// - Registry identification
/// - Diagnostics and logging
/// - Debug and introspection facilities
static constexpr std::string_view entryName() { return brightnessTemperatureName; }

/// @brief Return the symbolic name of a concept variant.
///
/// @tparam T Variant enumeration value
///
/// @return String view representing the variant name
template <BrightnessTemperatureType T>
static constexpr std::string_view variantName() {
return brightnessTemperatureTypeName<T>();
}

/// @brief Return the callback associated with a specific encoding phase.
///
/// This function is queried by the registry engine to obtain the callback
/// implementing the `brightnessTemperature` concept for a given:
///
/// - Capability
/// - Encoding stage
/// - GRIB section
/// - Concept variant
///
/// The function returns:
/// - A valid function pointer if the concept is applicable
/// - `nullptr` otherwise
///
/// @tparam Capability Encoding capability index
/// @tparam Stage Encoding stage
/// @tparam Sec GRIB section
/// @tparam Variant Concept variant
/// @tparam MarsDict_t Type of MARS dictionary
/// @tparam ParDict_t Type of parameter dictionary
/// @tparam OptDict_t Type of options dictionary
/// @tparam OutDict_t Type of output GRIB dictionary
///
/// @return Function pointer implementing the phase, or `nullptr`
template <std::size_t Capability, std::size_t Stage, std::size_t Sec, BrightnessTemperatureType Variant,
class MarsDict_t, class ParDict_t, class OptDict_t, class OutDict_t>
static constexpr Fn<MarsDict_t, ParDict_t, OptDict_t, OutDict_t> phaseCallbacks() {
if constexpr (Capability == 0) {
if constexpr (brightnessTemperatureApplicable<Stage, Sec, Variant>()) {
return &BrightnessTemperatureOp<Stage, Sec, Variant, MarsDict_t, ParDict_t, OptDict_t, OutDict_t>;
}
else {
return nullptr;
}
}
else {
return nullptr;
}

mars2gribUnreachable();
}

/// @brief Variant-specific callbacks.
///
/// The brightnessTemperature concept does not currently require
/// variant-specific runtime callbacks. All runtime behavior is handled
/// through phase callbacks.
///
/// @return Always `nullptr`
template <std::size_t Capability, BrightnessTemperatureType Variant, class MarsDict_t, class ParDict_t,
class OptDict_t, class OutDict_t>
static constexpr Fn<MarsDict_t, ParDict_t, OptDict_t, OutDict_t> variantCallbacks() {
return nullptr;
}

/// @brief Entry-level matcher callback.
///
/// This callback is used by the registry engine to decide whether the
/// brightnessTemperature concept is active for a given MARS request.
///
/// @tparam Capability Encoding capability index
/// @tparam MarsDict_t Type of MARS dictionary
/// @tparam OptDict_t Type of options dictionary
///
/// @return Function pointer to the matcher, or `nullptr`
template <std::size_t Capability, class MarsDict_t, class OptDict_t>
static constexpr Fm<MarsDict_t, OptDict_t> entryCallbacks() {
if constexpr (Capability == 0) {
return &brightnessTemperatureMatcher<MarsDict_t, OptDict_t>;
}
else {
return nullptr;
}
}
};

} // namespace metkit::mars2grib::backend::concepts_
Loading
Loading