Skip to content

Commit

Permalink
ECC-1867: GRIB: Unexpected PDT change for GRIB2 wave template for ens…
Browse files Browse the repository at this point in the history
…emble DA streams
  • Loading branch information
shahramn committed Jul 12, 2024
1 parent f0e58ef commit 6e112df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/accessor/grib_accessor_class_g2_mars_labeling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@ 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);
grib_get_long(hand, "is_chemical_distfn", &is_chemical_distfn);
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 */
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion tests/grib2_wave_spectra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 6e112df

Please sign in to comment.