How to loop over all the fields in my fieldset?
Create a loop over the number of fields, and setting the parameter grib_field_position to the position of the field in your fieldset ( starting from 1)
To know the number of fields in your grib files, you can use the function grib_count of the grib_api package.
My field contains data from 0 to 100, but the contouring shows values below and above?
This is an effect of the interpolation, and easy way to get rid of it is to use the 2 following parameters contour_interpolation_floor and contour_interpolation_ceiling,
In this case mcont(contour_interpolation_floor = 0.,contour_interpolation_ceiling=100.). Check the mcont documentation.
How to remove the ECMWF Logo?
If you do not want to see the ECMWF logo on your plot, set the parameter page_id_line to off in the page object.
How can I display some information of the GRIB header in my title?
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.
To get an idea of the available keys on your grib files, you can use the function grib_dump of the grib_api package.
Here is a short list of keys that we find useful, and are used in the generation of the automatioc Magics title
|name||long name of the parameter|
|shortName||short name of the parameter|
|valid-date||valid date ( computed by Magics)|
How can I set the size of my PNG output?
Magics is internally working in cm. All the superpage, page and subpage dimension should be given in cm. When working with png, you can set the parameter output_width to the number of pixel you want. Magics will map this width with super_page_x_length to define a ratio and compute the height in pixel.
In the following example : we set the output_width to 1200, the page is the default A4 landscape. 1200 will match 29.7, the height will be computed to respect the aspect ratio ie, the height will be 848.
How can I set the DPI of my PNG output?
When printing, users are used to setting a DPI (dots per inch) for the quality of their output. Graphics on the web & screen, especially raster graphics, do not have the concept. There is only so much information which can be stored in a pixel. To get a higher quality raster plot you have to scale up the content and possibly increase the (pixel) size of you image (see above question). You can use image manipulation tools to set a DPI when you convert from vector to raster. So you could output your plot into PS or PDF and convert it using Imagemagick (see http://www.imagemagick.org/script/command-line-options.php#density)
For more information on this please read https://www.webdesignerdepot.com/2010/02/the-myth-of-dpi/.
Can I get a plot in in a portrait mode?
To do that, you will have to change the dimension of the super page ( the output) and of the page.
Let's say that you want an A4 in portrait mode. You will have to set super_page_x_length and the page_x_length to 21., and super_page_y_length and the page_y_length to 29.7.
How can I apply a format to a number in Magics?
Several parameters accept a format : for historical reason Magics is using a fortran convention, with bracket around it,
(I3) : Marks the place for an integer variable. It is followed by an integer indicating the number of columns to be reserved in the line for the integer. For example "i10", reserves 10 columns for output of the integer. If the integer contains less that 10 digits in this example, it is right justified in the reserved 10 columns and unused columns simply appear as spaces to the left of the integer.
(F5,2) : Marks the place for the decimal form of a real number. As with "i", it is followed by an integer reserving a number of columns for the number. This integer is followed immediately by a period ("."), acting as a separator rather than true decimal place. The period is immediately followed by another integer giving the number of digits to be printed (or read) to the right of the number's decimal. For example if the computer contains the number 11.23456, then "f10.3" in an output format results in a printed number " 11.234" (four spaces to the left of the number).