Worksheet 2a: Introduction to using CDO for analysis and NCL for visualisation


In this worksheet PRECIS output over south east Asia driven by HadCM3Q0 and ECHAM5 is compared with observations for validation purposes. Validation of model results by comparison with observed data is essential. It is the measure by which we can assess the quality of the model and it informs appropriate uses of the data.

Here, we use PRECIS output driven by two different GCMs. Using data from both experiments will give us two representations of present day climate and two possible climate scenarios. For more details on multimodel approaches see the PRECIS workshop lecture on climate model ensembles.

The following are examples of types of analyses undertaken as part of a model validation. The methods shown are not necessarily the only way to proceed and are intended to demonstrate the use of CDO tools in model validation, and provide a starting point for your own analyses. For further help on validating your PRECIS simulations, refer to the PRECIS workshop lecture notes.

The first worksheet uses Panoply to visualise the data, whilst this is a useful tool to look quickly at results, it is not suitable for use in reports and papers. NCL visualisation software can produce high quality plots, this will be introduced in this worksheet.



Contents


2.1 Introduction to CDO
2.2 Climatological mean calculation
2.3 Mean annual cycle calculation
2.4 Comparing models and observations
2.5 Climatological mean and annual cycle for an ensemble
2.6 Introduction to NCL for visualisation


Note: The data used here has been processed in the same way as Worksheet 1. The 8 point-rim has been removed and it has been converted from PP to netCDF format.





2.1 Introduction to CDO


CDO stands for Climate Data Operators, it is a free open source tool set and like PP tools it is used at the Linux command line. For further details and documentation see https://code.zmaw.de/projects/cdo/wiki.

The datasets used here are daily and monthly data from two PRECIS runs carried out over south east Asia, one driven by HadCM3Q0 and the other driven by ECHAM5. The observations used for comparison are APHRODITE and CRU.

1. ) Find out more information about the monthly precipitation file 1961-1990 of experiment cahpa.

infov writes information about the structure and content of the netCDF file to screen.
% DATA=[data_for_your_computer]/bangkok # change this for your computer
% cd $DATA/monthly
% ls

The runid of the HadCM3Q0 driven run is cahpa and the runid of the ECHAM5 driven run is cahpb.

% cd cahpa/05216
% cdo infov cahpaa.pm.6190.05216.rr8.nc


2.2 Climatological mean calculation

1 a. ) Calculate the 1960-1990 seasonal mean precipitation field for June-September (JJAS) from both the HadCM3Q0 (cahpa) and ECHAM5 (cahpb) driven PRECIS runs.

timmean calculates the mean over all timesteps in a file. We have combined timmean with selmon and selyear to be selective about the time period (e.g. selecting only JJAS - months 6, 7 ,8 and 9.)
Firstly for cahpa

Note: sometimes commands are too long to fit on one line, if a line does not start with %, the command is continued on the next line and you should not press enter until it is complete.

% cd $DATA/monthly
% mkdir $HOME/climatology # creates a new directory called climatology
% cdo timmean -selmon,6/9 -selyear,1961/1990 cahpa/05216/cahpaa.pm.6190.05216.rr8.nc $HOME/climatology/cahpaa.JJAS.mean.baseline.05216.nc
% panoply $HOME/climatology/cahpaa.JJAS.mean.baseline.05216.nc

Secondly for cahpb

% cdo timmean -selmon,6/9 -selyear,1961/1990 cahpb/05216/cahpba.pm.6190.05216.rr8.nc $HOME/climatology/cahpba.JJAS.mean.baseline.05216.nc

1 b. ) Convert the JJAS mean fields for both runs from kg/m2/s to mm/day (multiply by 86400.)

mulc multiplies the field by a constant. Similar operators exist for division, subtraction and addition.
% cdo mulc,86400 $HOME/climatology/cahpaa.JJAS.mean.baseline.05216.nc $HOME/climatology/cahpaa.JJAS.mean.baseline.05216.mmday.nc
% cdo mulc,86400 $HOME/climatology/cahpba.JJAS.mean.baseline.05216.nc $HOME/climatology/cahpba.JJAS.mean.baseline.05216.mmday.nc

2. ) Calculate the 1961-1990 seasonal mean for JJAS from the APHRODITE observation data.

% cd $DATA/monthly/APHRODITE
% cdo timmean -selmon,6/9 -selyear,1961/1990 aphro.mon.6190.nc $HOME/climatology/aphro.JJAS.mean.baseline.05216.nc
% panoply $HOME/climatology/aphro.JJAS.mean.baseline.05216.nc

