Re: linint2_Wrap Regriding

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu May 17 2012 - 10:45:32 MDT

Hi Ping,
I think you are on the right track, but you do not need to subset the
input array. (I am guessing that you are getting null values around the
perimeter of your new grid.) When it comes to regridding one needs to make
sure that the input latitudes and longitudes and the output latitudes and
longitudes are in the same range, and flow in the same direction. You
state you want your grid on negative longitudes, which is fine, but that
means your input longitudes need to span the same range as well. So, I
would recommend reading in the input data in its' entirety, flipping the
latitudes, then use lonFlip to convert the longitudes from 0:360 to
-180:180:

pres=in->pres(:,::-1,:) ; ::-1 = flip latitudes
pres = lonFlip(pres)
printVarSummary(pres) ; lats should run from S->N, and lons from -180:180

newlon = fspan(-84.025,-64.875,383)
newlat = fspan(34.875,50.125,305)
newlat@units = "degrees_north"
newlon@units = "degrees_east"
newsst=linint2_Wrap(pres&lon,pres&lat,pres,True,newlon,newlat,0)

That should be it. If that doesn't work or if you have further questions
please respond to ncl-talk.
Best regards,
Adam

> Dear NCL user,
>
> I am doing interpolation from the PSD data(daily T62 Gaussian grid
> (192x94)
> 88.542N - 88.542S, 0E - 358.125E) to a 3 minute*3minute lon/lat regular
> grid, I have encountered an issue with the bilinear interpolation with the
> linint2_Wrap function (Interpolates from a rectilinear grid to another
> rectilinear grid using bilinear interpolation, and retains metadata)with
> NCL, because I've got invalid values(some of of the value are null). I
> used
> this code (I used a NCEP/NCAR reanalysis data, which is available by this
> link
> ftp://ftp.cdc.noaa.gov/Datasets/ncep.reanalysis.dailyavgs/surface_gauss/pres.sfc.gauss.2006.nc)
> :
>
> ;*************************************************
> ; interpolation.ncl
> ;
> ; Concepts illustrated:
> ; - Interpolating from one grid to another using bilinear interpolation
> ; use linint2_Wrap function for the retrieving all the metadata
> ;create a new file to include the interpolated variable
> ;
> ;************************************************
> load "/usr/local/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;change $NCARG_ROOT to /usr/local directly.
> ;************************************************
> begin
> ;open file to write variable to(a new netCDF file)
> out=addfile("pres.sfc.gauss.2006.interpolated.nc","c")
> ;************************************************
> ; read in netCDF file
> ;************************************************
> in = addfile("pres.sfc.gauss.2006.nc","r")
> ;************************************************
> ; read in pres
> ;***********************************************
> ;Use a subscript for change the dimension of pressure and also subset the
> variable
> pres=in->pres(time|:,{lat|34.875:50.125},{lon|95.975:115.125})
> ;so the newPres is with the latitude increasing
> ;***********************************************************
> ;newlon = fspan(-84.025,-64.875,383)
> newlon = fspan(95.975,115.125,383);convert to a (0,360) instead of
> (-180,+180)
> newlat = fspan(34.875,50.125,305)
> newlat@units = "degrees_north"
> newlon@units = "degrees_east"
> ;************************************************
> ; interpolate to new grid use linint2_Wrap function
> ;***********************************************
> newsst=linint2_Wrap(pres&lon,pres&lat,pres,True,newlon,newlat,0)
> ;*************output variable to new file****************
> out->pres=newsst
> end
>
> Actually I need the domain range is from lon(-84.025,-64.875,383),
> lat(34.875,50.125,305) in the lon/lat regular grid, Can I ask you what
> will
> be the correct range in the Gaussian grid lon 95.975:115.125? I tried
> several times, it seems that I am confused by the translation,
>
> Am I use the right function for this interpolation? I will be appreciated
> if you can point out where is the problem ?
>
> Best Regards,
>
> Ping
>
> --
> Ping Yang, Ph.D.
> CUNY Environmental Crossroads Initiative
> Marshak Science Building - Suite 925
> The City College of New York - CUNY
> 160 Convent Avenue, New York NY 10031
> Phone: 212-650-5769
> Fax: 212-650-7064
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

__________________________________________________
Adam Phillips asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division
P.O. Box 3000 (303) 497-1726
Boulder, CO 80307-3000
http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 17 10:45:40 2012

This archive was generated by hypermail 2.1.8 : Thu May 17 2012 - 13:42:02 MDT