Re: linint2 function dimension errors

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 27 2011 - 14:01:23 MDT

Both WRF and NARR are curvilinear grids. linint2 is for rectilinear grids.

[1] linint2 requires the the xi/yi must be monotonically increasing
     and one-dimensional. Further, must be one dimensional the xo/yo.
     The NARR coordinates are two dimensional. Bottom line ...
     linint2 is not the routine you want to use.

[2] There is no general purpose curvilinear-to-curvilinear grid
     function in NCL [yet]. This is a nontrivial problem. The next
     release of NCL will likely have this capability.

[3] A (possibly slow) work around is:

http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2points.shtml

[4] You must interpolate the WRF to pressure levels before doing
the interpolation. Generically,

    fw = addfile ("some_WRF_file.nc", "r")
    wlat2d = fw->XLAT(0,:,:) ; size = (nlat,nlon)
    wlon2d = fw->XLONG(0,:,:)
    xwrf = fw->X ; (time,nlat,nlon) or
                                             ; (time,lev,nlat,nlon)

    xwrfp = interpolate to pressure levels
    printVarSummary(xwrfp)

    fn = addfile ("some_NARR_file.{nc or grb}", "r")
    nlat2d = fn->??? ; (:,:)
    nlon2d = fn->??? ; (:,:)

    nlat1d = ndtooned(nlat2d)
    nlon1d = ndtooned(nlon2d)

           ; WRF to NARR
    xw2n = rcm2points (wlat2d, wlon2d, xwrfp, nlat1d, nlon1d, 0)

    xNARR = onedtond(xw2n, dimxwp)

Then reshape xwork to

On 07/27/2011 12:27 PM, jonathan meyer wrote:
> Hello all,
>
> I am attempting to regrid wrf output variables (specifically u and v
> wind components on 4 standard upper levels; 850, 700, 500 and 250mb) to
> the NARR grid. When using the linint2 function within NCL, I get, what I
> can tell are conflicting error messages telling me my dimension ordering
> is off. When fixing one error message, another error occurs telling me
> the fix for the first error isn't valid and it needs to go back the way
> it was before.
>
> The following are the two different error messages I get along with the
> variable dimension's the function is seeing for both cases:
>
> FIRST CASE:
>
> Lam_U(n,i,:,:,:) = linint2(Xlon(west_east|:, south_north|:),
> Xlat(west_east|:, south_north|:), U_avg(num_levels|:, west_east|:,
> south_north|:), True, narr_lon_1d, narr_lat_1d, 0)
>
> Lam_V(n,i,:,:,:) = linint2(Xlon(west_east|:, south_north|:),
> Xlat(west_east|:, south_north|:), V_avg(num_levels|:, west_east|:,
> south_north|:), True, narr_lon_1d, narr_lat_1d, 0)
>
>
>
> Variable: Xlon (subsection)
>
> Type: float
>
> Total Size: 144004 bytes
>
> 36001 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes:[west_east | 259] x [south_north | 139]
>
> Coordinates:
>
> Number Of Attributes: 5
>
> stagger :
>
> units :degree_east
>
> description :LONGITUDE, WEST IS NEGATIVE
>
> MemoryOrder :XY
>
> FieldType :104
>
>
>
> Variable: U_avg (subsection)
>
> Type: float
>
> Total Size: 576016 bytes
>
> 144004 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:[num_levels | 4] x [west_east | 259] x [south_north
> | 139]
>
> Coordinates:
>
> Number Of Attributes: 8
>
> _FillValue :-999999
>
> PlotLevelID :250 hPa
>
> coordinates :XLONG XLAT
>
> stagger :
>
> FieldType :104
>
> description :u,v met velocity
>
> units :m/s
>
> average_op_ncl :dim_avg_n over dimension(s): u_v
>
> *fatal:linint2: If xi is not one-dimensional, then its leftmost
> dimensions must be the same as the leftmost dimensions of fi*
>
> *
> *
>
> *--------------------------------------------------------------------------------------------------------------------------------------*
>
> SECOND CASE:
>
>
> Lam_U(n,i,:,:,:) = linint2(Xlon(west_east|:, south_north|:),
> Xlat(west_east|:, south_north|:), U_avg(west_east|:, south_north|:,
> num_levels|:), True, narr_lon_1d, narr_lat_1d, 0)
>
> Lam_V(n,i,:,:,:) = linint2(Xlon(west_east|:, south_north|:),
> Xlat(west_east|:, south_north|:), V_avg(west_east|:, south_north|:,
> num_levels|:), True, narr_lon_1d, narr_lat_1d, 0)
>
> Variable: Xlon (subsection)
>
> Type: float
>
> Total Size: 144004 bytes
>
> 36001 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes:[west_east | 259] x [south_north | 139]
>
> Coordinates:
>
> Number Of Attributes: 5
>
> stagger :
>
> units :degree_east
>
> description :LONGITUDE, WEST IS NEGATIVE
>
> MemoryOrder :XY
>
> FieldType :104
>
> Variable: U_avg (subsection)
>
> Type: float
>
> Total Size: 576016 bytes
>
> 144004 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes:[west_east | 259] x [south_north | 139] x
> [num_levels | 4]
>
> Coordinates:
>
> Number Of Attributes: 8
>
> _FillValue :-999999
>
> PlotLevelID :250 hPa
>
> coordinates :XLONG XLAT
>
> stagger :
>
> FieldType :104
>
> description :u,v met velocity
>
> units :m/s
>
> average_op_ncl :dim_avg_n over dimension(s): u_v
>
> *fatal:linint2: The rightmost dimensions of fi must be nyi x nxi, where
> nyi and nxi are the lengths of yi and xi respectively*
>
>
> I might be looking at this the wrong way but it seems I am going in a
> circle to fix these error messages.
>
> Any input is much appreciated.
>
> Thanks in advance.
> Jon Meyer
>
>
>
> _______________________________________________
> 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 Jul 27 14:01:30 2011

This archive was generated by hypermail 2.1.8 : Fri Jul 29 2011 - 08:44:18 MDT