From e0398e03d8ae5df3e6cdfb8c72124f8d2724af7e Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Fri, 8 Mar 2024 09:12:15 +0000 Subject: [PATCH 1/4] ECC-1766: Added class ed for testing and implemented the grib.class.def structure. --- definitions/grib2/section.4.def | 3 ++- definitions/mars/class.table | 1 + definitions/mars/grib.ed.def | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 definitions/mars/grib.ed.def diff --git a/definitions/grib2/section.4.def b/definitions/grib2/section.4.def index 512544da4..a966bbc1e 100644 --- a/definitions/grib2/section.4.def +++ b/definitions/grib2/section.4.def @@ -63,7 +63,8 @@ if (productDefinitionTemplateNumber >= 32768) { } if (defined(marsStream) && defined(marsType)) { - template_nofail marsKeywords1 "mars/grib.[marsStream:s].[marsType:s].def"; + template_nofail marsKeywordsByClass "mars/grib.[marsClass:s].def"; + template_nofail marsKeywordsByStreamAndType "mars/grib.[marsStream:s].[marsType:s].def"; } template parameters "grib2/parameters.def"; diff --git a/definitions/mars/class.table b/definitions/mars/class.table index efe2be6b1..bb740e63a 100644 --- a/definitions/mars/class.table +++ b/definitions/mars/class.table @@ -50,6 +50,7 @@ 49 gh C3S Global hydrology 50 ci CERISE project 51 ai Operational AIFS +52 ed EERIE project 99 te Test 100 at Austria 101 be Belgium diff --git a/definitions/mars/grib.ed.def b/definitions/mars/grib.ed.def new file mode 100644 index 000000000..ae4d2b3db --- /dev/null +++ b/definitions/mars/grib.ed.def @@ -0,0 +1,10 @@ +# Class ed EERIE project climate keywords + +codetable[2] activity "grib2/destine_activity.table" : dump; +alias mars.activity = activity; + +codetable[2] experiment "grib2/destine_experiment.table" : dump; +alias mars.experiment = experiment; + +unsigned[1] realization = 255 : dump; +alias mars.realization = realization; \ No newline at end of file From 5e6be438a4e1e8ba4d2537dfa885da28ddc87293 Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Mon, 11 Mar 2024 12:25:42 +0000 Subject: [PATCH 2/4] ECC-1766: Implementation will be done via new local template (43). --- definitions/mars/grib.ed.def | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 definitions/mars/grib.ed.def diff --git a/definitions/mars/grib.ed.def b/definitions/mars/grib.ed.def deleted file mode 100644 index ae4d2b3db..000000000 --- a/definitions/mars/grib.ed.def +++ /dev/null @@ -1,10 +0,0 @@ -# Class ed EERIE project climate keywords - -codetable[2] activity "grib2/destine_activity.table" : dump; -alias mars.activity = activity; - -codetable[2] experiment "grib2/destine_experiment.table" : dump; -alias mars.experiment = experiment; - -unsigned[1] realization = 255 : dump; -alias mars.realization = realization; \ No newline at end of file From 45d7f659f80f9edf4a20e3503cf7c412ff5b838e Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Mon, 11 Mar 2024 12:27:08 +0000 Subject: [PATCH 3/4] ECC-1766: Implementation will be done via new local template (43). --- definitions/grib2/local.98.43.def | 10 ++++++++++ definitions/grib2/section.4.def | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 definitions/grib2/local.98.43.def diff --git a/definitions/grib2/local.98.43.def b/definitions/grib2/local.98.43.def new file mode 100644 index 000000000..e7141c91e --- /dev/null +++ b/definitions/grib2/local.98.43.def @@ -0,0 +1,10 @@ +# Class ed EERIE project climate keywords + +codetable[2] activity "grib2/destine_activity.table" ; +alias mars.activity = activity; + +codetable[2] experiment "grib2/destine_experiment.table" ; +alias mars.experiment = experiment; + +unsigned[1] realization = 255 ; +alias mars.realization = realization; \ No newline at end of file diff --git a/definitions/grib2/section.4.def b/definitions/grib2/section.4.def index a966bbc1e..512544da4 100644 --- a/definitions/grib2/section.4.def +++ b/definitions/grib2/section.4.def @@ -63,8 +63,7 @@ if (productDefinitionTemplateNumber >= 32768) { } if (defined(marsStream) && defined(marsType)) { - template_nofail marsKeywordsByClass "mars/grib.[marsClass:s].def"; - template_nofail marsKeywordsByStreamAndType "mars/grib.[marsStream:s].[marsType:s].def"; + template_nofail marsKeywords1 "mars/grib.[marsStream:s].[marsType:s].def"; } template parameters "grib2/parameters.def"; From 8f366f2d76125f536e4072e7de1c339f7749ed2c Mon Sep 17 00:00:00 2001 From: Matthew Griffith Date: Mon, 11 Mar 2024 15:29:48 +0000 Subject: [PATCH 4/4] ECC-1766: Addition of test along with a few small tweaks. --- .../grib2/grib2LocalSectionNumber.98.table | 1 + definitions/grib2/local.98.43.def | 12 ++++- tests/CMakeLists.txt | 1 + tests/grib_ecc-1766.sh | 45 +++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 tests/grib_ecc-1766.sh diff --git a/definitions/grib2/grib2LocalSectionNumber.98.table b/definitions/grib2/grib2LocalSectionNumber.98.table index dcb8e84cd..26d0b1ec0 100644 --- a/definitions/grib2/grib2LocalSectionNumber.98.table +++ b/definitions/grib2/grib2LocalSectionNumber.98.table @@ -21,6 +21,7 @@ 39 39 4DVar model errors for long window 4Dvar system 41 41 The Flood Awareness System 42 42 Lead Centre for Wave Forecast Verification +43 43 EERIE project MARS labelling 60 60 Ocean data analysis date and analysis time 192 192 Multiple ECMWF local definitions 300 300 Multi-dimensional parameters (deprecated) diff --git a/definitions/grib2/local.98.43.def b/definitions/grib2/local.98.43.def index e7141c91e..008a528eb 100644 --- a/definitions/grib2/local.98.43.def +++ b/definitions/grib2/local.98.43.def @@ -1,10 +1,20 @@ # Class ed EERIE project climate keywords +# CMIP related activity keyword codetable[2] activity "grib2/destine_activity.table" ; alias mars.activity = activity; +# CMIP related experiment keyword codetable[2] experiment "grib2/destine_experiment.table" ; alias mars.experiment = experiment; +# Climate run realization keyword, which relates to an initial condition perturbation unsigned[1] realization = 255 ; -alias mars.realization = realization; \ No newline at end of file +alias mars.realization = realization; + +# Remove mars domain from this data +unalias mars.domain; + +# Add some padding just in case we want more keys in the future +pad padding_loc43(30); + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e282ee85a..31a644601 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -144,6 +144,7 @@ if( HAVE_BUILD_TOOLS ) grib_ecc-1671 grib_ecc-1708 grib_ecc-1691 + grib_ecc-1766 bufr_ecc-1028 bufr_ecc-1195 bufr_ecc-1259 diff --git a/tests/grib_ecc-1766.sh b/tests/grib_ecc-1766.sh new file mode 100755 index 000000000..79e273b1d --- /dev/null +++ b/tests/grib_ecc-1766.sh @@ -0,0 +1,45 @@ +#!/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 + +REDIRECT=/dev/null + +# ECC-1766: EERIE project metadata support + +label="grib_ecc-1766_test" +temp_grib=temp.$label.grib +eerie_sample=temp.$label.eerie.grib +sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl + +tablesVersionLatest=$( ${tools_dir}/grib_get -p tablesVersionLatest $sample_grib2 ) + +# Setup GRIB message with MARS keys +# Set latest tables version and add local section with MARS labeling +${tools_dir}/grib_set -s tablesVersion=$tablesVersionLatest,setLocalDefinition=1 $sample_grib2 $temp_grib + +# Then change to EERIE project GRIB message --> grib2LocalSectionNumber=43 +${tools_dir}/grib_set -s grib2LocalSectionNumber=43,class=ed $temp_grib $eerie_sample + +# Check EERIE related keys are present and correct +grib_check_key_exists $eerie_sample activity,experiment,realization +grib_check_key_equals $eerie_sample "activity,experiment,realization" "0 0 255" + +# Check domain key is unaliased +[ $( ${tools_dir}/grib_get -f -p mars.domain $eerie_sample ) = "not_found" ] + +# Check an example where a few additional things are set +${tools_dir}/grib_set -s activity=1,experiment=1,realization=1 $eerie_sample $temp_grib + +grib_check_key_equals $temp_grib "activity,experiment,realization" "1 1 1" +grib_check_key_equals $temp_grib "activity:s,experiment:s" "CMIP6 hist" + +# Clean up +rm -f $temp_grib $eerie_sample