From 1f3aac3b539c4e3259d1d3309c4666a2437934e9 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 12 Jul 2024 14:37:29 +0100 Subject: [PATCH] ECC-1867: GRIB: Unexpected PDT change for GRIB2 wave template for ensemble DA streams --- .../grib_accessor_class_g2_mars_labeling.cc | 9 +++++++++ tests/grib2_wave_spectra.sh | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/accessor/grib_accessor_class_g2_mars_labeling.cc b/src/accessor/grib_accessor_class_g2_mars_labeling.cc index b9059220f..0603763f2 100644 --- a/src/accessor/grib_accessor_class_g2_mars_labeling.cc +++ b/src/accessor/grib_accessor_class_g2_mars_labeling.cc @@ -101,6 +101,7 @@ static int extra_set(grib_accessor* a, long val) long is_chemical_srcsink = 0; long is_aerosol = 0; long is_aerosol_optical = 0; + long is_wave = 0, is_wave_prange = 0; grib_get_long(hand, "is_chemical", &is_chemical); grib_get_long(hand, "is_chemical_srcsink", &is_chemical_srcsink); @@ -108,6 +109,9 @@ static int extra_set(grib_accessor* a, long val) grib_get_long(hand, "is_aerosol", &is_aerosol); grib_get_long(hand, "is_aerosol_optical", &is_aerosol_optical); + is_wave = grib_is_defined(hand, "waveDirectionNumber"); + is_wave_prange = grib_is_defined(hand, "typeOfWavePeriodInterval"); + switch (self->index) { case 0: /* class */ @@ -287,6 +291,11 @@ static int extra_set(grib_accessor* a, long val) return GRIB_INTERNAL_ERROR; } + if (is_wave || is_wave_prange) { + // ECC-1867 + productDefinitionTemplateNumberNew = -1; // disable PDT selection + } + if (productDefinitionTemplateNumberNew >= 0) { grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber); if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) diff --git a/tests/grib2_wave_spectra.sh b/tests/grib2_wave_spectra.sh index 44b58add8..ea465b04b 100755 --- a/tests/grib2_wave_spectra.sh +++ b/tests/grib2_wave_spectra.sh @@ -12,6 +12,8 @@ label="grib2_wave_spectra_test" temp=temp.$label +tempGribA=temp.$label.A.grib +tempGribB=temp.$label.B.grib tempSample=temp.$label.tmpl sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl @@ -52,5 +54,18 @@ grib_check_key_equals $temp firstWavelengthInNanometres '12' grib_check_key_equals $temp firstWavelengthInMetres '1.2e-08' +# ECC-1867: Unexpected PDT change for wave template for ensemble DA streams +sample_ld=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl # Sample with a mars local def +${tools_dir}/grib_set -s tablesVersion=32,productDefinitionTemplateNumber=99,waveFrequencyNumber=14 $sample_ld $tempGribA +${tools_dir}/grib_set -s stream=ewla $tempGribA $tempGribB +grib_check_key_equals $tempGribB productDefinitionTemplateNumber,waveFrequencyNumber '99 14' +${tools_dir}/grib_compare -b marsStream $tempGribA $tempGribB + +${tools_dir}/grib_set -s type=em $tempGribA $tempGribB +${tools_dir}/grib_compare -b marsType,typeOfProcessedData,typeOfGeneratingProcess $tempGribA $tempGribB +${tools_dir}/grib_set -s type=es $tempGribA $tempGribB +${tools_dir}/grib_compare -b marsType,typeOfProcessedData,typeOfGeneratingProcess $tempGribA $tempGribB + + # Clean up -rm -f $tempSample $temp +rm -f $tempSample $temp $tempGribA $tempGribB