From 4b49e73cb6f61f3d8e1a0212323a4ba5e0203473 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 15 Dec 2015 16:02:48 +0000 Subject: [PATCH 01/14] GRIB-824: grib1 short names --- .../grib1/localConcepts/ecmf/shortName.def | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index 7e24e25da..d4946f7d5 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9330,227 +9330,227 @@ indicatorOfParameter = 251 ; } #Mean surface runoff rate -'~' = { +'msrr' = { table2Version = 235 ; indicatorOfParameter = 20 ; } #Mean sub-surface runoff rate -'~' = { +'mssrr' = { table2Version = 235 ; indicatorOfParameter = 21 ; } #Mean surface photosynthetically active radiation flux, clear sky -'~' = { +'msparfcs' = { table2Version = 235 ; indicatorOfParameter = 22 ; } #Mean snow evaporation rate -'~' = { +'mser' = { table2Version = 235 ; indicatorOfParameter = 23 ; } #Mean snowmelt rate -'~' = { +'msmr' = { table2Version = 235 ; indicatorOfParameter = 24 ; } #Mean magnitude of turbulent surface stress -'~' = { +'mmtss' = { table2Version = 235 ; indicatorOfParameter = 25 ; } #Mean large-scale precipitation fraction -'~' = { +'mlspf' = { table2Version = 235 ; indicatorOfParameter = 26 ; } #Mean surface downward UV radiation flux -'~' = { +'msdwuvrf' = { table2Version = 235 ; indicatorOfParameter = 27 ; } #Mean surface photosynthetically active radiation flux -'~' = { +'msparf' = { table2Version = 235 ; indicatorOfParameter = 28 ; } #Mean large-scale precipitation rate -'~' = { +'mlspr' = { table2Version = 235 ; indicatorOfParameter = 29 ; } #Mean convective precipitation rate -'~' = { +'mcpr' = { table2Version = 235 ; indicatorOfParameter = 30 ; } #Mean snowfall rate -'~' = { +'msr' = { table2Version = 235 ; indicatorOfParameter = 31 ; } #Mean boundary layer dissipation -'~' = { +'mbld' = { table2Version = 235 ; indicatorOfParameter = 32 ; } #Mean surface sensible heat flux -'~' = { +'msshf' = { table2Version = 235 ; indicatorOfParameter = 33 ; } #Mean surface latent heat flux -'~' = { +'mslhf' = { table2Version = 235 ; indicatorOfParameter = 34 ; } #Mean surface downward short-wave radiation flux -'~' = { +'msdwswrf' = { table2Version = 235 ; indicatorOfParameter = 35 ; } #Mean surface downward long-wave radiation flux -'~' = { +'msdwlwrf' = { table2Version = 235 ; indicatorOfParameter = 36 ; } #Mean surface net short-wave radiation flux -'~' = { +'msnswrf' = { table2Version = 235 ; indicatorOfParameter = 37 ; } #Mean surface net long-wave radiation flux -'~' = { +'msnlwrf' = { table2Version = 235 ; indicatorOfParameter = 38 ; } #Mean top net short-wave radiation flux -'~' = { +'mtnswrf' = { table2Version = 235 ; indicatorOfParameter = 39 ; } #Mean top net long-wave radiation flux -'~' = { +'mtnlwrf' = { table2Version = 235 ; indicatorOfParameter = 40 ; } #Mean eastward turbulent surface stress -'~' = { +'metss' = { table2Version = 235 ; indicatorOfParameter = 41 ; } #Mean northward turbulent surface stress -'~' = { +'mntss' = { table2Version = 235 ; indicatorOfParameter = 42 ; } #Mean evaporation rate -'~' = { +'mer' = { table2Version = 235 ; indicatorOfParameter = 43 ; } #Sunshine duration fraction -'~' = { +'sdf' = { table2Version = 235 ; indicatorOfParameter = 44 ; } #Mean eastward gravity wave surface stress -'~' = { +'megwss' = { table2Version = 235 ; indicatorOfParameter = 45 ; } #Mean northward gravity wave surface stress -'~' = { +'mngwss' = { table2Version = 235 ; indicatorOfParameter = 46 ; } #Mean gravity wave dissipation -'~' = { +'mgwd' = { table2Version = 235 ; indicatorOfParameter = 47 ; } #Mean runoff rate -'~' = { +'mror' = { table2Version = 235 ; indicatorOfParameter = 48 ; } #Mean top net short-wave radiation flux, clear sky -'~' = { +'mtnswrfcs' = { table2Version = 235 ; indicatorOfParameter = 49 ; } #Mean top net long-wave radiation flux, clear sky -'~' = { +'mtnlwrfcs' = { table2Version = 235 ; indicatorOfParameter = 50 ; } #Mean surface net short-wave radiation flux, clear sky -'~' = { +'msnswrfcs' = { table2Version = 235 ; indicatorOfParameter = 51 ; } #Mean surface net long-wave radiation flux, clear sky -'~' = { +'msnlwrfcs' = { table2Version = 235 ; indicatorOfParameter = 52 ; } #Mean top downward short-wave radiation flux -'~' = { +'mtdwswrf' = { table2Version = 235 ; indicatorOfParameter = 53 ; } #Mean vertically integrated moisture divergence -'~' = { +'mvimd' = { table2Version = 235 ; indicatorOfParameter = 54 ; } #Mean total precipitation rate -'~' = { +'mtpr' = { table2Version = 235 ; indicatorOfParameter = 55 ; } #Mean convective snowfall rate -'~' = { +'mcsr' = { table2Version = 235 ; indicatorOfParameter = 56 ; } #Mean large-scale snowfall rate -'~' = { +'mlssr' = { table2Version = 235 ; indicatorOfParameter = 57 ; } #Mean surface direct short-wave radiation flux -'~' = { +'msdrswrf' = { table2Version = 235 ; indicatorOfParameter = 58 ; } #Mean surface direct short-wave radiation flux, clear sky -'~' = { +'msdrswrfcs' = { table2Version = 235 ; indicatorOfParameter = 59 ; } #Mean surface diffuse short-wave radiation flux -'~' = { +'msdfswrf' = { table2Version = 235 ; indicatorOfParameter = 60 ; } #Mean surface diffuse short-wave radiation flux, clear sky -'~' = { +'msdfswrfcs' = { table2Version = 235 ; indicatorOfParameter = 61 ; } #Mean carbon dioxide net ecosystem exchange flux -'~' = { +'mcdneef' = { table2Version = 235 ; indicatorOfParameter = 62 ; } #Mean carbon dioxide gross primary production flux -'~' = { +'mcdgppf' = { table2Version = 235 ; indicatorOfParameter = 63 ; } #Mean carbon dioxide ecosystem respiration flux -'~' = { +'mcderf' = { table2Version = 235 ; indicatorOfParameter = 64 ; } From e6b074fefaaefa1a1b61b572d85dac75fc7dc51c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 15 Dec 2015 17:32:19 +0000 Subject: [PATCH 02/14] GRIB-824: grib1 params --- .../grib1/localConcepts/ecmf/cfVarName.def | 61 ++++++++++++------- definitions/grib1/localConcepts/ecmf/name.def | 15 +++++ .../grib1/localConcepts/ecmf/paramId.def | 15 +++++ .../grib1/localConcepts/ecmf/shortName.def | 21 ++++++- .../grib1/localConcepts/ecmf/units.def | 15 +++++ 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/cfVarName.def b/definitions/grib1/localConcepts/ecmf/cfVarName.def index 6409f72d9..d55cd2102 100644 --- a/definitions/grib1/localConcepts/ecmf/cfVarName.def +++ b/definitions/grib1/localConcepts/ecmf/cfVarName.def @@ -9455,120 +9455,135 @@ indicatorOfParameter = 44 ; } #Mean eastward gravity wave surface stress -'p235045' = { +'megwss' = { table2Version = 235 ; indicatorOfParameter = 45 ; } #Mean northward gravity wave surface stress -'p235046' = { +'mngwss' = { table2Version = 235 ; indicatorOfParameter = 46 ; } #Mean gravity wave dissipation -'p235047' = { +'mgwd' = { table2Version = 235 ; indicatorOfParameter = 47 ; } #Mean runoff rate -'p235048' = { +'mror' = { table2Version = 235 ; indicatorOfParameter = 48 ; } #Mean top net short-wave radiation flux, clear sky -'p235049' = { +'mtnswrfcs' = { table2Version = 235 ; indicatorOfParameter = 49 ; } #Mean top net long-wave radiation flux, clear sky -'p235050' = { +'mtnlwrfcs' = { table2Version = 235 ; indicatorOfParameter = 50 ; } #Mean surface net short-wave radiation flux, clear sky -'p235051' = { +'msnswrfcs' = { table2Version = 235 ; indicatorOfParameter = 51 ; } #Mean surface net long-wave radiation flux, clear sky -'p235052' = { +'msnlwrfcs' = { table2Version = 235 ; indicatorOfParameter = 52 ; } #Mean top downward short-wave radiation flux -'p235053' = { +'mtdwswrf' = { table2Version = 235 ; indicatorOfParameter = 53 ; } #Mean vertically integrated moisture divergence -'p235054' = { +'mvimd' = { table2Version = 235 ; indicatorOfParameter = 54 ; } #Mean total precipitation rate -'p235055' = { +'mtpr' = { table2Version = 235 ; indicatorOfParameter = 55 ; } #Mean convective snowfall rate -'p235056' = { +'mcsr' = { table2Version = 235 ; indicatorOfParameter = 56 ; } #Mean large-scale snowfall rate -'p235057' = { +'mlssr' = { table2Version = 235 ; indicatorOfParameter = 57 ; } #Mean surface direct short-wave radiation flux -'p235058' = { +'msdrswrf' = { table2Version = 235 ; indicatorOfParameter = 58 ; } #Mean surface direct short-wave radiation flux, clear sky -'p235059' = { +'msdrswrfcs' = { table2Version = 235 ; indicatorOfParameter = 59 ; } #Mean surface diffuse short-wave radiation flux -'p235060' = { +'msdfswrf' = { table2Version = 235 ; indicatorOfParameter = 60 ; } #Mean surface diffuse short-wave radiation flux, clear sky -'p235061' = { +'msdfswrfcs' = { table2Version = 235 ; indicatorOfParameter = 61 ; } #Mean carbon dioxide net ecosystem exchange flux -'p235062' = { +'mcdneef' = { table2Version = 235 ; indicatorOfParameter = 62 ; } #Mean carbon dioxide gross primary production flux -'p235063' = { +'mcdgppf' = { table2Version = 235 ; indicatorOfParameter = 63 ; } #Mean carbon dioxide ecosystem respiration flux -'p235064' = { +'mcderf' = { table2Version = 235 ; indicatorOfParameter = 64 ; } #Mean rain rate -'p235065' = { +'mrr' = { table2Version = 235 ; indicatorOfParameter = 65 ; } #Mean convective rain rate -'p235066' = { +'mcrr' = { table2Version = 235 ; indicatorOfParameter = 66 ; } #Mean large-scale rain rate -'p235067' = { +'mlsrr' = { table2Version = 235 ; indicatorOfParameter = 67 ; } +#Mean surface downward short-wave radiation flux, clear sky +'msdwswrfcs' = { + table2Version = 235 ; + indicatorOfParameter = 68 ; + } +#Mean surface downward long-wave radiation flux, clear sky +'msdwlwrfcs' = { + table2Version = 235 ; + indicatorOfParameter = 69 ; + } +#Mean potential evaporation rate +'mper' = { + table2Version = 235 ; + indicatorOfParameter = 70 ; + } #Ceiling 'ceil' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/name.def b/definitions/grib1/localConcepts/ecmf/name.def index fa48f9858..00148cae0 100644 --- a/definitions/grib1/localConcepts/ecmf/name.def +++ b/definitions/grib1/localConcepts/ecmf/name.def @@ -9569,6 +9569,21 @@ table2Version = 235 ; indicatorOfParameter = 67 ; } +#Mean surface downward short-wave radiation flux, clear sky +'Mean surface downward short-wave radiation flux, clear sky' = { + table2Version = 235 ; + indicatorOfParameter = 68 ; + } +#Mean surface downward long-wave radiation flux, clear sky +'Mean surface downward long-wave radiation flux, clear sky' = { + table2Version = 235 ; + indicatorOfParameter = 69 ; + } +#Mean potential evaporation rate +'Mean potential evaporation rate' = { + table2Version = 235 ; + indicatorOfParameter = 70 ; + } #Ceiling 'Ceiling' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/paramId.def b/definitions/grib1/localConcepts/ecmf/paramId.def index 95c50b283..dfe06272c 100644 --- a/definitions/grib1/localConcepts/ecmf/paramId.def +++ b/definitions/grib1/localConcepts/ecmf/paramId.def @@ -9569,6 +9569,21 @@ table2Version = 235 ; indicatorOfParameter = 67 ; } +#Mean surface downward short-wave radiation flux, clear sky +'235068' = { + table2Version = 235 ; + indicatorOfParameter = 68 ; + } +#Mean surface downward long-wave radiation flux, clear sky +'235069' = { + table2Version = 235 ; + indicatorOfParameter = 69 ; + } +#Mean potential evaporation rate +'235070' = { + table2Version = 235 ; + indicatorOfParameter = 70 ; + } #Ceiling '260109' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index d4946f7d5..dbc664b2e 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9555,20 +9555,35 @@ indicatorOfParameter = 64 ; } #Mean rain rate -'~' = { +'mrr' = { table2Version = 235 ; indicatorOfParameter = 65 ; } #Mean convective rain rate -'~' = { +'mcrr' = { table2Version = 235 ; indicatorOfParameter = 66 ; } #Mean large-scale rain rate -'~' = { +'mlsrr' = { table2Version = 235 ; indicatorOfParameter = 67 ; } +#Mean surface downward short-wave radiation flux, clear sky +'msdwswrfcs' = { + table2Version = 235 ; + indicatorOfParameter = 68 ; + } +#Mean surface downward long-wave radiation flux, clear sky +'msdwlwrfcs' = { + table2Version = 235 ; + indicatorOfParameter = 69 ; + } +#Mean potential evaporation rate +'mper' = { + table2Version = 235 ; + indicatorOfParameter = 70 ; + } #Ceiling 'ceil' = { table2Version = 228 ; diff --git a/definitions/grib1/localConcepts/ecmf/units.def b/definitions/grib1/localConcepts/ecmf/units.def index 35d08c4bc..edcbdbbb9 100644 --- a/definitions/grib1/localConcepts/ecmf/units.def +++ b/definitions/grib1/localConcepts/ecmf/units.def @@ -9569,6 +9569,21 @@ table2Version = 235 ; indicatorOfParameter = 67 ; } +#Mean surface downward short-wave radiation flux, clear sky +'W m**-2' = { + table2Version = 235 ; + indicatorOfParameter = 68 ; + } +#Mean surface downward long-wave radiation flux, clear sky +'W m**-2' = { + table2Version = 235 ; + indicatorOfParameter = 69 ; + } +#Mean potential evaporation rate +'kg m**-2 s**-1' = { + table2Version = 235 ; + indicatorOfParameter = 70 ; + } #Ceiling 'm' = { table2Version = 228 ; From 8c6f1f1e4aa2e442d2f42c89e11f868530a42532 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 15 Dec 2015 17:57:18 +0000 Subject: [PATCH 03/14] Remove the comments re TIGGE --- definitions/grib2/cfVarName.def | 4 ++-- definitions/grib2/name.def | 4 ++-- definitions/grib2/paramId.def | 4 ++-- definitions/grib2/shortName.def | 4 ++-- definitions/grib2/units.def | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index 508439156..e4a226b9c 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -2621,7 +2621,7 @@ parameterCategory = 0 ; parameterNumber = 22 ; } -#Soil Moisture for TIGGE +#Soil Moisture 'sm' = { discipline = 2 ; parameterCategory = 0 ; @@ -2640,7 +2640,7 @@ parameterCategory = 0 ; parameterNumber = 2 ; } -#Soil temperature for TIGGE +#Soil Temperature 'st' = { discipline = 2 ; parameterCategory = 0 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 5c9a43478..5d13badfb 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -2621,7 +2621,7 @@ parameterCategory = 0 ; parameterNumber = 22 ; } -#Soil Moisture for TIGGE +#Soil Moisture 'Soil Moisture' = { discipline = 2 ; parameterCategory = 0 ; @@ -2640,7 +2640,7 @@ parameterCategory = 0 ; parameterNumber = 2 ; } -#Soil temperature for TIGGE +#Soil Temperature 'Soil Temperature' = { discipline = 2 ; parameterCategory = 0 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index 10dd65e9d..bcba3813f 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -2621,7 +2621,7 @@ parameterCategory = 0 ; parameterNumber = 22 ; } -#Soil Moisture for TIGGE +#Soil Moisture '228039' = { discipline = 2 ; parameterCategory = 0 ; @@ -2640,7 +2640,7 @@ parameterCategory = 0 ; parameterNumber = 2 ; } -#Soil temperature for TIGGE +#Soil Temperature '228139' = { discipline = 2 ; parameterCategory = 0 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 0b74aeaf6..122e99ecc 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -2621,7 +2621,7 @@ parameterCategory = 0 ; parameterNumber = 22 ; } -#Soil Moisture for TIGGE +#Soil Moisture 'sm' = { discipline = 2 ; parameterCategory = 0 ; @@ -2640,7 +2640,7 @@ parameterCategory = 0 ; parameterNumber = 2 ; } -#Soil temperature for TIGGE +#Soil Temperature 'st' = { discipline = 2 ; parameterCategory = 0 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 52c8ff60f..81cfb0208 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -2621,7 +2621,7 @@ parameterCategory = 0 ; parameterNumber = 22 ; } -#Soil Moisture for TIGGE +#Soil Moisture 'kg m**-3' = { discipline = 2 ; parameterCategory = 0 ; @@ -2640,7 +2640,7 @@ parameterCategory = 0 ; parameterNumber = 2 ; } -#Soil temperature for TIGGE +#Soil Temperature 'K' = { discipline = 2 ; parameterCategory = 0 ; From 124205729d5b0a3b60c80546f53bf1f691cd8b9f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 15 Dec 2015 18:00:56 +0000 Subject: [PATCH 04/14] Add examples/F90/eccodes_f_bufr_read_tropical_cyclone --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4d2754596..b797c304e 100644 --- a/.gitignore +++ b/.gitignore @@ -139,6 +139,7 @@ examples/F90/eccodes_f_bufr_subset examples/F90/eccodes_f_bufr_clone examples/F90/eccodes_f_bufr_read_header examples/F90/eccodes_f_bufr_read_scatterometer +examples/F90/eccodes_f_bufr_read_tropical_cyclone examples/F90/eccodes_f_grib_clone examples/F90/eccodes_f_copy_message examples/F90/eccodes_f_copy_namespace From 5de3530328c56d7c84d1d3f6c9ff409c3374cd9b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 16 Dec 2015 10:45:36 +0000 Subject: [PATCH 05/14] Testing: Remove temp files --- tests/bufr_filter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bufr_filter.sh b/tests/bufr_filter.sh index 6b3071023..2e395020a 100755 --- a/tests/bufr_filter.sh +++ b/tests/bufr_filter.sh @@ -801,4 +801,4 @@ EOF diff ${f}.ref ${f}.log rm -f ${f}.ref ${f}.log - +rm -f $fLog $fRules From 981845c12cbaf0209606d1befefa9baa791c42d2 Mon Sep 17 00:00:00 2001 From: Marijana Crepulja Date: Wed, 16 Dec 2015 11:03:37 +0000 Subject: [PATCH 06/14] tc in python ECC-190 --- .gitignore | 3 + examples/python/CMakeLists.txt | 1 + examples/python/bufr_read_tropical_cyclone.py | 278 ++++ examples/python/bufr_read_tropical_cyclone.sh | 39 + .../bufr_read_tropical_cyclone.py | 140 -- .../bufr_read_tropical_cyclone.sh | 1183 ----------------- 6 files changed, 321 insertions(+), 1323 deletions(-) create mode 100644 examples/python/bufr_read_tropical_cyclone.py create mode 100755 examples/python/bufr_read_tropical_cyclone.sh delete mode 100644 examples/python/experimental/bufr_read_tropical_cyclone.py delete mode 100755 examples/python/experimental/bufr_read_tropical_cyclone.sh diff --git a/.gitignore b/.gitignore index 4d2754596..4aee364a8 100644 --- a/.gitignore +++ b/.gitignore @@ -300,3 +300,6 @@ data/bufr/set_unexpandedDescriptors.filter *.sublime-workspace *.old + +examples/python/1 +examples/python/Testing/ diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt index ed00350ff..72b0c2464 100644 --- a/examples/python/CMakeLists.txt +++ b/examples/python/CMakeLists.txt @@ -49,6 +49,7 @@ list( APPEND tests bufr_keys_iterator bufr_read_header bufr_read_scatterometer + #bufr_read_tropical_cyclone bufr_read_synop bufr_read_temp bufr_set_keys diff --git a/examples/python/bufr_read_tropical_cyclone.py b/examples/python/bufr_read_tropical_cyclone.py new file mode 100644 index 000000000..8615dcb01 --- /dev/null +++ b/examples/python/bufr_read_tropical_cyclone.py @@ -0,0 +1,278 @@ +# Copyright 2005-2015 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. +# +# Python implementation: bufr_read_tropical_cyclone +# +# Description: how to read data of the ECMWF EPS tropical cyclone tracks encoded in BUFR format. +# +# Please note that scatterometer data can be encoded in various ways in BUFR. Therefore the code +# below might not work directly for other types of messages than the one used in the +# example. It is advised to use bufr_dump first to understand the structure of these messages. +# + + +import traceback +import sys +import collections +#import numpy + +from eccodes import * + +INPUT = '../../data/bufr/tropical_cyclone.bufr' +VERBOSE = 1 # verbose error reporting + + +data=collections.defaultdict(dict) +def example(): + + # open bufr file + f = open(INPUT) + + cnt = 1 + + # loop for the messages in the file + while 1: + # get handle for message + gid = codes_bufr_new_from_file(f) + if gid is None: + break + + print '**************** MESSAGE: ',cnt,' *****************' + + # we need to instruct ecCodes to expand all the descriptors + # i.e. unpack the data values + codes_set(gid, 'unpack', 1) + +# The BUFR file contains a single message with number of subsets in a compressed form. +# It means each subset has exactly the same structure. +# One subset contains values of latitude, longitude, pressure, wind at 10m +# for one particular ensemble member over forecast period from 0h to 240h by 6h step. +# To print values of latitude, longitude, pressure, wind at 10m for particular ensemble member from all the subsets +# we will simply access the key by condition (see below) +# +# The key latitude will give back the array of all the values corresponding +# to all the instances of the key in the tree. +# The key #2#latitude will return only the values of the second instance in the tree. + + + numObs=codes_get(gid,"numberOfSubsets") + year = codes_get(gid, "year") + month = codes_get(gid, "month") + day = codes_get(gid, "day") + hour = codes_get(gid, "hour") + minute= codes_get(gid, "minute") + + #print 'Date and time: %d%s %d%s %d%s %d%s %d' % (day,'.',month,'.',year,' ',hour,':',minute) + print 'Date and time: ', day,'.',month,'.',year,' ',hour,':',minute + + + stormIdentifier = codes_get(gid,"stormIdentifier") + print 'Storm identifier: ', stormIdentifier + + + #How many different timePeriod in the data structure? + rankPeriod=0 + while True: + rankPeriod=rankPeriod+1 + try: + codes_get_array(gid,"#%d#timePeriod" %rankPeriod) + #period=next(timeStep[i] for i in range (len(timeStep))if timeStep[i] != CODES_MISSING_DOUBLE ) + except CodesInternalError, err: + #print err.msg + #del(period) + break + #the numberOfPeriods includes the analysis (period=0) + + # Get ensembleMemberNumber + memberNumber = codes_get_array(gid, "ensembleMemberNumber") + memberNumberLen=len(memberNumber) + + + # Observed Storm Centre + significance = codes_get(gid,'#1#meteorologicalAttributeSignificance') + latitudeCentre = codes_get(gid,'#1#latitude') + longitudeCentre = codes_get(gid,'#1#longitude') + + if (significance!=1): + print 'ERROR: unexpected #1#meteorologicalAttributeSignificance' + return 1 + + if (latitudeCentre==CODES_MISSING_DOUBLE) and (longitudeCentre==CODES_MISSING_DOUBLE): + print 'Observed storm centre position missing' + else: + print 'Observed storm centre: latitude=',latitudeCentre,' longitude=',longitudeCentre + + # Location of storm in perturbed analysis + significance = codes_get(gid,'#2#meteorologicalAttributeSignificance') + latitudeAnalysis = codes_get_array(gid,'#2#latitude') + longitudeAnalysis = codes_get_array(gid,'#2#longitude') + pressureAnalysis = codes_get_array(gid,'#1#pressureReducedToMeanSeaLevel') + + if (significance!=4): + print 'ERROR: unexpected #2#meteorologicalAttributeSignificance' + return 1 + + latitude=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + longitude=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + pressure=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + + + if (len(latitudeAnalysis)==len(memberNumber)): + for i in range(len(memberNumber)): + latitude[i][0]=latitudeAnalysis[i] + longitude[i][0]=longitudeAnalysis[i] + pressure[i][0]=pressureAnalysis[i] + + else: + for i in range(len(memberNumber)): + latitude[i][0]=latitudeAnalysis[0] + longitude[i][0]=longitudeAnalysis[0] + pressure[i][0]=pressureAnalysis[i] + + # Location of Maximum Wind + significance=codes_get(gid,'#3#meteorologicalAttributeSignificance') + latitudeMaxWind0=codes_get_array(gid,'#3#latitude') + longitudeMaxWind0= codes_get_array(gid,'#3#longitude') + + if (significance!=3): + print 'ERROR: unexpected #3#meteorologicalAttributeSignificance=', significance + return 1 + + latitudeWind=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + longitudeWind=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + wind=[[0 for x in range(rankPeriod)] for x in range(len(memberNumber))] + + windMaxWind0= codes_get_array(gid,'#1#windSpeedAt10M') + + if (len(latitudeMaxWind0)==len(memberNumber)): + for i in range(len(memberNumber)): + latitudeWind[i][0]=latitudeMaxWind0[i] + longitudeWind[i][0]=longitudeMaxWind0[i] + wind[i][0]=windMaxWind0[i] + + else: + for i in range(len(memberNumber)): + latitudeWind[i][0]=latitudeMaxWind0[0] + longitudeWind[i][0]=longitudeMaxWind0[0] + wind[i][0]=windMaxWind0[i] + + rankSignificance=3 + rankPosition=3 + rankPressure=1 + rankWind=1 + + timePeriod=[0 for x in range(rankPeriod)] + for i in range(1,rankPeriod): + #for i in range(rankPeriod): + rank1 = i * 2 + 2 + rank3 = i * 2 + 3 + + #rank1 = (i+1) * 2 + 2 + #rank3 = (i+1)* 2 + 3 + + ivalues= codes_get_array(gid,"#%d#timePeriod" %(i)) + + if (len(ivalues)==1): + timePeriod[i]=ivalues[0] + else: + for j in range(len (ivalues)): + if (ivalues[j]!=CODES_MISSING_LONG): + timePeriod[i]=ivalues[j] + break + + values = codes_get_array(gid, "#%d#meteorologicalAttributeSignificance" % rank1) + if (len(values)==1): + significance=values[0] + else: + for j in range(len (values)): + if (values[j]!=CODES_MISSING_LONG): + significance=values[j] + break + + if(significance==1): + lat = codes_get_array(gid, "#%d#latitude" % rank1) + lon = codes_get_array(gid, "#%d#longitude" % rank1) + press = codes_get_array(gid, "#%d#pressureReducedToMeanSeaLevel" % (i + 1)) + else: + print 'ERROR: unexpected meteorologicalAttributeSignificance=',significance + + + values = codes_get_array(gid, "#%d#meteorologicalAttributeSignificance" % rank3) + if (len(values)==1): + significanceWind=values[0] + else: + for j in range(len (values)): + if (values[j]!=CODES_MISSING_LONG): + significanceWind=values[j] + break + + if(significanceWind==3): + lat3 = codes_get_array(gid, "#%d#latitude" % rank3) + lon3 = codes_get_array(gid, "#%d#longitude" % rank3) + wind3 = codes_get_array(gid, "#%d#windSpeedAt10M" % (i + 1)) + else: + print 'ERROR: unexpected meteorologicalAttributeSignificance=',significanceWind + + #for k in range(1,len(memberNumber)): + for k in range(len(memberNumber)): + data[k][i]=[lat[k],lon[k],press[k],lat3[k],lon3[k],wind3[k]] + + if(cnt==2): + print 'majaaa', i,timePeriod[s] + + # ---- Print the values -------------------------------- + + for m in sorted( data.keys()): + print "== Member %d"%(m+1) + print "step latitude longitude pressure latitude longitude wind" + #print " {:<3d}{:2.2f}{:2.2f}{}{} {} ".format(timePeriod[0],latitude[m][0],longitude[m][0],pressure[m][0],latitudeWind[m][0],longitudeWind[i][0],wind[i][0]) + if latitude[m][0]!=CODES_MISSING_DOUBLE: + print timePeriod[0],latitude[m][0],longitude[m][0],pressure[m][0], + #print " {:>3d}{}{:>6.1f}{}{:>6.1f}{}{:>8.1f}{}{:>6.1f}{}{:>6.1f}{}{:>6.1f}".format(\ + # timePeriod[0],' ',latitude[m][0],' ',longitude[m][0],' ',pressure[m][0],' ',latitudeWind[m][0],' ',longitudeWind[m][0],' ',wind[m][0]) + + for s in sorted( data[m].keys()): + if data[m][s][0]!=CODES_MISSING_DOUBLE: + print 'maja',s + #print " {:>3d}{}{:>6.1f}{}{:>6.1f}{}{:>8.1f}{}{:>6.1f}{}{:>6.1f}{}{:>6.1f}".format(\ + # timePeriod[s],' ',data[m][s][0],' ',data[m][s][1],' ',data[m][s][2],' ',data[m][s][3],' ',data[m][s][4],' ',data[m][s][5]) + #print "%d %.6g %.6g"%(timePeriod[s],data[m][s][0],data[m][s][1]) + + + + codes_release(gid) + + cnt += 1 + print 'majaaaaaaaaaaa',cnt + + #del(timePeriod) + #del(latitude) + #del(longitude) + #del(pressure) + #del(latitudeWind) + #del(longitudeWind) + #del(wind) + #del(data) + + # close the file + f.close() + + +def main(): + try: + example() + except CodesInternalError, err: + if VERBOSE: + traceback.print_exc(file=sys.stderr) + else: + print >>sys.stderr, err.msg + + return 1 + +if __name__ == "__main__": + sys.exit(main()) diff --git a/examples/python/bufr_read_tropical_cyclone.sh b/examples/python/bufr_read_tropical_cyclone.sh new file mode 100755 index 000000000..f86b50a77 --- /dev/null +++ b/examples/python/bufr_read_tropical_cyclone.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright 2005-2015 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.sh + + +#Define a common label for all the tmp files +label="bufr_read_tropical_cyclone_p" + +#Define tmp file +#fTmp=${label}.tmp.txt +#ref=${label}.tmp.ref +#rm -f $fTmp | true + +#We check "asca_1391.bufr". The path is +#hardcoded in the example + +REDIRECT=/dev/null + +echo $PYTHON $examples_src +#Write the key values into a file +#$PYTHON $examples_src/bufr_read_tropical_cyclone.py >$fTmp +$PYTHON $examples_src/bufr_read_tropical_cyclone.py + +#TODO: check the results + +#cat > $ref <>sys.stderr, err.msg - - return 1 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/examples/python/experimental/bufr_read_tropical_cyclone.sh b/examples/python/experimental/bufr_read_tropical_cyclone.sh deleted file mode 100755 index 59bf4ddbd..000000000 --- a/examples/python/experimental/bufr_read_tropical_cyclone.sh +++ /dev/null @@ -1,1183 +0,0 @@ -#!/bin/sh -# Copyright 2005-2015 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.sh - - -#Define a common label for all the tmp files -label="bufr_read_tropical_cyclone_p" - -#Define tmp file -fTmp=${label}.tmp.txt -ref=${label}.tmp.ref -rm -f $fTmp | true - -#We check "asca_1391.bufr". The path is -#hardcoded in the example - -REDIRECT=/dev/null - -echo $PYTHON $examples_src -#Write the key values into a file -$PYTHON $examples_src/bufr_read_tropical_cyclone.py >$fTmp - -#TODO: check the results - -cat > $ref < Date: Wed, 16 Dec 2015 11:49:29 +0000 Subject: [PATCH 07/14] Remove unnecessary ignores --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 7cb128f85..aaa6eb8aa 100644 --- a/.gitignore +++ b/.gitignore @@ -302,5 +302,3 @@ data/bufr/set_unexpandedDescriptors.filter *.sublime-workspace *.old -examples/python/1 -examples/python/Testing/ From b0289412c4b8e4a656fc35047900d201b29c0ddb Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 16 Dec 2015 11:49:59 +0000 Subject: [PATCH 08/14] Remove deprecated ecbuild macro --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db03faab7..202dcd615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ set( HAVE_LIBOPENJPEG 0 ) if( ENABLE_JPG ) - ecbuild_add_extra_search_paths( jasper ) # help standard cmake macro with ecmwf paths + #ecbuild_add_extra_search_paths( jasper ) # help standard cmake macro with ecmwf paths find_package( Jasper ) find_package( OpenJPEG ) From 0596e8df78528789f4b93c45b297c4c09081b098 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 16 Dec 2015 16:08:17 +0000 Subject: [PATCH 09/14] GRIB-899: Add new MARS class for CERA-SAT --- definitions/mars/class.table | 1 + 1 file changed, 1 insertion(+) diff --git a/definitions/mars/class.table b/definitions/mars/class.table index 077abb124..8887b7944 100644 --- a/definitions/mars/class.table +++ b/definitions/mars/class.table @@ -28,6 +28,7 @@ 27 s2 Sub-seasonal to seasonal prediction project (S2S) 28 j5 Japanese 55 year Reanalysis (JRA55) 29 ur UERRA +30 et CERA-SAT: ERA-CLIM2 coupled reanalysis of the satellite era 99 te Test 100 at Austria 101 be Belgium From 59e226bfe738f44f3b7d5764a626081dca5380c8 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 16 Dec 2015 17:38:09 +0000 Subject: [PATCH 10/14] GRIB-898: Encoding a constant field with grid_second_order generates error --- src/grib_loader_from_handle.c | 416 +++++++++++++++++----------------- src/grib_value.c | 53 +++-- 2 files changed, 238 insertions(+), 231 deletions(-) diff --git a/src/grib_loader_from_handle.c b/src/grib_loader_from_handle.c index 6d537d332..aed34129c 100644 --- a/src/grib_loader_from_handle.c +++ b/src/grib_loader_from_handle.c @@ -12,264 +12,262 @@ static int copy_values(grib_handle* h,grib_accessor* ga) { - int i,j,k; - /* printf("copy_values stack is %ld\n",(long)h->values_stack);*/ - for(j = 0; j < h->values_stack; j++) - { - for(i = 0; i < h->values_count[j]; i++) - { - for(k = 0; (k < MAX_ACCESSOR_NAMES) && (ga->all_names[k] != NULL); k++) - { - /*printf("copy_values: %s %s\n",h->values[j][i].name,ga->all_names[k]);*/ - if(strcmp(h->values[j][i].name,ga->all_names[k]) == 0) - { - size_t len = 1; - /*printf("SET VALUES %s\n",h->values[j][i].name);*/ - switch(h->values[j][i].type) - { - case GRIB_TYPE_LONG: - return grib_pack_long(ga,&h->values[j][i].long_value,&len); - break; + int i,j,k; + /* printf("copy_values stack is %ld\n",(long)h->values_stack);*/ + for(j = 0; j < h->values_stack; j++) + { + for(i = 0; i < h->values_count[j]; i++) + { + for(k = 0; (k < MAX_ACCESSOR_NAMES) && (ga->all_names[k] != NULL); k++) + { + /*printf("copy_values: %s %s\n",h->values[j][i].name,ga->all_names[k]);*/ + if(strcmp(h->values[j][i].name,ga->all_names[k]) == 0) + { + size_t len = 1; + /*printf("SET VALUES %s\n",h->values[j][i].name);*/ + switch(h->values[j][i].type) + { + case GRIB_TYPE_LONG: + return grib_pack_long(ga,&h->values[j][i].long_value,&len); + break; - case GRIB_TYPE_DOUBLE: - return grib_pack_double(ga,&h->values[j][i].double_value,&len); - break; + case GRIB_TYPE_DOUBLE: + return grib_pack_double(ga,&h->values[j][i].double_value,&len); + break; - case GRIB_TYPE_STRING: - len = strlen(h->values[j][i].string_value); - return grib_pack_string(ga,h->values[j][i].string_value,&len); - break; - } - } - } - } - } + case GRIB_TYPE_STRING: + len = strlen(h->values[j][i].string_value); + return grib_pack_string(ga,h->values[j][i].string_value,&len); + break; + } + } + } + } + } - return GRIB_NOT_FOUND; + return GRIB_NOT_FOUND; } - int grib_lookup_long_from_handle(grib_context* gc,grib_loader* loader,const char* name,long* value) { - grib_handle* h = (grib_handle*)loader->data; - grib_accessor *b = grib_find_accessor(h,name); - size_t len = 1; - if(b) return grib_unpack_long(b,value,&len); + grib_handle* h = (grib_handle*)loader->data; + grib_accessor *b = grib_find_accessor(h,name); + size_t len = 1; + if(b) return grib_unpack_long(b,value,&len); - /* TODO: fix me. For now, we don't fail on a lookup. */ + /* TODO: fix me. For now, we don't fail on a lookup. */ #if 1 - *value = -1; - return GRIB_SUCCESS; + *value = -1; + return GRIB_SUCCESS; #else - return GRIB_NOT_FOUND; + return GRIB_NOT_FOUND; #endif } int grib_init_accessor_from_handle(grib_loader* loader,grib_accessor* ga,grib_arguments* default_value) { - grib_handle* h = (grib_handle*)loader->data; - int ret = GRIB_SUCCESS; - size_t len = 0; - char* sval = NULL; - unsigned char* uval = NULL; - long* lval = NULL; - double* dval = NULL; - static int first = 1; - static const char* missing = 0; - const char* name = NULL; - int k = 0; - grib_handle *g; - int e, pack_missing = 0; - grib_context_log(h->context,GRIB_LOG_DEBUG, "XXXXX Copying %s", ga->name); + grib_handle* h = (grib_handle*)loader->data; + int ret = GRIB_SUCCESS; + size_t len = 0; + char* sval = NULL; + unsigned char* uval = NULL; + long* lval = NULL; + double* dval = NULL; + static int first = 1; + static const char* missing = 0; + const char* name = NULL; + int k = 0; + grib_handle *g; + int e, pack_missing = 0; + grib_context_log(h->context,GRIB_LOG_DEBUG, "XXXXX Copying %s", ga->name); - if(default_value) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to default value", - ga->name); - grib_pack_expression(ga,grib_arguments_get_expression(h,default_value,0)); - } + if(default_value) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to default value", + ga->name); + grib_pack_expression(ga,grib_arguments_get_expression(h,default_value,0)); + } - if( (ga->flags & GRIB_ACCESSOR_FLAG_NO_COPY) || - ((ga->flags & GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC) && - loader->changing_edition ) || - (ga->flags & GRIB_ACCESSOR_FLAG_FUNCTION) || - ( (ga->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) && - !(ga->flags & GRIB_ACCESSOR_FLAG_COPY_OK) ) ) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %s ignored", ga->name); - return GRIB_SUCCESS; - } + if( (ga->flags & GRIB_ACCESSOR_FLAG_NO_COPY) || + ((ga->flags & GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC) && + loader->changing_edition ) || + (ga->flags & GRIB_ACCESSOR_FLAG_FUNCTION) || + ( (ga->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) && + !(ga->flags & GRIB_ACCESSOR_FLAG_COPY_OK) ) ) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %s ignored", ga->name); + return GRIB_SUCCESS; + } #if 0 - if(h->values) - if(copy_values(h,ga) == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); - return GRIB_SUCCESS; - } + if(h->values) + if(copy_values(h,ga) == GRIB_SUCCESS) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); + return GRIB_SUCCESS; + } #endif #if 0 - if(h->loader) - h->loader->init_accessor(h->loader,ga,default_value); + if(h->loader) + h->loader->init_accessor(h->loader,ga,default_value); #else - /* COMEBACK here + /* COMEBACK here this is needed if we reparse during reparse.... - */ + */ - g = h; - while(g) - { - if(g->values) { - if(copy_values(g,ga) == GRIB_SUCCESS) { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); - return GRIB_SUCCESS; - } - } - g = g->main; - } + g = h; + while(g) + { + if(g->values) { + if(copy_values(g,ga) == GRIB_SUCCESS) { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying: setting %s to multi-set-value", ga->name); + return GRIB_SUCCESS; + } + } + g = g->main; + } #endif - /* Check if the same name exists in the original message ... */ - k = 0; - while( (k < MAX_ACCESSOR_NAMES) && - ((name = ga->all_names[k]) != NULL) && - ((ret = grib_get_size(h,name,&len)) != GRIB_SUCCESS)) k++; + /* Check if the same name exists in the original message ... */ + k = 0; + while( (k < MAX_ACCESSOR_NAMES) && + ((name = ga->all_names[k]) != NULL) && + ((ret = grib_get_size(h,name,&len)) != GRIB_SUCCESS)) k++; - if(ret != GRIB_SUCCESS) - { - name = ga->name; + if(ret != GRIB_SUCCESS) + { + name = ga->name; - if(first) - { - missing = getenv("ECCODES_PRINT_MISSING"); - first = 0; - } + if(first) + { + missing = getenv("ECCODES_PRINT_MISSING"); + first = 0; + } - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying [%s] failed: %s", - name,grib_get_error_message(ret)); + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying [%s] failed: %s", + name,grib_get_error_message(ret)); - if(missing) - { - fprintf(stdout,"REPARSE: no value for %s",name); - if(default_value) - fprintf(stdout," (default value)"); - fprintf(stdout,"\n"); - } + if(missing) + { + fprintf(stdout,"REPARSE: no value for %s",name); + if(default_value) + fprintf(stdout," (default value)"); + fprintf(stdout,"\n"); + } - return GRIB_SUCCESS; - } + return GRIB_SUCCESS; + } - /* we copy also virtual keys*/ - if(len == 0) { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %s failed, length is 0", name); - return GRIB_SUCCESS; - } + /* we copy also virtual keys*/ + if(len == 0) { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %s failed, length is 0", name); + return GRIB_SUCCESS; + } - if((ga->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && grib_is_missing(h,name,&e) && e == GRIB_SUCCESS && len == 1) - { - grib_pack_missing(ga); - pack_missing = 1; - } + if((ga->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) && grib_is_missing(h,name,&e) && e == GRIB_SUCCESS && len == 1) + { + grib_pack_missing(ga); + pack_missing = 1; + } - switch(grib_accessor_get_native_type(ga)) - { - case GRIB_TYPE_STRING: + switch(grib_accessor_get_native_type(ga)) + { + case GRIB_TYPE_STRING: - /* len = len > 1024 ? len : 1024; */ - _grib_get_string_length(ga,&len); - sval = (char*)grib_context_malloc(h->context,len); - ret = grib_get_string_internal(h,name,sval,&len); - if(ret == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying string %s to %s", sval, name); - ret = grib_pack_string(ga,sval,&len); - } - grib_context_free(h->context,sval); + /* len = len > 1024 ? len : 1024; */ + _grib_get_string_length(ga,&len); + sval = (char*)grib_context_malloc(h->context,len); + ret = grib_get_string_internal(h,name,sval,&len); + if(ret == GRIB_SUCCESS) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying string %s to %s", sval, name); + ret = grib_pack_string(ga,sval,&len); + } + grib_context_free(h->context,sval); - break; + break; - case GRIB_TYPE_LONG: - lval = (long*)grib_context_malloc(h->context,len*sizeof(long)); - ret = grib_get_long_array_internal(h,name,lval,&len); - if(ret == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d long(s) %d to %s", len, lval[0], name); - if(ga->same) - { - ret = grib_set_long_array(grib_handle_of_accessor(ga),ga->name,lval,len); + case GRIB_TYPE_LONG: + lval = (long*)grib_context_malloc(h->context,len*sizeof(long)); + ret = grib_get_long_array_internal(h,name,lval,&len); + if(ret == GRIB_SUCCESS) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d long(s) %d to %s", len, lval[0], name); + if(ga->same) + { + ret = grib_set_long_array(grib_handle_of_accessor(ga),ga->name,lval,len); - /* Allow for lists to be resized */ - if((ret == GRIB_WRONG_ARRAY_SIZE || ret == GRIB_ARRAY_TOO_SMALL) && loader->list_is_resized) - ret = GRIB_SUCCESS; - } - else - { - /* See GRIB-492. This is NOT an ideal solution! */ - if (*lval == GRIB_MISSING_LONG || pack_missing) - { - ; /* No checks needed */ - } - else - { - /* If we have just one key of type long which has one octet, then do not exceed maximum value */ - const long num_octets = ga->length; - if (len == 1 && num_octets == 1 && *lval > 255) - { - *lval = 0; /* Reset to a reasonable value */ - } - } - ret = grib_pack_long(ga,lval,&len); - } - } + /* Allow for lists to be resized */ + if((ret == GRIB_WRONG_ARRAY_SIZE || ret == GRIB_ARRAY_TOO_SMALL) && loader->list_is_resized) + ret = GRIB_SUCCESS; + } + else + { + /* See GRIB-492. This is NOT an ideal solution! */ + if (*lval == GRIB_MISSING_LONG || pack_missing) + { + ; /* No checks needed */ + } + else + { + /* If we have just one key of type long which has one octet, then do not exceed maximum value */ + const long num_octets = ga->length; + if (len == 1 && num_octets == 1 && *lval > 255) + { + *lval = 0; /* Reset to a reasonable value */ + } + } + ret = grib_pack_long(ga,lval,&len); + } + } - grib_context_free(h->context,lval); + grib_context_free(h->context,lval); - break; + break; - case GRIB_TYPE_DOUBLE: - dval = (double*)grib_context_malloc(h->context,len*sizeof(double)); - ret = grib_get_double_array_internal(h,name,dval,&len); - if(ret == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d double(s) %g to %s", len, dval[0], name); - if(ga->same) - { - ret = grib_set_double_array(grib_handle_of_accessor(ga),ga->name,dval,len); + case GRIB_TYPE_DOUBLE: + dval = (double*)grib_context_malloc(h->context,len*sizeof(double)); + ret = grib_get_double_array(h,name,dval,&len); /* GRIB-898 */ + if(ret == GRIB_SUCCESS) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d double(s) %g to %s", len, dval[0], name); + if(ga->same) + { + ret = grib_set_double_array(grib_handle_of_accessor(ga),ga->name,dval,len); - /* Allow for lists to be resized */ - if((ret == GRIB_WRONG_ARRAY_SIZE || ret == GRIB_ARRAY_TOO_SMALL) && loader->list_is_resized) - ret = GRIB_SUCCESS; - } - else ret = grib_pack_double(ga,dval,&len); - } + /* Allow for lists to be resized */ + if((ret == GRIB_WRONG_ARRAY_SIZE || ret == GRIB_ARRAY_TOO_SMALL) && loader->list_is_resized) + ret = GRIB_SUCCESS; + } + else ret = grib_pack_double(ga,dval,&len); + } - grib_context_free(h->context,dval); - break; + grib_context_free(h->context,dval); + break; - case GRIB_TYPE_BYTES: + case GRIB_TYPE_BYTES: - uval = (unsigned char*)grib_context_malloc(h->context,len*sizeof(char)); - ret = grib_get_bytes_internal(h,name,uval,&len); - if(ret == GRIB_SUCCESS) - { - grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d byte(s) to %s", len, name); - ret = grib_pack_bytes(ga,uval,&len); - } + uval = (unsigned char*)grib_context_malloc(h->context,len*sizeof(char)); + ret = grib_get_bytes_internal(h,name,uval,&len); + if(ret == GRIB_SUCCESS) + { + grib_context_log(h->context,GRIB_LOG_DEBUG, "Copying %d byte(s) to %s", len, name); + ret = grib_pack_bytes(ga,uval,&len); + } - grib_context_free(h->context,uval); + grib_context_free(h->context,uval); - break; + break; - case GRIB_TYPE_LABEL: - break; + case GRIB_TYPE_LABEL: + break; - default: - grib_context_log(h->context,GRIB_LOG_ERROR, "Copying %s, cannot establish type %d [%s]" - , name,grib_accessor_get_native_type(ga),ga->creator->cclass->name); - break; - } - - return ret; + default: + grib_context_log(h->context,GRIB_LOG_ERROR, "Copying %s, cannot establish type %d [%s]" + , name,grib_accessor_get_native_type(ga),ga->creator->cclass->name); + break; + } + return ret; } diff --git a/src/grib_value.c b/src/grib_value.c index 4251e89c2..bf6029317 100644 --- a/src/grib_value.c +++ b/src/grib_value.c @@ -61,7 +61,7 @@ int grib_set_long_internal(grib_handle* h, const char* name, long val) { a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_long_internal %s=%ld\n",name,(long)val); if(a){ @@ -86,7 +86,7 @@ int grib_set_long(grib_handle* h, const char* name, long val) { a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_long %s=%ld\n",name,(long)val); if(a){ @@ -109,7 +109,7 @@ int grib_set_double_internal(grib_handle* h, const char* name, double val) { a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_double_internal %s=%g\n",name,val); if(a){ @@ -299,7 +299,7 @@ int grib_set_double(grib_handle* h, const char* name, double val) { a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_double %s=%g\n",name,val); if(a){ @@ -324,7 +324,7 @@ int grib_set_string_internal(grib_handle* h, const char* name, a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_string_internal %s=%s\n",name,val); if(a){ @@ -347,27 +347,33 @@ int grib_set_string(grib_handle* h, const char* name, const char* val, size_t *l int ret=0; grib_accessor* a; -#if 1 - /* Second order doesn't have a proper representation for constant fields - the best is not to do the change of packing type if bitsPerValue=0 + /* Second order doesn't have a proper representation for constant fields. + So best not to do the change of packing type */ if (!grib_inline_strcmp(name,"packingType") && !grib_inline_strcmp(val,"grid_second_order")) { long bitsPerValue=0; size_t numCodedVals = 0; grib_get_long(h,"bitsPerValue",&bitsPerValue); - if (bitsPerValue==0) return 0; + if (bitsPerValue==0) { + if (h->context->debug) { + printf("ECCODES DEBUG grib_set_string packingType: Constant field cannot be encoded in second order. Packing not changed\n"); + } + return 0; + } /* GRIB-883: check if there are enough coded values */ ret = grib_get_size(h, "codedValues", &numCodedVals); if (ret == GRIB_SUCCESS && numCodedVals < 3) { + if (h->context->debug) { + printf("ECCODES DEBUG grib_set_string packingType: not enough coded values for second order. Packing not changed\n"); + } return 0; } } -#endif a = grib_find_accessor(h, name); - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_string %s=%s\n",name,val); if(a) @@ -625,7 +631,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl { int ret=0; - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_double_array_internal key=%s %ld values\n",name, (long)length); if (length==0) { @@ -638,7 +644,7 @@ int grib_set_double_array_internal(grib_handle* h, const char* name, const doubl if (ret!=GRIB_SUCCESS) grib_context_log(h->context,GRIB_LOG_ERROR,"unable to set double array %s (%s)", name,grib_get_error_message(ret)); - /*if (h->context->debug==-1) printf("ECCODES DEBUG grib_set_double_array_internal key=%s --DONE\n",name);*/ + /*if (h->context->debug) printf("ECCODES DEBUG grib_set_double_array_internal key=%s --DONE\n",name);*/ return ret; } @@ -647,7 +653,7 @@ static int __grib_set_double_array(grib_handle* h, const char* name, const doubl double v=val[0]; int constant,i; - if (h->context->debug==-1) + if (h->context->debug) printf("ECCODES DEBUG grib_set_double_array key=%s %ld values\n",name,(long)length); if (length==0) { @@ -688,10 +694,17 @@ static int __grib_set_double_array(grib_handle* h, const char* name, const doubl !strcmp(packingType,"grid_second_order_SPD2") || !strcmp(packingType,"grid_second_order_SPD3") ) { + int ret = 0; slen=11; /*length of 'grid_simple' */ - if (h->context->debug == -1) - printf("ECCODES DEBUG grib_set_double_array forcing grid_simple\n"); - grib_set_string(h,"packingType","grid_simple",&slen); + if (h->context->debug) { + printf("ECCODES DEBUG __grib_set_double_array: Cannot use second order packing for constant fields. Using simple packing\n"); + } + ret = grib_set_string(h,"packingType","grid_simple",&slen); + if (ret != GRIB_SUCCESS) { + if (h->context->debug) { + printf("ECCODES DEBUG __grib_set_double_array: could not switch to simple packing!\n"); + } + } } } } @@ -999,7 +1012,6 @@ int grib_get_native_type(grib_handle* h, const char* name,int* type) } return GRIB_SUCCESS; - } const char* grib_get_accessor_class_name(grib_handle* h, const char* name) @@ -1010,9 +1022,8 @@ const char* grib_get_accessor_class_name(grib_handle* h, const char* name) int _grib_get_double_array_internal(grib_handle* h,grib_accessor* a,double* val, size_t buffer_len,size_t *decoded_length) { - int err; if(a) { - err = _grib_get_double_array_internal(h,a->same,val,buffer_len,decoded_length); + int err = _grib_get_double_array_internal(h,a->same,val,buffer_len,decoded_length); if ( err == GRIB_SUCCESS ) { @@ -1041,7 +1052,6 @@ int grib_get_double_array_internal(grib_handle* h, const char* name, double* val return ret; } - int grib_get_double_array(grib_handle* h, const char* name, double* val, size_t *length) { size_t len = *length; @@ -1067,7 +1077,6 @@ int grib_get_double_array(grib_handle* h, const char* name, double* val, size_t } } - int _grib_get_string_length(grib_accessor* a, size_t* size) { size_t s=0; From ce2d1ed49fb810a3fe8941088ad236428cdb9183 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 17 Dec 2015 11:11:42 +0000 Subject: [PATCH 11/14] ECBUILD-190: suppress deprecation messages --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 202dcd615..5e16b4133 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,8 +106,16 @@ set( HAVE_LIBOPENJPEG 0 ) if( ENABLE_JPG ) - #ecbuild_add_extra_search_paths( jasper ) # help standard cmake macro with ecmwf paths + # Note: This is a deprecated feature but we need it to find Jasper at ECMWF. + # ecbuild_add_extra_search_paths modifies CMAKE_PREFIX_PATH + # which can affect future package discovery if not undone by the caller. + # The current CMAKE_PREFIX_PATH is backed up as _CMAKE_PREFIX_PATH + # + set(ECBUILD_NO_DEPRECATIONS ON) # Suppress deprecation message + ecbuild_add_extra_search_paths( jasper ) find_package( Jasper ) + set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH + set(ECBUILD_NO_DEPRECATIONS OFF) # Remove suppression find_package( OpenJPEG ) From 96c7846fc36a3d186890551147771801b606a110 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 17 Dec 2015 14:01:19 +0000 Subject: [PATCH 12/14] Suppress error output from tests --- examples/python/binary_message.sh | 2 +- examples/python/bufr_set_keys.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/python/binary_message.sh b/examples/python/binary_message.sh index 14971b53b..ba9c95616 100755 --- a/examples/python/binary_message.sh +++ b/examples/python/binary_message.sh @@ -13,7 +13,7 @@ rm $OUTPUT || true # We are expecting the command to fail so must turn off "set -e" INPUT=${data_dir}/bad.grib set +e -$PYTHON $examples_src/binary_message.py $INPUT $OUTPUT +$PYTHON $examples_src/binary_message.py $INPUT $OUTPUT 2>/dev/null status=$? set -e # Check command did indeed fail diff --git a/examples/python/bufr_set_keys.sh b/examples/python/bufr_set_keys.sh index 294c0a4e8..bd0ce62e3 100755 --- a/examples/python/bufr_set_keys.sh +++ b/examples/python/bufr_set_keys.sh @@ -28,7 +28,7 @@ $PYTHON $examples_src/bufr_set_keys.py 2> $REDIRECT > $REDIRECT #Compare modified to the original set +e -${tools_dir}/bufr_compare $f $fBufrTmp +${tools_dir}/bufr_compare $f $fBufrTmp 1>$REDIRECT 2> $REDIRECT #Check if modified is different if [ $? -eq 0 ]; then From 2a3c5415e89e5712d62e66958b09263de6843aec Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 17 Dec 2015 16:06:57 +0000 Subject: [PATCH 13/14] GRIB-764 and GRIB-824: Amendments --- .../grib1/localConcepts/ecmf/shortName.def | 4 +- definitions/grib1/param.pl | 3 +- definitions/grib2/cfVarName.def | 24 +++++----- definitions/grib2/name.def | 48 +++++++++---------- definitions/grib2/paramId.def | 24 +++++----- definitions/grib2/shortName.def | 24 +++++----- definitions/grib2/units.def | 24 +++++----- 7 files changed, 75 insertions(+), 76 deletions(-) diff --git a/definitions/grib1/localConcepts/ecmf/shortName.def b/definitions/grib1/localConcepts/ecmf/shortName.def index dbc664b2e..bed90bd2f 100644 --- a/definitions/grib1/localConcepts/ecmf/shortName.def +++ b/definitions/grib1/localConcepts/ecmf/shortName.def @@ -9330,12 +9330,12 @@ indicatorOfParameter = 251 ; } #Mean surface runoff rate -'msrr' = { +'msror' = { table2Version = 235 ; indicatorOfParameter = 20 ; } #Mean sub-surface runoff rate -'mssrr' = { +'mssror' = { table2Version = 235 ; indicatorOfParameter = 21 ; } diff --git a/definitions/grib1/param.pl b/definitions/grib1/param.pl index c8e27d6a1..93bc6c4fd 100755 --- a/definitions/grib1/param.pl +++ b/definitions/grib1/param.pl @@ -21,10 +21,9 @@ foreach my $p ( metdb::grib_parameters->find( my $file = "2.$centre.$table.table"; if($file ne $last) { - #system("p4 edit $file"); open(OUT,">$file") or die "$file: $!"; print OUT "# This file was automatically generated by $0\n"; - #system("p4 add $file"); + $last = $file; } diff --git a/definitions/grib2/cfVarName.def b/definitions/grib2/cfVarName.def index e4a226b9c..18fcf7325 100644 --- a/definitions/grib2/cfVarName.def +++ b/definitions/grib2/cfVarName.def @@ -209,84 +209,84 @@ parameterCategory = 0 ; parameterNumber = 33 ; } -#Mean temperature tendency due to parametrized short-wave radiation +#Mean temperature tendency due to short-wave radiation 'mttsr' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 22 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation +#Mean temperature tendency due to long-wave radiation 'mtttr' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 23 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized short-wave radiation, clear sky +#Mean temperature tendency due to short-wave radiation, clear sky 'mttsrc' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 24 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation, clear sky +#Mean temperature tendency due to long-wave radiation, clear sky 'mtttrc' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 25 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrizations +#Mean temperature tendency due to parametrisations 'mttpm' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 26 ; typeOfStatisticalProcessing = 0 ; } -#Mean specific humidity tendency due to parametrizations +#Mean specific humidity tendency due to parametrisations 'mqtpm' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 108 ; typeOfStatisticalProcessing = 0 ; } -#Mean eastward wind tendency due to parametrizations +#Mean eastward wind tendency due to parametrisations 'mutpm' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 39 ; typeOfStatisticalProcessing = 0 ; } -#Mean northward wind tendency due to parametrizations +#Mean northward wind tendency due to parametrisations 'mvtpm' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 40 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught mass flux due to parametrized convection +#Mean updraught mass flux 'mumf' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 27 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught mass flux due to parametrized convection +#Mean downdraught mass flux 'mdmf' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught detrainment rate due to parametrized convection +#Mean updraught detrainment rate 'mudr' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 29 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught detrainment rate due to parametrized convection +#Mean downdraught detrainment rate 'mddr' = { discipline = 0 ; parameterCategory = 3 ; diff --git a/definitions/grib2/name.def b/definitions/grib2/name.def index 5d13badfb..cc38096d1 100644 --- a/definitions/grib2/name.def +++ b/definitions/grib2/name.def @@ -209,85 +209,85 @@ parameterCategory = 0 ; parameterNumber = 33 ; } -#Mean temperature tendency due to parametrized short-wave radiation -'Mean temperature tendency due to parametrized short-wave radiation' = { +#Mean temperature tendency due to short-wave radiation +'Mean temperature tendency due to short-wave radiation' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 22 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation -'Mean temperature tendency due to parametrized long-wave radiation' = { +#Mean temperature tendency due to long-wave radiation +'Mean temperature tendency due to long-wave radiation' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 23 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized short-wave radiation, clear sky -'Mean temperature tendency due to parametrized short-wave radiation, clear sky' = { +#Mean temperature tendency due to short-wave radiation, clear sky +'Mean temperature tendency due to short-wave radiation, clear sky' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 24 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation, clear sky -'Mean temperature tendency due to parametrized long-wave radiation, clear sky' = { +#Mean temperature tendency due to long-wave radiation, clear sky +'Mean temperature tendency due to long-wave radiation, clear sky' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 25 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrizations -'Mean temperature tendency due to parametrizations' = { +#Mean temperature tendency due to parametrisations +'Mean temperature tendency due to parametrisations' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 26 ; typeOfStatisticalProcessing = 0 ; } -#Mean specific humidity tendency due to parametrizations -'Mean specific humidity tendency due to parametrizations' = { +#Mean specific humidity tendency due to parametrisations +'Mean specific humidity tendency due to parametrisations' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 108 ; typeOfStatisticalProcessing = 0 ; } -#Mean eastward wind tendency due to parametrizations -'Mean eastward wind tendency due to parametrizations' = { +#Mean eastward wind tendency due to parametrisations +'Mean eastward wind tendency due to parametrisations' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 39 ; typeOfStatisticalProcessing = 0 ; } -#Mean northward wind tendency due to parametrizations -'Mean northward wind tendency due to parametrizations' = { +#Mean northward wind tendency due to parametrisations +'Mean northward wind tendency due to parametrisations' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 40 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught mass flux due to parametrized convection -'Mean updraught mass flux due to parametrized convection' = { +#Mean updraught mass flux +'Mean updraught mass flux' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 27 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught mass flux due to parametrized convection -'Mean downdraught mass flux due to parametrized convection' = { +#Mean downdraught mass flux +'Mean downdraught mass flux' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught detrainment rate due to parametrized convection -'Mean updraught detrainment rate due to parametrized convection' = { +#Mean updraught detrainment rate +'Mean updraught detrainment rate' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 29 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught detrainment rate due to parametrized convection -'Mean downdraught detrainment rate due to parametrized convection' = { +#Mean downdraught detrainment rate +'Mean downdraught detrainment rate' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 30 ; diff --git a/definitions/grib2/paramId.def b/definitions/grib2/paramId.def index bcba3813f..3d630d7c8 100644 --- a/definitions/grib2/paramId.def +++ b/definitions/grib2/paramId.def @@ -209,84 +209,84 @@ parameterCategory = 0 ; parameterNumber = 33 ; } -#Mean temperature tendency due to parametrized short-wave radiation +#Mean temperature tendency due to short-wave radiation '235001' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 22 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation +#Mean temperature tendency due to long-wave radiation '235002' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 23 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized short-wave radiation, clear sky +#Mean temperature tendency due to short-wave radiation, clear sky '235003' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 24 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation, clear sky +#Mean temperature tendency due to long-wave radiation, clear sky '235004' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 25 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrizations +#Mean temperature tendency due to parametrisations '235005' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 26 ; typeOfStatisticalProcessing = 0 ; } -#Mean specific humidity tendency due to parametrizations +#Mean specific humidity tendency due to parametrisations '235006' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 108 ; typeOfStatisticalProcessing = 0 ; } -#Mean eastward wind tendency due to parametrizations +#Mean eastward wind tendency due to parametrisations '235007' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 39 ; typeOfStatisticalProcessing = 0 ; } -#Mean northward wind tendency due to parametrizations +#Mean northward wind tendency due to parametrisations '235008' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 40 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught mass flux due to parametrized convection +#Mean updraught mass flux '235009' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 27 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught mass flux due to parametrized convection +#Mean downdraught mass flux '235010' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught detrainment rate due to parametrized convection +#Mean updraught detrainment rate '235011' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 29 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught detrainment rate due to parametrized convection +#Mean downdraught detrainment rate '235012' = { discipline = 0 ; parameterCategory = 3 ; diff --git a/definitions/grib2/shortName.def b/definitions/grib2/shortName.def index 122e99ecc..09312b286 100644 --- a/definitions/grib2/shortName.def +++ b/definitions/grib2/shortName.def @@ -209,84 +209,84 @@ parameterCategory = 0 ; parameterNumber = 33 ; } -#Mean temperature tendency due to parametrized short-wave radiation +#Mean temperature tendency due to short-wave radiation 'mttsr' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 22 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation +#Mean temperature tendency due to long-wave radiation 'mtttr' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 23 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized short-wave radiation, clear sky +#Mean temperature tendency due to short-wave radiation, clear sky 'mttsrc' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 24 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation, clear sky +#Mean temperature tendency due to long-wave radiation, clear sky 'mtttrc' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 25 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrizations +#Mean temperature tendency due to parametrisations 'mttpm' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 26 ; typeOfStatisticalProcessing = 0 ; } -#Mean specific humidity tendency due to parametrizations +#Mean specific humidity tendency due to parametrisations 'mqtpm' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 108 ; typeOfStatisticalProcessing = 0 ; } -#Mean eastward wind tendency due to parametrizations +#Mean eastward wind tendency due to parametrisations 'mutpm' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 39 ; typeOfStatisticalProcessing = 0 ; } -#Mean northward wind tendency due to parametrizations +#Mean northward wind tendency due to parametrisations 'mvtpm' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 40 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught mass flux due to parametrized convection +#Mean updraught mass flux 'mumf' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 27 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught mass flux due to parametrized convection +#Mean downdraught mass flux 'mdmf' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught detrainment rate due to parametrized convection +#Mean updraught detrainment rate 'mudr' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 29 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught detrainment rate due to parametrized convection +#Mean downdraught detrainment rate 'mddr' = { discipline = 0 ; parameterCategory = 3 ; diff --git a/definitions/grib2/units.def b/definitions/grib2/units.def index 81cfb0208..7a944fae5 100644 --- a/definitions/grib2/units.def +++ b/definitions/grib2/units.def @@ -209,84 +209,84 @@ parameterCategory = 0 ; parameterNumber = 33 ; } -#Mean temperature tendency due to parametrized short-wave radiation +#Mean temperature tendency due to short-wave radiation 'K s**-1' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 22 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation +#Mean temperature tendency due to long-wave radiation 'K s**-1' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 23 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized short-wave radiation, clear sky +#Mean temperature tendency due to short-wave radiation, clear sky 'K s**-1' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 24 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrized long-wave radiation, clear sky +#Mean temperature tendency due to long-wave radiation, clear sky 'K s**-1' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 25 ; typeOfStatisticalProcessing = 0 ; } -#Mean temperature tendency due to parametrizations +#Mean temperature tendency due to parametrisations 'K s**-1' = { discipline = 0 ; parameterCategory = 0 ; parameterNumber = 26 ; typeOfStatisticalProcessing = 0 ; } -#Mean specific humidity tendency due to parametrizations +#Mean specific humidity tendency due to parametrisations 'kg kg**-1 s**-1' = { discipline = 0 ; parameterCategory = 1 ; parameterNumber = 108 ; typeOfStatisticalProcessing = 0 ; } -#Mean eastward wind tendency due to parametrizations +#Mean eastward wind tendency due to parametrisations 'm s**-2' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 39 ; typeOfStatisticalProcessing = 0 ; } -#Mean northward wind tendency due to parametrizations +#Mean northward wind tendency due to parametrisations 'm s**-2' = { discipline = 0 ; parameterCategory = 2 ; parameterNumber = 40 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught mass flux due to parametrized convection +#Mean updraught mass flux 'kg m**-2 s**-1' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 27 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught mass flux due to parametrized convection +#Mean downdraught mass flux 'kg m**-2 s**-1' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 28 ; typeOfStatisticalProcessing = 0 ; } -#Mean updraught detrainment rate due to parametrized convection +#Mean updraught detrainment rate 'kg m**-3 s**-1' = { discipline = 0 ; parameterCategory = 3 ; parameterNumber = 29 ; typeOfStatisticalProcessing = 0 ; } -#Mean downdraught detrainment rate due to parametrized convection +#Mean downdraught detrainment rate 'kg m**-3 s**-1' = { discipline = 0 ; parameterCategory = 3 ; From 48c948a7681dc4d91cebe6ef9eab6b5463c01fc3 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 17 Dec 2015 18:21:14 +0000 Subject: [PATCH 14/14] GRIB-203: grib_ls -l fails with 2nd order packed boustrophedonic ordering --- ..._accessor_class_data_apply_boustrophedonic.c | 17 ++++++++++++++++- tests/second_order.sh | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/grib_accessor_class_data_apply_boustrophedonic.c b/src/grib_accessor_class_data_apply_boustrophedonic.c index f2b74c526..4e7b4937c 100644 --- a/src/grib_accessor_class_data_apply_boustrophedonic.c +++ b/src/grib_accessor_class_data_apply_boustrophedonic.c @@ -254,7 +254,22 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len) static int unpack_double_element(grib_accessor* a, size_t idx,double* val) { - return GRIB_NOT_IMPLEMENTED; + size_t size; + double* values; + int err = 0; + + /* GRIB-564: The index idx relates to codedValues NOT values! */ + + err=grib_get_size(a->parent->h,"codedValues",&size); + if (err) return err; + if (idx > size) return GRIB_INVALID_NEAREST; + + values=(double*)grib_context_malloc_clear(a->parent->h->context,size*sizeof(double)); + err=grib_get_double_array(a->parent->h,"codedValues",values,&size); + if (err) return err; + *val=values[idx]; + grib_context_free(a->parent->h->context,values); + return err; } static int pack_double(grib_accessor* a, const double* val, size_t *len) diff --git a/tests/second_order.sh b/tests/second_order.sh index ed5804493..bb82fe33c 100755 --- a/tests/second_order.sh +++ b/tests/second_order.sh @@ -96,6 +96,9 @@ res=`${tools_dir}grib_get -l 33,88.5 $sec_ord_bmp` res=`${tools_dir}/grib_get -l 28.5,90 $sec_ord_bmp` [ "$res" = "3.51552 9999 5.26552 9999 " ] +# GRIB-203 nearest on M-F second order boustrophedonic +res=`${tools_dir}grib_get -w count=1 -l 0,0 lfpw.grib1` +[ "$res" = "20560.7 20563.4 20554.7 20559.5 " ] rm -f $sec_ord_bmp rm -f test.filter