[ncl-talk] wrf_user_intrp3d with rectilinear grid, dimension mismatch

Ryan Connelly rconne01 at gmail.com
Tue Apr 26 15:10:59 MDT 2016


Follow-up: I had my lat and lon arrays switched.  Fixed that.  But the
error still persists.

It seems to be a Catch 22.  Right now, I have

    locSW = wrf_user_ij_to_ll(a,1.,1.,True)     ; SW corner of domain for
lat and lon minima. Func is fortran-based so 1 not 0
    lon_west = locSW(0)
    lat_south = locSW(1)

; Use any variable that spans the entire grid to get maxima of i,j
; which will then be used to get lat, lon of upper right (NE) corner

    grid_size = dimsizes(tc)                    ; z is 0th index, lat 1st,
lon 2nd
    jMax = grid_size(1)
    iMax = grid_size(2)

    locNE = wrf_user_ij_to_ll(a,iMax,jMax,True)     ; NE corner of domain
for lat and lon maxima. Func is fortran-based so max not max-1
    lon_east = locNE(0)
    lat_north = locNE(1)

    n = dimsizes(lat)
    m = dimsizes(lon)

    nlat = n(0)
    mlon = m(1)

    dst_lat = fspan(lat_south,lat_north,nlat)
    dst_lon = fspan(lon_west,lon_east,mlon)

which means that element (2) of fspan has 1 dimension.  Therefore, in the
output, I see:

(0) write_grid_description: source lat dims = (281,353)
(0) write_grid_description: source lon dims = (281,353)
(0) write_grid_description: source grid type is 'curvilinear'
(...)
(0) write_grid_description: destination lat dims = (281)
(0) write_grid_description: destination lon dims = (353)
(0) write_grid_description: destination grid type is 'rectilinear'

which seems like it should not be.  Shouldn't I want(need) the dimensions
of the source and destination grid to match?

So then, in fspan, I switch nlat to src_lat and mlon to src_lon, making
that element two-dimensional instead of one-dimensional:

    dst_lat = fspan(lat_south,lat_north,src_lat)
    dst_lon = fspan(lon_west,lon_east,src_lon)

Yet when I run with that change, I get: fatal:Number of dimensions in
parameter (2) of (fspan) is (2), (1) dimensions were expected

How can NCL simultaneously be expecting a one- and two-dimension array?
I'm very confused here.

Ryan

On Tue, Apr 26, 2016 at 2:16 PM, Ryan Connelly <rconne01 at gmail.com> wrote:

> Hi,
>
> I'm using ESMF_WRF_to_rect.ncl to regrid (
> https://www.ncl.ucar.edu/Applications/Templates/ESMF_WRF_to_rect.ncl).
> Regridding completes fine, but then when i try to interpolate the regridded
> variable to an isobaric plane using wrf_user_intrp3d I get:
>
> fatal:Dimension size mismatch, dimension (1) of left hand side reference
> does not have the same size as the right hand side reference after
> subscripting.
>
> This is a pretty literal error message and one that I've fixed before, but
> this time it has me stumped.  I haven't even declared the variable on the
> left hand side until this particular line (and I've double checked that by
> issuing a printVarSummary and having it throw a variable undefined error)
> so how can the dimension sizes not match if this is a blank new variable?
>
> I then decided to be extra super literal and declare a new array with the
> right dimensions before calling wrf_user_intrp3d, but the error persists:
>
> (...)
> tc_rect = ESMF_regrid(tc,Opt)     ; Do the regridding
>
>
> ; Interpolate to isobaric planes
>
>       pressure = 850.
>
>       newdim = (dimsizes(tc_rect))
>       print(newdim)
>
>       tc_rect_plane =
> new((/newdim(0),newdim(1),newdim(2)/),typeof(tc_rect))
>
>       tc_rect_plane = wrf_user_intrp3d(tc_rect,p,"h",pressure,0.,False)
> (...)
>
> I'm out of ideas here.
>
> Ryan
>
> --
> Ryan Connelly
> M.S. Student in Atmospheric Sciences, Stony Brook University
> B.S. in Meteorology with Minors in Mathematics and GIS, Valparaiso
> University
> rconne01 at gmail.com
> ryan.connelly at stonybrook.edu
>



-- 
Ryan Connelly
M.S. Student in Atmospheric Sciences, Stony Brook University
B.S. in Meteorology with Minors in Mathematics and GIS, Valparaiso
University
rconne01 at gmail.com
ryan.connelly at stonybrook.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160426/424c72a2/attachment.html 


More information about the ncl-talk mailing list