Re: linint2_Wrap Regriding

From: Ping Yang <pyang_at_nyahnyahspammersnyahnyah>
Date: Thu May 24 2012 - 11:31:54 MDT

Dear Adam,

I have one more question, how can I extract a time period (e.g. 2001
January to 2010 December) using NCL, I looked at a
function calendar_decode2 which can transfer numeric time to calendar time,
actually what I need to do is a opposite way(from calendar to numeric, so I
can extract the time in the same script that I used for last discussion).

Could you please give me some hints or Is here someone have the same
experience?

Best Regards,

Ping

> On Fri, May 18, 2012 at 1:06 PM, Adam Phillips <asphilli@ucar.edu> wrote:
>
>> Hi Ping,
>> I would think that you want the high resolution T and PSL fields to look
>> like the low-resolution T and PS fields, right? linint2_Wrap is basically a
>> simple linear interpolation routine, fine for many applications. The T and
>> PSL T62 fields are likely relatively smooth, while I am guessing the T62
>> solar radiation field is not. The resulting interpolated high resolution
>> output will thus likely have smoother T and PSL fields, and noisier solar
>> radiation fields.
>>
>> Speaking to a regridding expert here, there are other interpolation
>> methods that you can use, such as bi-cubic sphere interpolation. However,
>> if you start out with a relatively smoothed field as your T62 PSL/T fields
>> are, it's not going to matter whether you use a linear interpolation or a
>> bi-cubic sphere interpolation routine, the results will look quite similar.
>>
>> Hope that helps.. Adam
>>
>>
>> On 05/18/2012 10:02 AM, Ping Yang wrote:
>>
>> 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 <%28303%29%20497-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
>>
>>
>> --
>> ______________________________________________________________
>> Adam Phillips asphilli@ucar.edu
>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>> P.O. Box 3000
>> 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
>>
>>
>
>
> --
> 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
>
> --
> 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 Thu May 24 11:32:13 2012

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