Skip to content

Commit

Permalink
Merge pull request #201 from ecmwf/feature/ECC-1766-EERIE
Browse files Browse the repository at this point in the history
ECC-1766: EERIE project metadata support
  • Loading branch information
shahramn authored Mar 12, 2024
2 parents 6dfd9be + e5cff6a commit af910d5
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions definitions/grib2/grib2LocalSectionNumber.98.table
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions definitions/grib2/local.98.43.def
Original file line number Diff line number Diff line change
@@ -0,0 +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;

# 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);

1 change: 1 addition & 0 deletions definitions/mars/class.table
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions tests/grib_ecc-1766.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit af910d5

Please sign in to comment.