Skip to content

Commit

Permalink
ECC-2010: GRIB2: activate the use of model in the mars namespace for …
Browse files Browse the repository at this point in the history
…class=AI and ML
  • Loading branch information
shahramn committed Jan 24, 2025
1 parent fceeb6b commit c409124
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
10 changes: 6 additions & 4 deletions definitions/grib2/local/ecmf/section4_extras.def
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# (C) Copyright 2005- ECMWF.

# See ECC-1846
# This is only read when centre=ecmf, so can remove if statement that was here
# This is ecmf local so we shouldn't use MasterDir. Instead we look for pseudocentre (conceptsDir2) then centre (conceptsLocalDirAll)
# This is only read when centre=ecmf, so can remove if statement that was here
# This is ecmf local so we shouldnt use MasterDir. Instead we look for pseudocentre (conceptsDir2) then centre (conceptsLocalDirAll)

concept modelName(unknown, "modelNameConcept.def", conceptsDir2, conceptsLocalDirAll): no_copy, dump, read_only;

if (modelName isnot "unknown") {
concept modelVersion(unknown, "modelVersionConcept.[modelName].def", conceptsDir2, conceptsLocalDirAll): no_copy, dump, read_only;
# alias ls.model = modelName;
# alias mars.model = modelName;
if ( defined(marsClass) && (marsClass is "ai" || marsClass is "ml") ) {
alias ls.model = modelName;
alias mars.model = modelName;
}
}
8 changes: 7 additions & 1 deletion definitions/grib2/localConcepts/ecmf/modelNameConcept.def
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'IFS' = {
backgroundProcess = 255;
}
'AIFS' = {
'aifs-single-mse' = {
backgroundProcess = 1;
}
'aifs-ens-crps' = {
backgroundProcess = 2;
}
'aifs-ens-diff' = {
backgroundProcess = 3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'v1' = { generatingProcessIdentifier = 1; }
'v2' = { generatingProcessIdentifier = 2; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'v1' = { generatingProcessIdentifier = 1; }
'v2' = { generatingProcessIdentifier = 2; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'v1' = { generatingProcessIdentifier = 1; }
'v2' = { generatingProcessIdentifier = 2; }
20 changes: 16 additions & 4 deletions tests/grib_modelName.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ tempRef=temp.$label.ref
sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl

${tools_dir}/grib_set -s generatingProcessIdentifier=1,backgroundProcess=1 $sample $tempGrib
grib_check_key_equals $tempGrib modelName,modelVersion "AIFS v1"
grib_check_key_equals $tempGrib modelName,modelVersion "aifs-single-mse v1"

${tools_dir}/grib_set -s generatingProcessIdentifier=154 $sample $tempGrib
grib_check_key_equals $tempGrib modelName,modelVersion "IFS cy48r1"

${tools_dir}/grib_set -s generatingProcessIdentifier=100 $sample $tempGrib
grib_check_key_equals $tempGrib modelName,modelVersion "IFS unknown"

# Check that this only works for centre ecmf
# Check that this only works for centre ecmf
${tools_dir}/grib_set -s generatingProcessIdentifier=1,backgroundProcess=1,centre=84 $sample $tempGrib
[ $( ${tools_dir}/grib_get -f -p modelName $tempGrib ) = "not_found" ]
[ $( ${tools_dir}/grib_get -f -p modelVersion $tempGrib ) = "not_found" ]
Expand All @@ -40,8 +40,19 @@ ${tools_dir}/grib_set -s generatingProcessIdentifier=1,backgroundProcess=1,centr
${tools_dir}/grib_set -s generatingProcessIdentifier=1,backgroundProcess=3,productionStatusOfProcessedData=13 $sample $tempGrib
grib_check_key_equals $tempGrib modelName,modelVersion "ALARO cy46h1"
${tools_dir}/grib_set -s productionStatusOfProcessedData=0 $tempGrib $temp2Grib
[ $( ${tools_dir}/grib_get -f -p modelName $temp2Grib ) = "unknown" ]
[ $( ${tools_dir}/grib_get -f -p modelVersion $temp2Grib ) = "not_found" ]
[ $( ${tools_dir}/grib_get -f -p modelName $temp2Grib ) = "aifs-ens-diff" ]
[ $( ${tools_dir}/grib_get -f -p modelVersion $temp2Grib ) = "v1" ]


# ECC-2010
${tools_dir}/grib_set -s marsClass=ai,typeOfProcessedData=missing,backgroundProcess=1,generatingProcessIdentifier=1 \
$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl $temp2Grib
grib_check_key_equals $temp2Grib mars.model 'aifs-single-mse'

${tools_dir}/grib_set -s marsClass=ai,typeOfProcessedData=missing,backgroundProcess=2,generatingProcessIdentifier=1 \
$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl $temp2Grib
grib_check_key_equals $temp2Grib mars.model 'aifs-ens-crps'


# Keys are read-only (may change this later)
set +e
Expand All @@ -61,3 +72,4 @@ grep -q "Value is read only" $tempLog

# Clean up
rm -f $tempGrib $tempFilt $tempLog $tempOut $tempRef
rm -f $temp2Grib

0 comments on commit c409124

Please sign in to comment.