Modelling clouds and climate

Plotting

Path: Single Column Model > Plotting
Site Map

MOC2 Links:
MOC2 Home
Projects
Publications
Personnel
SCM
Internal documents



Web Contact: Phil Austin
Site created with Cheetah.

Last updated: Mar 13 2003


UBC SCM uses NetCDF as a format for its data output. The plotting is done using the NCAR Command Language (NCL), designed specifically for the access, analysis, and visualization of data. It uses a publicly-available software packages that can very easily read NetCDF files.


Plots Generated During the Run

If the plotting option in the scm run in turned on, a web page sample_plots.html will be created right after the run. The page will contain some selected plots at the start and at the end of the run's time steps located in plots directory.
The model runs scmplot_html.py and scmplot_html_convert.py scripts run exactly the same as scmplot.py (described below) and use some of it's modules, with an addition that a web page is generated at the end.
If this script is run on its own, it will not work because it uses some model run environmental variables to figure out what time steps to plot.
http://www.eos.ubc.ca/research/scm/sample_plots.html is an example of such a page.
See the guide for more information on how to have the plotting parameters in scm_job turned on or off.



Generating Plots After the Run

The code used, to generate plots for ubcscm is in the ubcscm model directory.
The main scipt is scmplot.py wich uses a nclpy library (a python wrapper for ncl) so all the ncl interface is hiden from the user. Other scripts involved are scmplot.py, pyncl.py, NCLPlot.py contours.py, plots.py and utilities.py.
Here is how to set up scmplot:

The Paths

The first thing to set is the inputpath where the model NetCDF output files can be found, and outputpath where the generated plots will be recorded to. The defaults are set to be the current directory.
Once a run has been made, the user can specify run's output directory as inputpath and run the plotting manually. Output Files Section of the UBCSCM guide specifies where the run's output files can be found.

Plot Info List

scmplot.py has a list plotinfo that has information for running different plots. The list takes the following vaules. First item in the list is filename. It is a NetCDF file with the ".nc" extension whose data will be used for plotting. The next item is outputfilename. This is what ncl will save it's output as. Then, it is the list of times in case timeplot is used. It specifies what time step of a variable to plot. It can contain multiple times and for each one a seperate plot will be drawn. If timeplot is not used, this value will be ingnored. Further, the kind of a plot (timeplot - plots data values against their pressure levels for a specific time step, dataplot - plots data value vs time, valueplot - makes a contour plot). Finally the wokrstation(skip, X11, eps, ps, ncgm, jpg, png, tif, pgf), which will either skip the plot, output it on the screen or save it in a given data format.

The script will look into the list and it will make plots starting from the top of the list. If all workstations are set to 'skip', it will skip all the items in the list.

Executing scmplot.py

To generate plots, set the path and edit the list in the scmplot.py file and then type:
> python scmplot.py
scmplot.py can be run individually in any directory as long as the input and output paths are set and are valid.



Example of UBC SCM runs

http://www.eos.ubc.ca/research/moc2/report_index.html gives a short report on the outcome of the ubcscm runs for different data input cases with plots generated using scmplot.py.



Converting to Other Formats

If the plotting workstation is set to ps, eps, or ncgm, ncl will output the plots into files with these formats.
These are the programs that can view these files:

 > ghostview thts.out.0.ps
 > ghostview thts.out.0.eps
 > idt thts.out.0.eps.ncgm
 
To convert ps and eps files into jpg and pdf, use the following scripts:
 > convert thts.out.0.ps thts.out.0.ps.jpg
 > ps2pdf thts.out.0.ps thts.out.0.ps.pdf
 
Here are some extra tips when using these conversions:
 convert multiple files: > for i in *.eps; do convert -append ${i} ${i}.jpg; done
 make a small image:     > convert -geometry 15% thts.out.0.eps thts.out.0.eps.jpg
 append multiple pages:  > convert -append thts.out.0.eps thts.out.0.eps.jpg
 
To view jpg or pdf files:
 > xv thts.out.0.eps.jpg
 > acroread thts.out.0.eps.pdf
 


Reading NetCDF files using NCL

If a NetCDF file contains, say, two variables data and levels, ncl script can easily read this:

 afile = addfile(filename,"r")
 data = afile->data
 levels = afile->levels
 

It can also very easily read the NetCDF global and variable attributes:

 varname = afile->data@name
 descrip = afile@description