Skip to content
Snippets Groups Projects

Grib AMQP Payload

The format and meaning of the AMQP messages that grib_processor.py produces.

Format

This is the code that generates the payload. The payload is then converted into a UTF-8 encoded string and published.

{
    "__payload_gen_time__": format_dt(datetime.now()),
    "path": grib_path,
    "directory": os.path.dirname(grib_path),
    "file_name": os.path.basename(grib_path),
    "server_ip": HOSTNAME,
    "server_type": "realtime",
    "first_lat": f_lat,
    "last_lat": getattr(msg, "latitudeLastGridpoint", None),
    "first_lon": f_lon,
    "last_long": getattr(msg, "longitudeLastGridpoint", None),
    "forecast_hour": int(msg.valueOfForecastTime),
    "run_hour": int(msg.hour) * 100 + int(msg.minute),
    "model_time": format_dt(msg.refDate),
    "start_time": format_dt(msg.refDate),
    "projection": msg.gridDefinitionTemplateNumber.definition,
    "center_id": int(msg.originatingCenter.value),
    "center_desc": msg.originatingCenter.definition,
    "level": msg.level,
    "parameter": msg.shortName,
    "param_long": msg.fullName,
    "param_units": msg.units,
    "grib_number": 2,
    "size": "%d x %d" % (rows, cols),
    "ensemble": getattr(msg, "pertubationNumber", None),
    "model_id": int(gen_proc.value),
    "model": gen_proc.definition,
    "xcd_model": xcd_info[1],
    "xcd_model_id": xcd_info[0],
    "grib_record_number": msg._msgnum,
    "title": str(msg),
}

Meaning

Name Type Meaning
__payload_gen_time__ datetime (str) when the payload was generated.
__injector_script__ str the user@server:path/to/script that generated the payload.
path str fully qualified path to the grib file with this message.
directory str directory of path.
file_name str file name of path.
server_ip str name of server that published the message.
server_type str literal Type of server that published the message, currently just 'realtime'.
first_lat float latitude of the first grid point in the grid message.
first_lon float longitude of the first grid point in the grid message.
last_lat float latitude of the last grid point in the grid message.
last_lon float longitude of the last grid point in the grid message.
forecast_hour int hour of forecast for the grid message.
run_hour int run hour of the grid message.
model_time datetime (str) when the grid message was generated at upstream location.
start_time datetime (str) see model_time
projection str projection of grid message.
center_id int id number for the generating center.
center_desc str name of the generating center.
level str level of the grid message.
parameter str short name of the grid message parameter.
param_long str long name of the grid message paramter.
param_units str units of the grid message parameter.
grib_number int literal grid edition number, e.g. 1 or 2.
size str number of rows in cols in grid message formatted as "{rows} x {cols}".
ensemble int or null ensemble number for the grid message, or null.
model_id int id of the generating process model.
model str name of the generating process model.
xcd_model str name of the xcd grib model.
xcd_model_id str name of the xcd grib model id.
grib_record_number int the index of this grid message in the file.
title str the wgrib2 formatted string for this grid message.