Merge remote-tracking branch 'origin/feature/mtg2' into feature/mtg2-srcsink

This commit is contained in:
Robert Osinski 2024-06-14 13:37:21 +00:00
commit f14ee9d57e
6 changed files with 68 additions and 11 deletions

View File

@ -43,16 +43,18 @@ else {
alias cfVarName=cfVarNameFallback;
}
concept chemId (unknown,"chemId.def",conceptsDir2,conceptsDir1): no_copy,long_type,dump;
concept chemName (unknown,"chemName.def",conceptsDir2,conceptsDir1): no_copy,dump;
concept chemShortName (unknown,"chemShortName.def",conceptsDir2,conceptsDir1): no_copy,dump;
concept chemFormula (unknown,"chemFormula.def",conceptsDir2,conceptsDir1): no_copy,dump;
if (tablesVersion >= 31 ) {
concept chemId (zero,"chemId.def",conceptsDir2,conceptsDir1): no_copy,long_type,dump;
concept chemName (unknown,"chemName.def",conceptsDir2,conceptsDir1): no_copy,dump;
concept chemShortName (unknown,"chemShortName.def",conceptsDir2,conceptsDir1): no_copy,dump;
concept chemFormula (unknown,"chemFormula.def",conceptsDir2,conceptsDir1): no_copy,dump;
if ( !(chemId is "unknown") ) {
alias mars.chem = chemId;
alias parameter.chemId = chemId;
alias ls.chemShortName = chemShortName;
alias parameter.chemShortName = chemShortName;
if ( !(chemId is "unknown") ) {
alias mars.chem = chemId;
alias parameter.chemId = chemId;
alias ls.chemShortName = chemShortName;
alias parameter.chemShortName = chemShortName;
}
}
concept srcSinkId (unknown,"srcSinkId.def",conceptsDir2,conceptsDir1): no_copy,long_type,dump;

View File

@ -170,6 +170,7 @@ if( HAVE_BUILD_TOOLS )
grib_grid_polar_stereographic
grib_grid_healpix
grib_g1day_of_the_year_date
grib_paramid_chemid_split
)
# These tests require data downloads

View File

@ -58,6 +58,7 @@ cat > $tempRef <<EOF
"class": "od",
"type": "an",
"stream": "oper",
"paramtype": "base",
"levtype": "sfc",
"date": 20200804,
"time": "0000",

View File

@ -217,8 +217,10 @@ ${tools_dir}/grib_compare $temp $temp.1
${tools_dir}/grib_set -s paramId=211123,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 40
${tools_dir}/grib_set -s paramId=456000,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 76
# Automatic PDT selection is disabled for some parameters (the key is_chemical_srcsink removed from their definition)
# ${tools_dir}/grib_set -s paramId=456000,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
${tools_dir}/grib_set -s productDefinitionTemplateNumber=76,paramId=456000,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp chemShortName,chemId 'O3 236'
${tools_dir}/grib_set -s paramId=215225,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 48

View File

@ -49,6 +49,7 @@ cat > $tempRef << EOF
"class": "od",
"type": "an",
"stream": "oper",
"paramtype": "base",
"step": 0,
"levelist": 1000,
"levtype": "pl",
@ -73,6 +74,7 @@ cat > $tempRef << EOF
"class": "od",
"type": "pf",
"stream": "enfo",
"paramtype": "base",
"step": 0,
"levelist": 1000,
"levtype": "pl",

View File

@ -0,0 +1,49 @@
#!/bin/sh
# (C) Copyright 2005- ECMWF.
#
# 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.
#
. ./include.ctest.sh
label="grib_paramid_chemid_split_test"
tempGribA=temp1.$label.grib
tempGribB=temp2.$label.grib
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
# Legacy using older tablesVersion
# We expect paramId 210121
${tools_dir}/grib_set -s productDefinitionTemplateNumber=40,discipline=0,parameterCategory=20,parameterNumber=2,constituentType=5 \
$sample_grib2 $tempGribA
grib_check_key_equals $tempGribA tablesVersion 4
grib_check_key_equals $tempGribA paramId,is_chemical "210121 1"
# The new keys should not be present
result=$( ${tools_dir}/grib_get -f -p chemName,chemId $tempGribA )
[ "$result" = "not_found not_found" ]
# Switch to the newer tablesVersion so now the chemId/paramId split is activated
# Now expect paramId 402000 and chemId 17
${tools_dir}/grib_set -s tablesVersion=32 $tempGribA $tempGribB
grib_check_key_equals $tempGribB paramId,chemId "402000 17"
grib_check_key_equals $tempGribB chemName "Nitrogen dioxide"
grib_check_key_equals $tempGribB name "Mass mixing ratio"
# The is_chemical key should not be present
result=$( ${tools_dir}/grib_get -f -p is_chemical $tempGribB )
[ "$result" = "not_found" ]
# Test non-chemical e.g. temperature. Now chem keys are present but unknown
${tools_dir}/grib_set -s tablesVersion=32,discipline=0,parameterCategory=0,parameterNumber=0 $sample_grib2 $tempGribA
grib_check_key_equals $tempGribA "chemId,chemName,chemShortName" "0 unknown unknown"
# Clean up
rm -f $tempGribA $tempGribB