Forecast plotting

From gfi

Both the forecast plotting script and the website creation script is based on python. The plotting script uses dynlib, the website creating script uses django the same library that also drives plikt.org.

Preparations

Prepare dynlib

To get started, make sure you have followed the procedures to setup dynlib. Use the Guide to use the centrally installed dynlib. If you want to start developing own diagnostics, follow also the Quick start to developing with dynlib.

Obtain the example scripts

Example scripts as well as the actual forecast scripts currently used are available in a tar archive: /Data/gfi/users/csp001/prj/forecast_plotting.tar.bz2. In that archive there are three folders called examples, production and website.

  1. examples contains a thoroughly documented plot script and the necessary settings file that sets up the right paths and file name structure used for the forecasts.
  2. production contains the currently used plot script. The settings file also contains the colormaps developed by Franziska Menzel.
  3. website contains the script and the template file used to create web pages fitting to the plots.

The workflow

  1. Create a folder in which the plots should be created, and set conf.opath in the settings.py.
  2. Create a folder which contains the contents of the folder website. The website will be created in this folder. The website expects an folder plots in that folder, so either create the folder in step 1 as a subfolder of this folder, or symlink the plot folder here.
  3. Follow the examples in example_plot2.py to develop a new plot.
  4. Contain the plot in the structure plot_forecasts.py.
  5. When the forecasts are created, adapt the script render_vaerkart.py to include your new variables/plots in the list starting around line 30.
  6. Create the website and open it in a browser!

Plotconf options

Many properties of the plots can be configured. The following list is a (hopefully complete) list of what is currently available for the dynlib plotting routines. Contact Clemens Spensberger in case you're missing an option. The implementation will be much easier and quicker if you check first such an option is available in the underlying plotting library matplotlib.

Name Line Fill Type Default Description
cb_orientation ✓ string 'vertical' Orientation of the color bar.
cmap ✓ mpl-colormap Color map for the contours.
cmap ✓ mpl-colormap cm.gist_ncar Color map.
coastcolor ✓ ✓ mpl-color black Color of the coastlines.
colors ✓ list of mpl-color black Presribe color of the contours, instead of using color map.
colors ✓ list of mpl-color Prescribe colors directly instead of using color map.
contour_labels ✓ bool False Label the contours within the plot.
contour_labels_fontsize ✓ int/string 12 Font size in point, or a string like 'smaller'.
contour_labels_inline ✓ bool True Remove the contour under the label?
contour_labels_inline_spacing ✓ int 2 Space in pixels around the label where the contour is removed as well.
contour_labels_format ✓ string/list of string '%1.1f' How to format the numbers, or list of strings used as labels.
disable_cb ✓ ✓ bool False Do not plot add a colorbar.
extend ✓ string 'both' Extend the color bar on the upper and lower boundaries? Possible values are: 'neither', 'upper', 'lower' and 'both'.
gridcolor ✓ ✓ mpl-color black Color lat/lon grid lines.
hook ✓ ✓ callable Function to apply to the data before plotting.
linestyles ✓ string Line styles for contours.
linewidths ✓ int/list Line widths for contours.
m ✓ ✓ Basemap worldmap Map projection.
maskcolor ✓ ✓ mpl-color light grey Color of the parts below orography.
mark ✓ ✓ tuple of list Tuple containing list of x-coordinates and y-coordinates to be marked on the map with circles.
oroalpha ✓ ✓ float 0.4 Transparency of the orography isolines, which 0 being entirely translucent.
orocolor ✓ ✓ mpl-color black Color of the orography isolines.
oroscale ✓ ✓ int/list Δ=1000 m Anything matplotlib accepts as a scale.
overlays ✓ ✓ list of overlay List of overlays (being fronts or countours) to plot on top.
plev ✓ ✓ string/int Vertical level of the plot. Used to auto-mask intersections with orography using the ERA-Interim average height of the level.
scale ✓ ✓ list/int/string 'auto' If 'auto', use the configurable autoscaling (see scale*-properties), otherwise anything matplotlib accepts.
scale_exceed_percentiles ✓ ✓ tuple of float (0.02, 0.98) Percentiles giving the minimal displayed data coverage of the colorbar. For the default values, the lowermost and uppermost inverval cuts of maximally 2% of the data values.
scale_intervals ✓ ✓ list of int [1,2,3,5,10] Which intervals are considered to be "round"? By default it is this list for any order of magnitude.
scale_intervals_periodic ✓ ✓ bool True Which intervals are considered to be "round"? If set to False the above list applies only for the given order of magnitude.
scale_target_steps ✓ ✓ int 7 If scale='auto', how many intervals are desired? The actual intervals might be a few more/less, to allow for a "round" interval value.
scale_symmetric_zero ✓ ✓ bool False If scale='auto', force the scale to be symmetric around zero.
save ✓ ✓ string If not None, save plot as the given file name with full path.
show ✓ ✓ bool True Show the plot in a window.
ticks ✓ ✓ list Where to put the ticks on the colorbar.
ticklabels ✓ ✓ list How to label the ticks.
title ✓ ✓ string Title for the plot.
Zdata ✓ ✓ numpy.ndarray 2D geopotential height field, used for masking intersections with orography.