[ncl-talk] Using NCL to Regrid NetCDF data for ArcGIS

Matthew Shultz matthew.shultz at yale.edu
Mon Jun 22 19:42:09 MDT 2015


Greetings,
I am very new to netcdf  and need some assistance.  I am trying to
calculate zonal statistics (sums and averages within watershed shapes)
using some tools in ArcGIS for netcdf.  The tools require netcdf files to
be in a regular grid.  My source data is NARR data, which isn't being
recognized as a regular grid (I believe it is curvilinear).  So I am trying
to regrid using templates provided on the ucar website.  Attached is the
code I am currently using.  It gives me the following error.  Despite
search archives of this list, other responses have not resolved my problem.
Help is very much appreciated, clearly there is something I am not
understanding.



fatal:Eq: Dimension size, for dimension number 0, of operands does not
match, can't continue




load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"

;---Data file containing source grid
    src_file = "air.sfc.2009.nc"                    ;;---Change (likely)
    sfile    = addfile(src_file,"r")

;---Get variable to regrid
    varname = "air"                    ;;---Change (likely)
    var     = sfile->air
    src_lat = sfile->lat               ;;---Change (maybe)
    src_lon = sfile->lon               ;;---Change (maybe)

;---Set up regridding options
    Opt                   = True

;---"bilinear" is the default. "patch" and "conserve" are other options.
    Opt at InterpMethod      = "bilinear"        ;;---Change (maybe)

    Opt at WgtFileName       = "curv_to_1deg.nc"

    Opt at SrcGridLat        = src_lat           ; source grid
    Opt at SrcGridLon        = src_lon
    Opt at SrcRegional       = True             ;;--Change (maybe)
    Opt at SrcInputFileName  = src_file          ; optional, but good idea
    Opt at SrcMask2D         = where(.not.ismissing(var),1,0) ; Necessary if
has
                                                           ; missing values.

    Opt at DstGridType       = "0.5x0.5"            ; Destination grid
    ;Opt at DstLLCorner       = (/-89.75d,   0.00d /)   ;;--Change (likely)
    ;Opt at DstURCorner       = (/ 89.75d, 359.75d /)   ;;--Change (likely)
    Opt at DstRegional       = True                 ;;--Change (maybe)

    Opt at ForceOverwrite    = True
    Opt at PrintTimings      = True
    Opt at Debug             = True

    var_regrid = ESMF_regrid(var,Opt)     ; Do the regridding

    printVarSummary(var_regrid)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150622/8106ddb4/attachment.html 


More information about the ncl-talk mailing list