2023-09-27 09:58:47 +00:00
|
|
|
#!/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-1691: Destination Earth ClimateDT metadata support
|
|
|
|
|
|
|
|
label="grib_ecc-1691_test"
|
|
|
|
temp_grib_a=temp.$label.a.grib
|
|
|
|
temp_grib_b=temp.$label.b.grib
|
|
|
|
destine_sample=temp.$label.destine.grib
|
|
|
|
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
|
|
|
|
2023-09-27 10:41:34 +00:00
|
|
|
tablesVersionLatest=$( ${tools_dir}/grib_get -p tablesVersionLatest $sample_grib2 )
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Setup Destine pseudo-centre GRIB message
|
|
|
|
# First latest tables version and add local section with MARS labeling
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_set -s tablesVersion=$tablesVersionLatest,setLocalDefinition=1,grib2LocalSectionNumber=1 $sample_grib2 $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Then change to processed data = 12 --> DestinE
|
2023-09-29 16:10:53 +00:00
|
|
|
${tools_dir}/grib_set -s productionStatusOfProcessedData=12,class=d1 $temp_grib_a $destine_sample
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check DestinE base related keys are present and correct
|
2023-09-27 10:41:34 +00:00
|
|
|
grib_check_key_exists $destine_sample destineLocalVersion,dataset,marsClass,marsType,marsStream,experimentVersionNumber
|
|
|
|
grib_check_key_equals $destine_sample "marsClass,dataset,destineLocalVersion" "d1 0 1"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check setting dataset to climate-dt (1). Check keys are present and equal defaults
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_set -s dataset=1 $destine_sample $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
2023-09-29 16:10:53 +00:00
|
|
|
grib_check_key_exists $temp_grib_a dataset,generation,activity,experiment,model,realisation,resolution
|
|
|
|
grib_check_key_equals $temp_grib_a "dataset,generation,activity,experiment,model,realisation,resolution" "1 255 0 0 0 255 0"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check an example where a few additional things are set in climate-dt
|
2023-09-29 16:10:53 +00:00
|
|
|
${tools_dir}/grib_set -s dataset=1,generation=2,activity=1,experiment=1,model=2,realisation=1,resolution=1 $destine_sample $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
2023-09-29 16:10:53 +00:00
|
|
|
grib_check_key_equals $temp_grib_a "dataset,generation,activity,experiment,model,realisation,resolution" "1 2 1 1 2 1 1"
|
|
|
|
grib_check_key_equals $temp_grib_a "dataset:s,activity:s,experiment:s,model:s,resolution:s" "climate-dt CMIP6 hist IFS-NEMO standard"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check mars.date and mars.time are equal to validityDate and validityTime, and that mars.step has been unaliased
|
|
|
|
result1=$( ${tools_dir}/grib_get -p mars.date,mars.time $temp_grib_a )
|
|
|
|
result2=$( ${tools_dir}/grib_get -p validityDate,validityTime $temp_grib_a )
|
|
|
|
[ "$result1" = "$result2" ]
|
|
|
|
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_ls -jm $temp_grib_a
|
|
|
|
[ $( ${tools_dir}/grib_get -f -p mars.step $temp_grib_a ) = "not_found" ]
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check setting dataset to extremes-dt (2). This time we will check string also
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_set -s dataset=2 $destine_sample $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
2023-09-27 10:41:34 +00:00
|
|
|
grib_check_key_equals $temp_grib_a "dataset,dataset:s" "2 extremes-dt"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Check concepts. First check default value and then example of mapping
|
2023-09-27 10:41:34 +00:00
|
|
|
grib_check_key_exists $destine_sample destineOrigin,gridSpecification
|
|
|
|
grib_check_key_equals $destine_sample "destineOrigin,gridSpecification" "unknown unknown"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Below mapping is for MeteoFrance
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_set -s centre=98,subCentre=84 $destine_sample $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
2023-09-27 10:41:34 +00:00
|
|
|
grib_check_key_equals $temp_grib_a "destineOrigin" "MeteoFrance"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Below mapping is for H1024
|
2023-09-27 10:41:34 +00:00
|
|
|
${tools_dir}/grib_set -s numberOfDataPoints=12582912,gridDefinitionTemplateNumber=150,Nside=1024 $destine_sample $temp_grib_a
|
2023-09-27 09:58:47 +00:00
|
|
|
|
2023-09-27 10:41:34 +00:00
|
|
|
grib_check_key_equals $temp_grib_a "gridSpecification" "H1024"
|
2023-09-27 09:58:47 +00:00
|
|
|
|
|
|
|
# Clean up
|
|
|
|
rm -f $temp_grib_a $temp_grib_b $destine_sample
|