Scroll pdf ignore | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Overview
You have seen already how to either visualise your processed data on the display or save it to a file. Most processing you will do with Metview will lead to a visualisation you might want to save, either to publish it on web pages or in reports, or simply to keep records. This session will give you more information on how you can save and customise your visualisations.
...
All graphical output formats are generated through ECMWF's graphics library Magics. This means that all graphical capabilities in Metview depend on what Magics offers. Detailed descriptions of the output formats and their settings can be found in the Magics reference documentation.
The table below gives you a list of all the formats that Magics/Metview support and how you can use them.
Format | parameter | How to visualise | What to use for |
---|---|---|---|
Qt/screen | Metview display window | Interactive usage within Metview | |
PostScript | ps/eps | okular, ghostscript/gv | Printing, publications |
okular, acroread | Web, archiving, printing | ||
PNG | png | web browsers, display, xv | Web, presentations -> animations |
SVG | svg | web browsers, vector graphics editor (e.g. Inkscape) | Web HTML5, for further editing in drawing programs |
KML/KMZ | kml | Google Earth, Google Maps, OpenLayers | Interactive (non-scientific) publications |
The KML output format
KML is a very special output format. It has no notion of output size since it is displayed on the globe. KMZ is the compressed version of the KML files and is written by default. You can write out the uncompressed KML if you want to debug the output.
...
The following piece of code shows the simplest way to save your plot as a PostScript PDF file instead of creating an interactive Display Window.
Code Block | ||
---|---|---|
| ||
# set up the output format ps pdf = pspdf_output( output_name : "my_plot" ) setoutput(pspdf) data = read("z500.grib") plot(data) # the plot will be sent to the PostScriptPDF file |
Try it!
The pspdf_output()
function defines how a PostScript PDF file should be generated. More options are available to further customise it. The setoutput()
function selects this output format. So our code can contain many output format definitions and then select just one (or more) with the setoutput()
function at run-time (see later).
The following code example shows how to set multiple output formats at the same time and also set various parameters for the different output formats. Note that in most cases the default values are sufficient. A list of all options can found in the Magics documentation for each format at: PostScript, SVG, PNG and KML.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
# # Setting common output options for multiple formats # output_common = ( output_name : "/tmp/myOutputTest", # specify relative or full path output_title : "Map of Z500", # title used by a viewer output_debug : "ON", # print extra information output_filelist : "ON", # save list of files generated output_filelist_name : "/tmp/filelist.txt" # where to save the list ) ps = ps_output( output_common, output_ps_scale : 0.9, # scale content to 90%, for some printers output_ps_colour_model : "CMYK" # set colour model to CYMK ) png = png_output( output_common, output_width : 1000, # set width in pixels output_cairo_transparent_background : "ON" # to get transparent PNGs ) svg = svg_output( output_common, output_width : 1000, # set width in pixels output_svg_fix_size : "ON", # 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 where Google Earth centres the view kml_longitude : 120, # longitude where Google Earth centres the view kml_coastlines : "ON" # normally OFF" ) output_drivers = [ps, png, svg, kml] setoutput(output_drivers) data = read("z500.grib") plot(data) |
...
Create a new Macro icon and rename it outputs. Write a small macro to read the file z500.grib and plot it. If the macro is run in batch mode, the plot should be saved as a PDF file somewhere into /tmp; otherwise, plot it to the screena PNG file.
- Run the code in the Macro Editor and see what happens if your execute the macro.
- Go on the command line and change to the directory where the macro is located. Execute the macro from the command line outside Metview.
...
This function is normally used within loops to generate output of each iteration on a separate page (or file). It is the only way to use different views on different pages - this is the main purpose of it.
To use newpage()
you need first to define a plot_superpage()
as shown in the example below.
Code Block | ||||
---|---|---|---|---|
| ||||
... dw = plot_superpage( pages : [plot_page(),plot_page()]] # use default page ) plot(dw[1], ...) newpage(dw) ... plot(dw[2], ...) |
Here we create two a default sized pages page with plot_page()
, which attach attaches to the super page. Than we assign each plot command to a page.
...
Take the macro from the previous task and add a page where you visualise the same field but over Europe only.modify it to produce a 2-page output: the first page should be on a default Geographic View, the second should be over Europe only. Only plot the first field in the data. The result should be 2 PNG files or a 2-page PDF, depending on how you run the macro.
Further processing outside Metview
Of course you can do further processing of plots outside Metview. The page Generating animated GIFs from Metview plots gives you some helpful advice if you want to build animations.
Metview/Magics also supports special tags in SVG for the Inkscape graphical editor. This open source editor is great for when you need to further annotate your maps.
If you have extra time
If you have time, you might want to try out opening your SVG file from the first exercise above in inkscape and alter it and save it to a PNG.
Using Web Map Services (WMS)
Metview provides a module to request maps from a Web Map Services (WMS). The WMS standard is defined by the Open Geospatial Consortium (OGC), which is very popular in the GIS community. The WMS module can be used to query an OGC-compliant WMS server, retrieve maps from it and overlay them with other data. The WMS icon is a great way to integrate web services within Metview.
We have a separate tutorial which shows in more detail how you can use maps served by web map services within Metview.
Tasks
...
.