Metview's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

You have seen already how to visualise outputs

Overview

Most processing you will do with Metview will lead to an visualisation you might want to save to either publish on web pages or reports air archive to keep records. This session will give you more information on how you can save and customise your visualisations. 

Output formats

All graphical output formats are generated through ECMWF's graphics library Magics. This means that all graphical capabilities in Metview depends 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 Magics/Metview support and how you can use them.

FormatparameterHow to visualiseWhat to use for
Qt Metview display windowInteractive usage within Metview
PostScriptps/epsokular, ghostscript/gvPrinting, publications
PDFpdfokular, acroreadWeb, archiving
PNGpngweb browsers, display, xvWeb, presentations -> animations
SVGsvgweb browsers, inkscapeWeb HTML5, editing with inkscape
KML/KMZkmlGoogle Earth, Google Maps, OpenLayersInteractive publications

Metadata

When a large amount of plots is generated it is often hard to find later plots with specific contents. What can help is to store additional information with the plots to describe what the content is. This descriptions about the content are called Metadata. Magics/Metview support the saving of such metadata when the format allows this. Especially in text/XML based formats, such as Postscript and SVG, you can use simple UNIX tools like grep to search the files for specific keywords.

How to save your visualisations

Here we quickly recap how you can save your display from the interactive plot window or save them within Macros.

Exporting from the plot window

Whenever you have a plot window open which displays any map or graph, you are able to export the plot into other file formats. You can either select the export button in the menu (looks like a disk)

  , by selecting File > Export  or by using the Ctrl+s keyboard shortcut.

 

You will get a dialogue as shown below

 

Tasks

  1. From an open display window, try to save your plot as a PDF.
  2. Now try to save your plot as a SVG without and with fixed dimensions.
    1. Open both files in Firefox and see how the plots behave when you resize the browser window.
    2. Open one of the SVGs in inkscape and edit the images (for example add some text) and save it as a PDF.

Setting output formats in macro code

You have already seen in previous excesses how to save plots from macros.

Seeting multiple outputs in Metview Macro
output_common = ( 
      output_name            : "/tmp/myOutputTest",
      output_width           : 1000,
      output_title           : "Map of Z500",
      output_debug           : "ON",
      output_filelist        : "ON",
      output_filelist_name   : "/tmp/filelist.txt"
)

ps = ps_output(
      output_common,
      output_ps_scale        : 0.9,
      output_ps_colour_model : "CMYK"
)

png = png_output(
      output_common,
      output_cairo_transparent_background : "ON"
)

svg = svg_output(
      output_common,
      output_svg_fix_size : "ON",
      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,
      kml_longitude   : 120,
      kml_coastlines  : "ON"
)

output_drivers = [ps, png, svg, kml]

setoutput(output_drivers)

data = read("z500.grib")

plot(data)

 

Setting output dependent on runmode

The way to code run mode dependent outcomes is by using the function runmode(). It returns a string with the run mode:

mode = runmode()

So it is enough to check this string and to code accordingly, either using if/else conditions or the case/of condition test. To introduce the new functionality replace the existing unconditional call to

setoutput() by the following lines of code :

Example for runmode
# check run mode
mode = runmode()

# select outcome dependent on run-mode
if(mode = "execute")
 then setoutput(to_pngfile)
else if (mode = "batch")
 then setoutput(to_psfile)
else if (mode = "visualise") 
 then print('Plotting to screen')
else if (mode = "prepare")
 then print('Plotting to screen')
else
 fail("Only execute, batch and visualise allowed")
end if

 

Now, depending on how you call the macro your output will be directed to different media. Choose different options from the icon’s right-click menu to see what happens. Note that you can also simulate these actions from within the Macro editor ( Program | Run Options). The ‘prepare’ run mode is the default one when you run your macro from the Macro editor. The ‘batch’ run mode will be explained in a later paragraph.

If you select an option not covered by the allowed run modes (e.g. Save or Examine), the macro will stop, turn red (failed run) and issue an error message - this behaviour is provided by the fail() function. A related function, stop(), will do the same but allow the macro to exit in the green state (successful run). Note that you may have to see that it has worked! To delete the output files before running the macro in order to

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 step8

The newlines within the conditional branching part of the code are down to personal preference. You could also have formatted the code as follows:

if (mode = "execute") then

setoutput(to_pngfile)

else if (mode = "batch") then

setoutput(to_psfile)

If You Have Extra Time ...

One important piece of functionality that we have omitted is the ability to save our derived data. Add some code to handle the Save run mode by saving the derived data in a file. There are three things you will have to do:

• at the end of the run mode checks, instead of

else fail ( ... )

• we should not fail if the mode is “save”:

else if (mode <> "save")

 then fail ( ... )

• we must again check the run mode, and if it is Save then write the data to a file; otherwise plot the data.

KML as output format

KML is a very special output format. It contains the    it has no notion of output size.

 

Be careful

KML can only be generated if the Cylindrical projections is selected!

 

 

Converting Geopoints to KML

Metview allows

Importing graphical layers through OGC 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 following material describes the use of WMS within Metview.

Extra tasks

 

 

  • No labels