Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt
hiddentrue

When defining your text, you can use a special tag grib_info, Magics will then get the information from the grib header and replace the tag by the value read. You can use all the grib api keys, and Magics have a special one called valid-date that will compute the valid date for the data, taking into account the base date and the step

How can I display some information of the GRIB header in my title?

Step-by-step guide

When defining your text, you can use a special tag grib_info, Magics will then get the information from the grib header and replace the tag by the value read. You can use all the grib api keys, and Magics have a special one called valid-date that will compute the valid date for the data, taking into account the base date and the step.

Code Block
collapse
languagepy
titlePython Example : configure the titletrue
from Magics.macro import *
#Setting output
output = output(
    output_formats                = ['ps'],
    output_name                   = 'precip',
    output_name_first_page_number = 'off')
#Setting the coastlines
background = mcoast(
    map_coastline_land_shade        = 'on',
    map_coastline_land_shade_colour = 'cream')
#Setting data
grib = mgrib(grib_input_file_name = "path/data.grib")
#Defining the contour
contour = mcont(
)
#Picking the grib metadata
title = mtext(
    text_lines                     = ["Parameter : <grib_info key='name'/> valid for  <grib_info key='valid-date'/>"],
	)     
#Plotting
plot(output, background, grib, data, title)


 1. To  To get an idea of the available keys on your grib files, you can use the function grib_dump of the grib_api ecCodes package.

 2. Here is a short list of keys that we find useful, and are used in the generation of the automatioc automatic Magics title

     

grib_api keydefinition
centreoriginating centre
namelong name of the parameter
shortNameshort name of the parameter
valid-datevalid date ( computed by Magics)
unitsunits
levellevel

...

Content by Label
showLabelsfalse
max5
spaces~usa
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "kb-how-to-article" magics-faqs" and label in ("keys","grib") and type = "page" and space = "UDOC"
labelskb-how-to-article

...