Friday 17 July 2015

WRF3.7 on gaia

Downloaded and installed on gaia: sweeneyc/Code/WRF3.7

module list

Currently Loaded Modulefiles:
  1) gcc/4.9.24.4.1
  2) openmpi/1.8.4
  3) netcdf/2014_10
  4) mpich2/1.5
  5) netcdf-fortran/

export JASPERLIB=/gaia/software/src/grib2/lib
export JASPERINC=/gaia/software/src/grib2/include
export NETCDF=/gaia/software/src/netcdf-fortran-4.4.1/build
export PHDF5=/gaia/software/src/hdf5-1.8.13/build
export NCARG_ROOT=/gaia/software/src/ncl_ncarg-6.2.1

./clean -a

./configure
#35
#1

./compile em_real

This should produce the following in main/*.exe:
wrf.exe -- model executable
real.exe -- real-data initialization
ndown.exe -- off-line, one-way nesting
tc.exe -- TC bogussing, serial only

cd ../WPS

./clean -a

./configure
#1

vim configure.wps
# WRF_DIR                 =       ../WRFV3p7
# NETCDF                  =       /gaia/software/src/netcdf-c/build
# NETCDFF                 =       /gaia/software/src/netcdf-fortran-4.4.1/build
#WRF_INCLUDE         =   ...
                        -I$(NETCDF)/include\
                        -I$(NETCDFF)/include
#WRF_LIB             =   ...
                        -L$(NETCDF)/lib -lnetcdf \
                        -L$(NETCDFF)/lib -lnetcdff -lgomp
# DM_FC               = mpif90 #-f90=gfortran
# DM_CC               = mpicc #-cc=gcc
#Append -lgomp to LDFLAGS

./compile >& log.compile

This should produce:

geogrid.exe -> geogrid/src/geogrid.exe
ungrib.exe -> ungrib/src/ungrib.exe
metgrid.exe -> metgrid/src/metgrid.exe

TEST RUN

In WPS directory, edit namelist.wps:
max_dom = 1,
geog_data_path = '/gaia/software/src/WPS_geog/'

Check domain:
module load ncl_ncarg
export NCARG_ROOT=/gaia/software/src/ncl_ncarg-6.2.1
ncl util/plotgrids_new.ncl

run ./geogrid.exe then make sure that the static file has been created:

geo_em.d01.nc

Download the Tutorial case study data

Link in the AWIP Vtable:
ln -sf ungrib/Variable_Tables/Vtable.AWIP Vtable

Link-in the GRIB data by making use of the script link_grib.csh

./link_grib.csh ../../../DATA/TESTWRF/2000012

Edit namelist.wps, and set the following:

start_date = '2000-01-24_12:00:00',
end_date = '2000-01-25_12:00:00',
interval_seconds = 21600,

Run ungrib to create the intermediate files:

./ungrib.exe >& ungrib_data.log

Run metgrid.exe to interpolate the input data on our model domain:

# module load netcdf-fortran/4.4.1 
./metgrid.exe

Change into WRF directory.
cd ../WRFV3p7/run

Link-in the met_em files created with metgrid.exe
ln -sf ../../WPS/met_em.d01.2000-01* .

namelist.input should already have default settings. Run real.exe. Check that the following two files have been created:
wrfinput_d01
wrfbdy_d01

Run wrf.exe. Check that the following file has been created:
wrfout_d01_2000-01-24_12:00:00


Move output file to Mac, and plot something with Python:

Thursday 16 July 2015

LFR reforecasts using 20CR and ERA-20C


20CR

The latest (recommended) version of the NOAA/CIRES Twentieth Century Global Reanalysis is Version 2c:
http://rda.ucar.edu/datasets/ds131.2/

I registered for an account, and downloaded data using "Data Access" > "Get a Subset"

Land cover and geometric height were downloaded from a different page:
http://rda.ucar.edu/datasets/ds131.1/index.html#sfol-wl-/data/ds131.1?g=2

Recommended data for WRF:

3D: Temp, U, V, HGT, RH
2D: Surface Pressure, MSLP, Skin Temp, 2mT, 2mRH, 10mU, 10mV


If the WRF model is going to be run with the Noah LSM model, then at least 2 levels of Soil Temperature and Soil Moisture are required.

Soil Height is recommended but not required. If Soil Height is supplied, then SOIL Temperatures and TSK can be adjusted to the WRF model terrain height.

Water equivalent snow depth (SNOW) is a nice field to have, but not required.

SEAICE is good to have for a high latitude winter case, but it is not required.

http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Basics/UNGRIB/ungrib_req_fields.htm


----

ERA-20C

ERA-20C is ECMWF's first atmospheric reanalysis of the 20th century, from 1900-2010. It assimilates observations of surface pressure and surface marine winds only.
http://www.ecmwf.int/en/research/climate-reanalysis/era-20c

----

WRF

Latest version for WRF-ARW and WPS is V3.7:
http://www2.mmm.ucar.edu/wrf/users/wrfv3.7/wrf_model.html

----

Run WRF with 20CR

Change into WPD directory and clean up any previous data:
rm geo_em* GRIBFILE.* met_em.* FILE\:* *.log

# module load netcdf/2014_10
Run goegrid.exe.


Link in the AWIP Vtable. I've written one called Vtable.20CRv2c based on Vtable.NARR. Differences:

use SPECHUMD at 2m
PMSL GRIB = 2
ST GRIB = 11
SOILHGT GRIB = 8

ln -sf ungrib/Variable_Tables/Vtable.20CRv2c Vtable

Link-in the GRIB data.
ls
./link_grib.csh ../../../DATA/20CRv2c/

Edit namelist.wps.
start_date = '1910-05-20_06:00:00',
end_date   = '1910-05-21_06:00:00',
...
 e_we              =  67,
 e_sn              =  54,
 geog_data_res     = '10m',
 dx = 50000,
 dy = 50000,
 map_proj = 'lambert',
 ref_lat   =  48.049,
 ref_lon   =  8.07,
 truelat1  =  50.0,
 truelat2  =  46.0,
 stand_lon =  8.0,
...

Run
./ungrib.exe

Run
# module load netcdf-fortran/4.4.1 
./metgrid.exe

Change into WRF directory. Clean up any old data.
cd ../WRFV3p7/run
rm met_em.* wrfinput_* wrfbdy_* namelist.output wrfout_* rsl.*

Link-in the met_em files created with metgrid.exe
ln -sf ../../WPS/met_em.* .

check namelist.input. Run real.exe. Check that the following two files have been created:
wrfinput_d01
wrfbdy_d01

Run wrf.exe. Check that the following file has been created:
wrfout_d01_2000-01-24_12:00:00

xxxx

I should check out my old work files on metstore:

/store/CONOR/BACKUP/Code/WRF/WRF-20CRV2

xxxx

Friday 10 July 2015

Python for WRF

I am using NCL at the moment to generate the images for UCD MCC GFS/WRF forecast:

http://mathsci.ucd.ie/met/mcc-forecast.html

It all works fine... so I want to change it! It would be nice to run the forecast on two domains - a higher resolution over Ireland and the UK. I'd also like to have meteograms for a number of locations, which would show forecasts and (historical) observations.

Can I generate these images using Python? I've had a quick Google around, and a promising place to start seems to be with the UK Met Office SciTools packages:

http://scitools.org.uk/

I've installed it on my mac using conda:

conda install -c scitools iris

Then I had a look at the user guide (http://scitools.org.uk/iris/docs/latest/userguide/index.html) and saw this:


If you are reading this user guide for the first time it is strongly recommended that you read the user guide fully before experimenting with your own data files.

Hmmm. I'm usually too impatient. Let's see how far I get...
- Iris data structures are "cubes", which contain data and metadata
- To load a single file into a list of Iris cubes the iris.load() function is used:

import iris
filename = '/Users/conor/DATA/2015071000/wrfout_d01_2015-07-12_02:00:00'
cubes = iris.load(filename)
print cubes
t2m = cubes[165]
print t2m

Wow! That worked! Loading multiple files, and specific fields, is easy too:

filenames = '/Users/conor/DATA/2015071000/wrfout_d01_2015-07-12*'
t2ms = iris.load(filenames, 'T2')
print t2ms

- The iris.save() function saves one or more cubes to a file.
- Iris is able to save to CF NetCDF (1.5) and GRIB (edition 2).

So, can I plot something?

No. Problem. WRF is not CF-compliant, so it doesn't store data in the format that iris expects. NCL works with WRF because it was specifically coded to handle the WRF format. Possibly useful links if I want to continue with this:

https://groups.google.com/forum/#!topic/scitools-iris/O7IRIhMomWc


I tried using wrfncxnj-0.1_r2183. It did produce a netcdf output file, but when I read that in, I still couldn't plot it in iris.

I did, however, get Scott Hosking's python code (link above) to work, after one change due to a .join error:

timestr = ''.join(times[time])

Now I can plot WRF using Python!


A more comprehensive set of functions are available on this page:

http://www.atmos.washington.edu/~lmadaus/pyscripts.html

I wget-ed these files:

coltbls.py
plot_wrf_maps.py

And ran this:
./plot_wrf_maps.py -e -f ../../../DATA/TESTWRF/wrfout_d01_2000-01-24_12\:00\:00 

This produced lots of plots! Here's one:



This may be a good starting point for MCC plots.