Issues Setting tags for GRIB messsages when outputting to GRIB


Shane Mill - NOAA Affiliate
 

Hello,

When writing data to GRIB files, I've noticed sometimes an inconsistency with setting the GRIB_PDS_TEMPLATE_NUMBERS. This parameter drives the parameter name for the GRIB message.

Below is a snippet of the code:

with rasterio.open('/mnt/data-api/output.grb', 'r+', driver='GRIB',DATA_ENCODING='SIMPLE_PACKING') as ds:
    for idx,t in enumerate(tags,start=0):
       ds.update_tags(idx+1,GRIB_PDS_TEMPLATE_NUMBERS=t['GRIB_PDS_TEMPLATE_NUMBERS'])
       ds.update_tags(idx+1,GRIB_IDS=t['GRIB_IDS'])

tags is a prepopulated list containing the "tags" for each grib message. I am simply updating the tags in the new GRIB file to contain the correct GRIB_PDS_TEMPLATE_NUMBERS and GRIB_IDS.

The problem- Sometimes, the tag is not properly set. 

An example: For the Grib parameterName "Soil Temperature", this is the corresponding tag:

{'GRIB_COMMENT': 'Soil temperature [C]', 'GRIB_DISCIPLINE': '2(Land_Surface)', 'GRIB_ELEMENT': 'TSOIL', 'GRIB_FORECAST_SECONDS': '0 sec', 'GRIB_IDS': 'CENTER=7(US-NCEP) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=1 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2020-09-29T00:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast)', 'GRIB_PDS_PDTN': '0', 'GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES': '0 2 2 0 81 0 0 1 0 106 0 1 106 2 200', 'GRIB_PDS_TEMPLATE_NUMBERS': '0 2 2 0 81 0 0 0 1 0 0 0 0 106 0 0 0 0 1 106 2 0 0 0 200', 'GRIB_REF_TIME': '1601337600 sec UTC', 'GRIB_SHORT_NAME': '1-2-DBLL', 'GRIB_UNIT': '[C]', 'GRIB_VALID_TIME': '1601337600 sec UTC'}

However, the outputted GRIB file has:

{'GRIB_COMMENT': 'Potential temperature [C]', 'GRIB_DISCIPLINE': '0(Meteorological)', 'GRIB_ELEMENT': 'POT', 'GRIB_FORECAST_SECONDS': '0 sec', 'GRIB_IDS': 'CENTER=7(US-NCEP) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=0 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2020-09-29T00:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast)', 'GRIB_PDS_PDTN': '0', 'GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES': '0 2 2 0 81 0 0 1 0 106 0 1 106 2 200', 'GRIB_PDS_TEMPLATE_NUMBERS': '0 2 2 0 81 0 0 0 1 0 0 0 0 106 0 0 0 0 1 106 2 0 0 0 200', 'GRIB_REF_TIME': '1601337600 sec UTC', 'GRIB_SHORT_NAME': '1-2-DBLL', 'GRIB_UNIT': '[C]', 'GRIB_VALID_TIME': '1601337600 sec UTC'}

Notice, it was intended to set to "Soil Temperature", but the output GRIB has "Potential Temperature". Do you know of a way to overcome this?









Join main@rasterio.groups.io to automatically receive all group messages.