Note: APHRODITE is a daily high resolution (0.25 degree) rain gauge based precipitation data set over Asia 1950-2007. See http://www.chikyu.ac.jp/precip/ for more information.

2.3 Mean annual cycle calculation

1 a. ) Extract the area around Bangkok from the monthly PRECIS precipitation data for both the HadCM3Q0 and ECHAM5 driven runs by specifying lon and lat co-ordinates.

sellonlatbox allows you to extract an area from fields by choosing lon1,lon2,lat1,lat2.
% cd $DATA/monthly/cahpa/05216
% cdo sellonlatbox,100.3,100.7,13.5,13.8 cahpaa.pm.6190.05216.rr8.nc cahpaa.pm.6190.05216.rr8.ext.nc

% cd $DATA/monthly/cahpb/05216
% cdo sellonlatbox,100.3,100.7,13.5,13.8 cahpba.pm.6190.05216.rr8.nc cahpba.pm.6190.05216.rr8.ext.nc

1 b. ) Calculate monthly mean fields for 1961-1990 for each of the twelve months for the Bangkok area.

ymonmean computes the mean of all the time steps of multiple years in each month.
% cd - # returns you to the directory you were previously in
% cdo ymonmean -selyear,1961/1990 cahpaa.pm.6190.05216.rr8.ext.nc $HOME/climatology/cahpaa.monmean.baseline.05216.rr8.ext.nc
% cd $DATA/monthly/cahpb/05216
% cdo ymonmean -selyear,1961/1990 cahpba.pm.6190.05216.rr8.ext.nc $HOME/climatology/cahpba.monmean.baseline.05216.rr8.ext.nc

Convert the monthly mean fields to mm/day

% cd $HOME/climatology
% cdo mulc,86400 cahpaa.monmean.baseline.05216.rr8.ext.nc cahpaa.monmean.baseline.05216.rr8.ext.mmday.nc
% cdo mulc,86400 cahpba.monmean.baseline.05216.rr8.ext.nc cahpba.monmean.baseline.05216.rr8.ext.mmday.nc
% cdo infov cahpba.monmean.baseline.05216.rr8.ext.mmday.nc

2. ) Now find monthly means 1961-1990 for observations.

% cd $DATA/monthly/APHRODITE
% cdo sellonlatbox,100.3,100.7,13.5,13.8 -selyear,1961/1990 aphro.mon.6190.nc aphro.mon.6190.ext.nc
% cdo ymonmean aphro.mon.6190.ext.nc $HOME/climatology/aphro.monmean.baseline.05216.ext.nc


2.4 Comparing models and observations


To fairly compare spatial model and observation fields they must firstly be on the same grid. We will regrid to the coarsest grid and then subtract the model field from the observations. In this case, the observations have the coarsest resolution so we will regrid the model data onto the observation grid.

1 . ) Regrid the multiannual JJAS mean model fields onto the observations grid.

griddes a command which prints a description of the input field(s) grid.
remapbil this operator remaps all input fields to a new horizontal grid using bilinear interpolation.
% cd $HOME/climatology
% cdo griddes aphro.JJAS.mean.baseline.05216.nc > mygrid
% cdo remapbil,mygrid cahpaa.JJAS.mean.baseline.05216.mmday.nc cahpaa.JJAS.mean.baseline.05216.mmday.rg.nc
% cdo remapbil,mygrid cahpba.JJAS.mean.baseline.05216.mmday.nc cahpba.JJAS.mean.baseline.05216.mmday.rg.nc

% panoply cahpaa.JJAS.mean.baseline.05216.mmday.rg.nc

Note: mygrid is used as the target grid for remapping.

2 a. ) Find the difference between the model and observation JJAS multiannual mean fields.

sub this operator subtracts one field from another, similar operators exist for addition, multiplication and division.
% cdo sub cahpaa.JJAS.mean.baseline.05216.mmday.rg.nc aphro.JJAS.mean.baseline.05216.nc diff.cahpa_aphro.JJAS.baseline.nc
% cdo sub cahpba.JJAS.mean.baseline.05216.mmday.rg.nc aphro.JJAS.mean.baseline.05216.nc diff.cahpb_aphro.JJAS.baseline.nc

2 b. ) Extract the RCM domain from the difference fields (this improves plotting.)

% cdo sellonlatbox,90,137,-14,31 diff.cahpa_aphro.JJAS.baseline.nc diff.cahpa_aphro.JJAS.baseline.ext.nc
% cdo sellonlatbox,90,137,-14,31 diff.cahpb_aphro.JJAS.baseline.nc diff.cahpb_aphro.JJAS.baseline.ext.nc
% panoply diff.cahpb_aphro.JJAS.baseline.ext.nc

