Re: Regridding from low to high resolution ?

From: Madeleine Patterson <madeleine.patterson77_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 14 2012 - 14:46:48 MDT

Hi Mary,

Sorry about the cluenessness about ncl-talk etiquette!

I have set up the function declaration at the start of the code, before the
main script, but am unsure of what I need to do to implement the function
and where, in the main body of the script (i.e. after I've open files and
read variables into variable names, etc.)

In your example below, I would -after opening files and reading in
variables -define clon, clat, tlon and tlat, but what do I do then? use the
regrid_cat function that I've already defined (and if so, how?), as well as
the 'testd=grid2triple()...' and 'pctpftnew=triple2grid()...' commands?

In grid2triple command, 'z' should be 2-d, but in my case it is 3-d (10
pfts, 91 lats, 144 lons)

Is there an example script you could point me to that creates a function
and implements it later in the script?

Thanks,
M

******
You are missing a "begin" after the "function" declaration.

In general, I would recommend not putting a function declaration right in
the middle of your main program. It's cleaner to do it like this:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

undef("regrid_cat")
function regrid_cat(clat[*],clon[*],pctpft[*][*],tlat[*],tlon[*]) ;
categorical grid and target grid
begin
testd=grid2triple(clon,clat,pctpft) ; testd(3,ld)
pctpftnew = triple2grid(testd(0,:),testd(1,:),testd(2,:),tlon,tlat,False)

copy_VarAtts(pctpft,pctpftnew) ;contributed.ncl
cnew!0 = "lat"
cnew!1 = "lon"
cnew&lat =tlat
cnew&lon =tlon

return(pctpftnew)
end

begin

setfileoption("nc","SuppressClose",False)

in1 = addfile("pft_file1.nc","r")

pctpft = in1->PCT_PFT

clat=90
clon=144
tlat=360
tlon=720
. . .

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 14 14:46:59 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 15 2012 - 14:51:31 MDT