The following exercise demonstrates how to prepare PRECIS data for use with the crop model GLAM. This worksheet focuses on preparing data for Thailand.
| 3.1|| Creating a country mask
| 3.2|| Applying a country mask
Note: In all of the following exercises, it is assumed that the spin up period and the 8-point rim have been removed.
3.1 Creating a country mask
GLAM will be run over Thailand, so we need to use CDO to apply a country mask of Thailand to the PRECIS data.
1. ) Create a regular lat lon mask of Thailand at 0.5x0.5 degree horizontal resolution.
GIS was used to create a high resolution mask of Thailand. GLAM requires data to be on a regular lonlat grid, however, PRECIS data is on a rotated pole curvilinear grid.
% cd $DATA/
% rm thai_mask.nc
% xconv -i thai_mask.orig.nc
% cdo griddes thai_mask.orig.nc | head
What is the horizontal resolution of the mask at the moment?
The netCDF Thailand mask is on a regular lonlat grid already, however, we must regrid it to 0.5x0.5 degree horizontal resolution.
% cdo remapbil,r720x360 thai_mask.orig.nc thai_mask.rg.nc
The mask has been remapped onto a global field, with 720 lon x 360 lat grid boxes - which correspondes to 0.5x0.5 degree resolution. Now extract Thailand from the global field.
% cdo sellonlatbox,96,107,5,22 thai_mask.rg.nc thai_mask.nc
Put the grid description of the new mask into a file, so that it can be used for regridding the PRECIS data.
% cdo griddes thai_mask.nc > $HOME/climatology/glamgrid
% cp thai_mask.nc $HOME/climatology
3.2 Applying a country mask
1. ) Apply a Thailand mask to the PRECIS data to be used in GLAM.
The mask must be applied to precipitation, minimum and maximum temperature and solar radiation data for the baseline period (1991-2000) and future period (2041-2050).
Firstly, apply the mask to minimum and maximum temperature and solar radiation data for HadCM3Q0 model run cahpa. Begin by regridding the PRECIS data onto the same grid as the Thailand mask created in 3.1.
Use a loop to do this, it will take a couple of minutes to complete.
% for sc in "01235" "03236.max" "03236.min"
% cd $DATA/daily/cahpa/$sc
% cdo remapbil,$HOME/climatology/glamgrid cahpaa.pa.1991_2000.$sc.rr8.nc cahpaa.pa.1991_2000.$sc.rm.nc
% cdo mul $HOME/climatology/thai_mask.nc cahpaa.pa.1991_2000.$sc.rm.nc $HOME/climatology/cahpaa.pa.1991_2000.$sc.glam.nc
% cdo remapbil,$HOME/climatology/glamgrid cahpaa.pa.2041_2050.$sc.rr8.nc cahpaa.pa.2041_2050.$sc.rm.nc
% cdo mul $HOME/climatology/thai_mask.nc cahpaa.pa.2041_2050.$sc.rm.nc $HOME/climatology/cahpaa.pa.2041_2050.$sc.glam.nc
% rm cahpaa.pa.???1_20?0.$sc.rm.nc
% cd $DATA/daily/cahpa
Precipitation data was not included in the above loop. This is because there are some aeras of zero precipitation in the PRECIS data. When the mask is applied these areas of zero precipitation are nost masked out correctly.
To work around this, we add a constant of 1 to the data before applying the Thailand mask, we then remove this constant after the mask has been applied.
% cd $DATA/daily/cahpa/05216
% cdo remapbil,$HOME/climatology/glamgrid cahpaa.pa.1991_2000.05216.rr8.nc cahpaa.pa.1991_2000.05216.rm.nc
% cdo addc,1 cahpaa.pa.1991_2000.05216.rm.nc cahpaa.pa.1991_2000.05216.rm1.nc
% cdo mul $HOME/climatology/thai_mask.nc cahpaa.pa.1991_2000.05216.rm1.nc cahpaa.pa.1991_2000.05216.tm1.nc
% cdo subc,1 cahpaa.pa.1991_2000.05216.tm1.nc $HOME/climatology/cahpaa.pa.1991_2000.05216.glam.nc
% cdo remapbil,$HOME/climatology/glamgrid cahpaa.pa.2041_2050.05216.rr8.nc cahpaa.pa.2041_2050.05216.rm.nc
% cdo addc,1 cahpaa.pa.2041_2050.05216.rm.nc cahpaa.pa.2041_2050.05216.rm1.nc
% cdo mul $HOME/climatology/thai_mask.nc cahpaa.pa.2041_2050.05216.rm1.nc cahpaa.pa.2041_2050.05216.tm1.nc
% cdo subc,1 cahpaa.pa.2041_2050.05216.tm1.nc $HOME/climatology/cahpaa.pa.2041_2050.05216.glam.nc
% rm cahpaa.pa.???1_20?0.05216.rm.nc cahpaa.pa.???1_20?0.05216.tm1.nc cahpaa.pa.???1_20?0.05216.rm1.nc
% panoply $HOME/climatology/cahpaa.pa.2041_2050.05216.glam.nc
The data is now ready to be used with GLAM.