Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
604cf9b
mars2grib: infrastructure for iteration concept
MircoValentiniECMWF Apr 13, 2026
109e143
mars2grib: infrastructure for modelError concept
MircoValentiniECMWF Apr 28, 2026
b2cbc19
mars2grib: split level concept Hybrid into ModelSingleLevel and Model…
MircoValentiniECMWF Apr 28, 2026
1978270
mars2grib: Register new section2 templates {20,25,38,39}
MircoValentiniECMWF Apr 28, 2026
4aed79f
mars2grib: add ERA6 re-encoding support (covariance params, ensemble …
MircoValentiniECMWF Apr 29, 2026
d6c1298
Run clang-format
MircoValentiniECMWF Apr 29, 2026
0b41ca9
mars2grib: add brightnessTemperature variant to satellite concept
MircoValentiniECMWF May 12, 2026
a568cec
mars2grib: improve documentation
MircoValentiniECMWF May 12, 2026
555a277
mars2grib: fix recipe for LocalSectionNumbe=37
MircoValentiniECMWF May 12, 2026
5ccf2e1
mars2grib: add default for numberOfFrequencies
MircoValentiniECMWF May 14, 2026
93b9579
mars2grib: resolve typeOfGeneratingProcess=4 for ensemble statistics …
dsarmany May 13, 2026
d72e34e
mars2grib: route type=ses to PDT=2 (derived ensemble forecast)
dsarmany May 13, 2026
48bb5cc
Fix multiple bugs for encoding of BrightnessTemperature
MircoValentiniECMWF May 26, 2026
86a700e
mars2grib: bugfix, fix BrightnessTemperatureEnsembleMean
MircoValentiniECMWF May 27, 2026
abd6b8d
mars2grib: split brightness temperature into its own concept
MircoValentiniECMWF Jun 1, 2026
560817b
mars2grib: extend model-error concept handling
MircoValentiniECMWF Jun 1, 2026
a9d9d4c
mars2grib: keep samples valid during packing setup
MircoValentiniECMWF Jun 1, 2026
2be0e6d
WIP: route temporal concepts through unified ProductTime
MircoValentiniECMWF May 5, 2026
bee813c
WIP: align deductions docs with as-built ProductTime migration
MircoValentiniECMWF May 5, 2026
e4a7b99
mars2grib: Add nested error handling for all matchers
MircoValentiniECMWF May 5, 2026
32d3e92
mars2grib: Run clang format
MircoValentiniECMWF May 5, 2026
5c612c6
mars2grib: Add documentation for all matchers
MircoValentiniECMWF May 5, 2026
45d943b
Run clang-format
MircoValentiniECMWF Jun 1, 2026
bce25b6
Bugfix: fix code deleted during rebase
MircoValentiniECMWF Jun 1, 2026
f316cf5
mars2grib: documentation alignment for concepts
MircoValentiniECMWF Jun 1, 2026
1f03bf7
mars2grib: Fix documentation of deductions
MircoValentiniECMWF Jun 1, 2026
2c91280
mars2grib: improvements in time management
MircoValentiniECMWF Jun 2, 2026
c89db8d
mars2grib: revert packing modifications due to ecCodes inconsistency
MircoValentiniECMWF Jun 11, 2026
f30d021
mars2grib: fix typo in grib key name
MircoValentiniECMWF Jun 11, 2026
f25b1c9
mars2grib: Fix productTime bugs
MircoValentiniECMWF Jun 11, 2026
aed9772
mars2grib: Add check for fakeDoubleLoop
MircoValentiniECMWF Jun 11, 2026
8b23de1
mars2grib: Add error handling to all the relevant code for productTime
MircoValentiniECMWF Jun 11, 2026
70f7956
mars2grib: Update the markdown specification of productTime
MircoValentiniECMWF Jun 11, 2026
e7891df
mars2grib: fix rebase typo
MircoValentiniECMWF Jun 12, 2026
36f2f3b
mars2grib: Run clang-format
MircoValentiniECMWF Jun 12, 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
14 changes: 11 additions & 3 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,15 +97,18 @@
#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"
Expand Down Expand Up @@ -170,8 +177,9 @@ 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>;
Comment on lines 179 to +183

} // 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