Skip to content

Commit ee83f90

Browse files
committed
Support sattelite fields type=em/es/ssd with local-use section template 24
1 parent c8d3a03 commit ee83f90

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

src/metkit/mars2grib/backend/concepts/satellite/satelliteEncoding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void SatelliteOp(const MarsDict_t& mars, const ParDict_t& par, const OptDict_t&
214214
if constexpr (Section == SecLocalUseSection && Stage == StagePreset) {
215215

216216
// Check/Validation
217-
validation::match_LocalDefinitionNumber_or_throw(opt, out, {14});
217+
validation::match_LocalDefinitionNumber_or_throw(opt, out, {24});
218218

219219
// Deductions
220220
long channel = deductions::resolve_Channel_or_throw(mars, par, opt);

src/metkit/mars2grib/frontend/encoderConfig.cc

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ void setLocalUseSection(const eckit::LocalConfiguration& mars, eckit::LocalConfi
124124
else { // method missing
125125
if (has(mars, "channel")) {
126126
const auto& type = get_opt<std::string>(mars, "type").value_or("None");
127-
if (type == "em" || type == "es") {
128-
setRecursive(sections, "local-use-section.template-number", 14);
127+
if (type == "em" || type == "es" || type == "ssd") {
128+
setRecursive(sections, "local-use-section.template-number", 24);
129129
}
130130
else {
131131
throw eckit::Exception("Unsupported type \"" + type + "\"!", Here());
@@ -142,6 +142,10 @@ void setLocalUseSection(const eckit::LocalConfiguration& mars, eckit::LocalConfi
142142
//=============================== Process Type ===============================//
143143

144144
void setProcessType(const eckit::LocalConfiguration& mars, eckit::LocalConfiguration& sections) {
145+
if (has(mars, "channel")) {
146+
return; // Sattelite field
147+
}
148+
145149
if (get_or_throw<std::string>(mars, "levtype") == "al") {
146150
// Large ensemble
147151
if (!has(mars, "number")) {
@@ -192,6 +196,29 @@ void setChemical(eckit::LocalConfiguration& sections) {
192196
bool setMiscHorizontal(const eckit::LocalConfiguration& mars, eckit::LocalConfiguration& sections) {
193197
const auto param = get_or_throw<long>(mars, "param");
194198

199+
if (has(mars, "channel")) {
200+
// Sattelite field
201+
if (const auto& type = get_opt<std::string>(mars, "type"); type && (*type == "em" || *type == "es")) {
202+
// Derived ensemble forecast satellite
203+
if (const auto param = get_or_throw<long>(mars, "param"); matchAny(param, 194)) {
204+
setTypeOfLevel(sections, "surface");
205+
setPointInTime(sections);
206+
return true;
207+
}
208+
}
209+
else {
210+
// Single satellite
211+
if (const auto param = get_or_throw<long>(mars, "param"); matchAny(param, range(260510, 260512))) {
212+
setPointInTime(sections);
213+
setRecursiveDefault(sections, "product-definition-section.satellite-configurator.type", "default");
214+
setPDT(sections, "productCategory", "satellite");
215+
return true;
216+
}
217+
}
218+
throw eckit::Exception{"Unhandled satellite field!", Here()};
219+
}
220+
221+
// Not a sattelite field
195222
if (get_or_throw<std::string>(mars, "levtype") == "sfc") {
196223
if (matchChemical(mars)) {
197224
if (matchAny(param, range(228080, 228082), range(233032, 233035), range(235062, 235064))) {
@@ -232,29 +259,7 @@ bool setMiscHorizontal(const eckit::LocalConfiguration& mars, eckit::LocalConfig
232259
return true;
233260
}
234261
}
235-
236-
if (!has(mars, "channel")) {
237-
return false; // Not a satellite field
238-
}
239-
240-
if (const auto& type = get_opt<std::string>(mars, "type"); type && (*type == "em" || *type == "es")) {
241-
// Derived ensemble forecast satellite
242-
if (const auto param = get_or_throw<long>(mars, "param"); matchAny(param, 194)) {
243-
setTypeOfLevel(sections, "surface");
244-
setPointInTime(sections);
245-
return true;
246-
}
247-
}
248-
else {
249-
// Single satellite
250-
if (const auto param = get_or_throw<long>(mars, "param"); matchAny(param, range(260510, 260512))) {
251-
setPointInTime(sections);
252-
setRecursiveDefault(sections, "product-definition-section.satellite-configurator.type", "default");
253-
setPDT(sections, "productCategory", "satellite");
254-
return true;
255-
}
256-
}
257-
throw eckit::Exception{"Unhandled satellite field!", Here()};
262+
return false;
258263
}
259264

260265
void setHorizontal(const eckit::LocalConfiguration& mars, eckit::LocalConfiguration& sections) {

0 commit comments

Comments
 (0)