From d7111f0185107b11f3f876745d92bd94be73dedc Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 15 Feb 2024 12:18:36 +0000 Subject: [PATCH] ECC-1767: GRIB2: Add keys to properly compute wavelengths in section 4 optical templates --- definitions/grib2/template.4.optical.def | 9 +++++++++ tests/grib2_wave_spectra.sh | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/definitions/grib2/template.4.optical.def b/definitions/grib2/template.4.optical.def index e1f9867ca..a73181f89 100644 --- a/definitions/grib2/template.4.optical.def +++ b/definitions/grib2/template.4.optical.def @@ -8,3 +8,12 @@ signed[1] scaleFactorOfFirstWavelength : dump; signed[4] scaledValueOfFirstWavelength : dump; signed[1] scaleFactorOfSecondWavelength = missing(): can_be_missing,dump; signed[4] scaledValueOfSecondWavelength = missing(): can_be_missing,dump; + +meta firstWavelength from_scale_factor_scaled_value(scaleFactorOfFirstWavelength, scaledValueOfFirstWavelength); +meta secondWavelength from_scale_factor_scaled_value(scaleFactorOfSecondWavelength, scaledValueOfSecondWavelength); +alias firstWavelengthInMetres = firstWavelength; +alias secondWavelengthInMetres = secondWavelength; + +constant oneBillionth = 1.0 / 1000000000 : hidden; +meta firstWavelengthInNanometres divdouble(firstWavelength, oneBillionth); +meta secondWavelengthInNanometres divdouble(secondWavelength, oneBillionth); diff --git a/tests/grib2_wave_spectra.sh b/tests/grib2_wave_spectra.sh index f610a08bb..44b58add8 100755 --- a/tests/grib2_wave_spectra.sh +++ b/tests/grib2_wave_spectra.sh @@ -45,6 +45,12 @@ grib_check_key_equals $temp scaleFactorOfLowerWavePeriodLimit,scaledValueOfLower ${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=104 $sample2 $temp grib_check_key_equals $temp scaleFactorOfLowerWavePeriodLimit,scaledValueOfLowerWavePeriodLimit,perturbationNumber 'MISSING MISSING 0' +${tools_dir}/grib_set -s \ + tablesVersion=$latest,productDefinitionTemplateNumber=108,scaleFactorOfFirstWavelength=9,scaledValueOfFirstWavelength=12 \ +$sample2 $temp +grib_check_key_equals $temp firstWavelengthInNanometres '12' +grib_check_key_equals $temp firstWavelengthInMetres '1.2e-08' + # Clean up rm -f $tempSample $temp