Re: Regridding from low to high resolution ?

From: Madeleine Patterson <madeleine.patterson77_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 13 2012 - 14:56:19 MDT

Hi Dennis,

I am trying to implement your regridding script that you suggested a while
ago but am having trouble -could I get some advice? I get an error message
'syntax error before or near testd...possibly expecting a begin or local'.
My script is below.

Thanks,
Madeleine.

************************************************

begin

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"

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

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

pctpft = in1->PCT_PFT

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

undef("regrid_cat")
function regrid_cat(clat[*],clon[*],pctpft[*][*],tlat[*],tlon[*]) ;
categorical grid and target grid

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

************************************************

On Thu, Apr 19, 2012 at 3:21 AM, Dennis Shea <shea@ucar.edu> wrote:

> For categorical data, bilinear interpolation is likely not
> appropriate. Consider vegland_1 at
>
> http://www.ncl.ucar.edu/**Applications/classification.**shtml<http://www.ncl.ucar.edu/Applications/classification.shtml>
>
> If the target grid point is in the middle of 4 points with
> categories 16, 10, 1, 2 then bilinear interpolation would
> yield 29/4 -> 7.25 -> 7. It is highly unlikely that this
> would be the case.
>
> Though slow, I would suggest a 2-step procedure
>
> [1] http://www.ncl.ucar.edu/**Document/Functions/Built-in/**
> grid2triple.shtml<http://www.ncl.ucar.edu/Document/Functions/Built-in/grid2triple.shtml>
>
> to convert the source grid to a triplet.
>
> [2] then
>
> http://www.ncl.ucar.edu/**Document/Functions/Built-in/**triple2grid.shtml<http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml>
>
>
> ===
> untested ...
>
>
> undef("regrid_cat")
> function regrid_cat (clat[*], clon[*], cgrid[*][*] \ ; categorical grid
> ,tlat[*], tlon[*]) ; target grid
>
> begin
> d = grid2triple (clon,clat,cgrid) ; d(3,ld)
> cnew = triple2grid(d(0,:), d(1,:), d(2,:), tlon, tlat, False)
>
> copy_VarAtts(cgrid, cnew) ; contributed.ncl
> cnew!0 = "lat"
> cnew!1 = "lon"
> cnew&lat = tlat
> cnew&lon = tlon
>
> return( cnew )
> end
>
>
>
> On 4/18/12 9:17 AM, Noel Aloysius wrote:
>
>> You can use CDO tools to do this, somthing like
>>
>> cdo remapbil,1x1grid_target.txt infile.nc <http://infile.nc>
>> outfile.nc <http://outfile.nc>
>>
>>
>> where remapbil does bilinear interpolation (and remapbic is for
>> bicubic), 1x1grid_target.txt is the user input file with grid size
>> information.
>>
>> Noel
>>
>>
>> On Wed, Apr 18, 2012 at 11:08 AM, Madeleine Patterson
>> <madeleine.patterson77@gmail.**com <madeleine.patterson77@gmail.com>
>> <mailto:madeleine.patterson77@**gmail.com<madeleine.patterson77@gmail.com>>>
>> wrote:
>>
>> Hi All,
>>
>> I was wondering if there is a low-to-high-resolution function for
>> regridding a global map of a categorical variable?
>>
>> I found all the regridding scripts but they all employ
>> interpolation, whereas I just want to 'pixelate' a 2x2.5 deg map to
>> a 0.5 x 0.5 degree map...
>>
>> Does NCL have a function which will do this?
>>
>> Thanks
>>
>> M
>>
>> ______________________________**_________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>
>>
>>
>>
>> ______________________________**_________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 13 14:56:37 2012

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