2.5 Climatological mean and annual cycle for an ensemble

So far data from two models downscaled with PRECIS have been used. In this section an ensemble of six models is used, five from the HadCMQ QUMP ensemble (discussed in the model ensemble lecture) and one ECHAM5 model. The five members of the QUMP ensemble are HadCM3Q0 (cahpa), HadCM3Q3 (cahpc), HadCM3Q10 (cahpd), HadCM3Q11 (cahpe) and HadCM3Q13 (cahpf).

Taking an ensemble approach allows us to account for a range of uncertainty in the model projections. Typing the CDO commands into the command line for all six ensebmle members would be very time consuming, so we use a script intead.

1 . ) Calculate the JJAS seasonal mean and annual cycle (for the Bangkok area) for 1.5m temperature for all six ensemble members and CRU observations. Also find the difference between model runs and observations.

The script worksheet2.sh contains all the CDO commands needed to calculate the JJAS mean, annual cycle and difference between models and observations for cahpa, cahpb, cahpc, cahpd, cahpe, and cahpf.

The top of the script needs to be edited to correct the location of DATA before running.

% cd $DATA
% emacs worksheet2.sh &;
% ./worksheet2.sh

Note: CRU is a monthly global land only data set (1901-2002) at 0.5 degree resolution. Nine variables are available, including mean,min and max temperature and precipitation. For further details see http://www.cru.uea.ac.uk/~timm/grid/CRU_TS_2_1.html.

2 . ) Calculate the JJAS seasonal mean and annual cycle (for the Bangkok area) for precipitation for all six ensemble members and APHRODITE observations. Also find the difference between model runs and observations.

Use the same script (worksheet2.sh) but change stash from 03236 to 05216 to change the script from calculating temperature to precipitation.

% emacs worksheet2.sh &
% ./worksheet2.sh

2.6 Introduction to NCL for visualisation


NCL is a powerful visualisation tool. It is easy to learn and can be scripted. Many examples of scripts and plots are available from http://www.ncl.ucar.edu/

1. ) Set up your NCL enviroment.


To check if NCL is working simply type ncl on the command line.You should see something like:

Copyright (C) 1995-2011 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.0.0
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
ncl 0>


Now type exit

2. ) Run an NCL script to plot the annual cycle of precipitation and temperature for the model and observations.


The script annualcycle.ncl uses the fields generated in section 2.5 to plot the annual cycle of precipitation and temperature. It reads in the NetCDF fields and finds the area mean for each month before plotting. It outputs a .png plot called annualcycle.png. Open the script for editing.

% cd $DATA/ncl_scripts
% emacs annualcycle.ncl & # you can use which ever text editor you prefer

Before running this script two changes need to be made. At the top of the script, change data_dir to be the location of the climatology directory which contains the data to be plotted. Also change plot_location to the location of the climatology directory.

% ncl annualcycle.ncl
% display annualcycle.png


How does the annual cycle of the six ensemble members compare to observations and each other, what are the differences?




3. ) Run an NCL script to plot mean JJAS precipitation fields for both PRECIS experiments and APHRODITE observations.


The script precip_JJAS_mean.ncl uses the fields generated in section 2.2 to plot JJAS mean precip fields. It outputs a .png plot called precip_JJAS_mean.png, open the script for editing.

% emacs precip_JJAS_mean.ncl & # you can use which ever text editor you prefer

Before running this script two changes need to be made. At the top of the script, change data_dir to be the location of the climatology directory which contains the data to be plotted. Also change plot_location to the location of the climatology directory.

% ncl precip_JJAS_mean.ncl
% display precip_JJAS_mean.png


How do the two PRECIS runs compare to each other and observations?




4. ) Run an NCL script to plot JJAS model minus observation fields for all six ensemble members. Do this for both precipitation and temperature


The script JJAS_diff.ncl uses the fields generated in section 2.5 to plot two difference fields. It outputs a .png plot called JJAS_diff.png, open the script for editing.

% emacs JJAS_diff.ncl &; # you can use which ever text editor you prefer

Before running this script two changes need to be made. At the top of the script, change data_dir to be the location of the climatology directory which contains the data to be plotted. Also change plot_location to the location of the climatology directory.

% ncl JJAS_diff.ncl
% display JJAS_diff.png


How do the six ensemble members compare to observations, where are the biggest temperature/precipitation differences?