...
You have already seen in previous exercises how to save plots from macros.
The following code example shows how to set various parameters for the different output formats. Note that in most cases the default values are sufficient.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# # Setting common output options for multiple formats # output_common = ( output_name : "/tmp/myOutputTest", # specify full path output_width : 1000, # set width in pixel output_title : "Map of Z500", # give a title to be used by a viewer output_debug : "ON", # print extra debug information into file output_filelist : "ON", # record the list of output files generated output_filelist_name : "/tmp/filelist.txt" # specify where the list of generated files goes ) ps = ps_output( output_common, output_ps_scale : 0.9, # scale content to 90%, this is useful for some printers output_ps_colour_model : "CMYK" # set colour model to CYMK (used by printers) ) png = png_output( output_common, output_cairo_transparent_background : "ON" # generate PNGs with transparent background ) svg = svg_output( output_common, output_svg_fix_size : "ON", # normally SVGs are scalable - this fixes the size to 'output_width' output_svg_meta : "Metview map of Z500", output_svg_desc : "This file was generated for the Training course" ) kml = kml_output( output_common, kml_description : "This file was generated for the Training course", kml_author : "Stephan Siemen", kml_link : "http://www.ecmwf.int", kml_latitude : 30, # latitude to where Google earth centres the view kml_longitude : 120, # longitude to where Google earth centres the view kml_coastlines : "ON" # normally ) output_drivers = [ps, png, svg, kml] setoutput(output_drivers) data = read("z500.grib") plot(data) |
...
To run the macro in batch mode, you call Metview with the option -b followed by the macro name on the command line (assuming you are running from the same directory as the macro - otherwise you must provide a path to it). For example:
metview -b step8mymacro.mv
The newlines within the conditional branching part of the code are down to personal preference. You could also have formatted the code as follows:
...