Your browser does not have javaScript enabled. Please enable it, or resize your browsers width so you can view the scriptless navigation bar below and the page's content.
Ferret Scripts 1
Regrid netcdf data and output it to a file
NOTE: This is much faster and easier than
regridding with NCL. Ferret commands and variables are in
green type.
Consider the dimensions of these two files: ncep.jja.nc
and preindctl.jja.nc.
The first is NCEP/NCAR Reanalysis data that has dimensions of 1 time
by 92 latitudes by 192 longitudes. The second is FOAM 1.5 LPJ data with
dimensions of 1 time by 128 latitudes by 128 longitudes.
Say you want to look at the difference between the two models. However,
since they are on different horizontal grids, GrADS and other software
cannot difference them. So you need to regrid the data. You can do this
with a short ferret script that we will call regrid.jnl:
use preindctl.jja.nc
use ncep.jja.nc
let ppt = prate[g=OPREC[d=1]]
let ts = skint[g=OPREC[d=1]]
save /file=ncep.jja.regrid.nc ppt,ts
use preindctl.jja.nc tells
ferret to use preindctl.jja.nc as the first data file.
use ncep.jja.nc tells ferret to use ncep.jja.nc
as the second data file.
let ppt = prate[g=OPREC[d=1]] defines
a new variable called ppt. This variable
is equal to prate from the second data
file placed on the grid of the variable OPREC
from the first data file [g=OPREC[d=1]].
The g tells ferret that the grid is changed,
and the [d=1] denotes the first data file.
The line let ts = skint[g=OPREC[d=1]]
is similar, except we are creating a new variable, ts,
that is skint from the ncep.jja.nc
file placed on the grid of OPREC from the
second data file.
To save these variables to a new file, we invoke the command save
/file=ncep.jja.regrid.nc ppt,ts to output the newly created variables
to a new file called ncep.jja.regrid.nc.
Multiple variables saved to this file are separated by a comma.
This script can be run by running ferret: at the unix prompt, type
ferret. Then type go
regrid.jnl at the ferret prompt. After the script runs, type
quit to exit ferret. You should now have
a data file that has the ncep data on the foam grid.
Helpful hint: you may get a memory error when you run this script.
Try using the SET MEMORY/SIZE=x, where
x is an integer. A value between 40 - 100 often works; if it doesn't,
keep increasing it until it does.
Download the two data files used in this example:
preindctl.jja.nc
ncep.jja.nc
Download the script:
regrid.jnl
Thanks to Donna Lee for help in creating the script. If you have
problems running the script, email Sara
Rauscher.
NCEP Reanalysis data provided by the NOAA-CIRES Climate Diagnostics
Center, Boulder, Colorado, USA, from their Web site at
http://www.cdc.noaa.gov/