Re: linint2_Wrap Regriding

From: Ping Yang <pyang_at_nyahnyahspammersnyahnyah>
Date: Fri May 18 2012 - 10:02:19 MDT

Dear Adam,

Thank you for the advice. Previously I was thinking to subset before the
interpolation which can save some computation for area that not interested.
It is working now.

One more question, the interpolation function linint2_Wrap seems work
better with some variables like solar radiation but not good for air
temperature and pressure, because I found that when I interpolated the air
temperature and surface pressure, the interpolated result is the same as
the original file just the region has been extracted, I think it is
supposed to be more intervals(which is higher resolution). but for solar
radiation it worked good.

Do you (or some user here) have the same problem?

Looking forward to hearing from you.

Regards,

Ping

On Thu, May 17, 2012 at 12:45 PM, Adam Phillips <asphilli@ucar.edu> wrote:

> 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
>
>

-- 
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
Received on Fri May 18 10:03:03 2012

This archive was generated by hypermail 2.1.8 : Fri May 25 2012 - 08:35:50 MDT