# Re: linear interpolation

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 23 Sep 2009 12:13:34 -0600

To further what DaveB wrote:

You did not state if the input grid was on hybrid levels or pressure levels.
There are slightly different approaches that may be used.

Generally, the vertical interpolation should be done first:

X(12, 60,180,360) ===> Y(12, 28,180,360)

Then, perform the horizontal interpolation:

Y(12, 28,180,360) ===> Z(12, 28, 64,128)

===========
NCL's Applications page is a good place to start:

==================== VERTICAL INTERPOLATION ===============
Under the "Data Analysis", Click: "Vertical Interpolation"

http://www.ncl.ucar.edu/Applications/vert_interp.shtml

If your input grid is on hybrid levels, Example 3 is closest to what you
want to do.

If the input is on pressure levels, the function "int2p"

or, better, "int2p_Wrap", because it returns meta data

See Example 5

yTemp = *int2p_Wrap*(p_in, x(time|:,lat|:,lon|:,pin|:), pout, linlog)
printVarSummary(yTemp)

YY = yTemp(time|:,iLev|:,LAT|:,LON|:) ; reorder for horizontal
interpolation
delete(yTemp)

use, linint2_Wrap, or f2gsh_Wrap or area_hitolores for the grid
interpolation.

David Brown wrote:
> Hi Lei,
>
> First just a bit of terminology: you are talking about the dimensions
> of the variable not the attributes (which are metadata such as units
> or a descriptive long name for the variable). There are a number of
> functions you could use. Assuming you have coordinate values for the
> input and output lat and lon dimensions, and you are using version
> 5.1.0 of NCL, I would recommend the function area_hi2lores_Wrap.
> However, you could also use linint2_Wrap, or if the output grid is
> Gaussian ("T42") the function
> f2gsh_Wrap might be preferable.
> -dave
>
>
> On Sep 22, 2009, at 1:05 PM, Lei Meng wrote:
>
>
>> Hi,
>> I have a nc file with attributes (Time, Lev, Lat, Lon) (e.g., 12,
>> 60,180,360) and I would like to convert it to a nc file with
>> attributes (Time, iLev,iLat,iLon) (e.g., 12, 28, 64,128) using
>> linear interpolation. Which functions should I use to interpolate
>> the three attributes (ilev, ilat, ilon)? Thanks,
>> Lei
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> 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
>

```--
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
```
Received on Wed Sep 23 2009 - 12:13:34 MDT

This archive was generated by hypermail 2.2.0 : Thu Sep 24 2009 - 13:55:09 MDT