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

Rick Brownrigg brownrig at ucar.edu
Tue Jun 23 21:23:25 MDT 2015


Do a:

printVarSummary(var)

and you'll know for sure.  My guess is that, yes while "var" is a scalar
field, as represented in a NetCDF file, it is defined at discrete points in
time *and* space, and so is likely 3D?

I'm not expert at the regridding component -- but I think in your call to
EMSF_regrid, it might look like this:

   EMSF_regrid(var(0,:,:), Opts)

which would regrid over all of the spatial domain for the first time step.

Hope that helps, but punchline:  print() or printVarSummary() is your
friend!  ;-)

Rick

On Tue, Jun 23, 2015 at 4:39 PM, Matthew Shultz <matthew.shultz at yale.edu>
wrote:

> That sounds like it could be right, but I guess I don’t understand NetCDF
> that well.  This file contains a year of daily data on air quality, which
> is a scalar stored in var.  So the value of ‘var’ is 1D for each daily
> time-step, but obviously air + time is 2D.  In order to get this to regrid
> correctly, is there a way I need to express that in my ncl code?
>
>
>
>
> On Jun 23, 2015, at 6:16 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:
>
> Hi Matthew,
>
> I don't know for certain, but tracking down where the error messages are
> coming from, it looks like perhaps your variable "var" is not of the same
> dimensions as lat/lon (which are clearly 2D).   Is there a time or level
> dimension perhaps associated with var?
>
> Rick
>
>
> On Tue, Jun 23, 2015 at 3:31 PM, Matthew Shultz <matthew.shultz at yale.edu>
> wrote:
>
>> Here’s the output I get when I run the command.  Line 40 in my file is
>> just the call to  ESMF_regrid
>> Thanks for you assistance
>>
>>
>> (0) get_src_grid_info: source lat dims = (277,349)
>> (0) get_src_grid_info: source lon dims = (277,349)
>> (0) get_src_grid_info: source grid type is 'curvilinear'
>> fatal:Eq: Dimension size, for dimension number 0, of operands does not
>> match, can't continue
>>
>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 1614 in
>> file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>>
>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 3853 in
>> file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>>
>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 3983 in
>> file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>>
>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 40 in
>> file regrid3.ncl
>>
>>
>>
>>
>> On Jun 23, 2015, at 1:22 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:
>>
>> What line number does the error message refer to?
>>
>>
>>
>> On Mon, Jun 22, 2015 at 7:42 PM, Matthew Shultz <matthew.shultz at yale.edu>
>> wrote:
>>
>>> 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
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__air.sfc.2009.nc&d=AwMFaQ&c=-dg2m7zWuuDZ0MUcV7Sdqw&r=uKbh2SXDxGKvLk5QzayNO82syruaWpicjIReiqrlroo&m=in-kyqdBB_SrcaUe8NduEiwvdug6jD8--IAlddvlGUM&s=ig9Wc1p8W1YxsWqkiFqci37YiabzbIhxeiyjz-uUzo0&e=>"
>>>                    ;;---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
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__curv-5Fto-5F1deg.nc&d=AwMFaQ&c=-dg2m7zWuuDZ0MUcV7Sdqw&r=uKbh2SXDxGKvLk5QzayNO82syruaWpicjIReiqrlroo&m=in-kyqdBB_SrcaUe8NduEiwvdug6jD8--IAlddvlGUM&s=oV6qP_NZtJZUXIOpck3rcmPKZHuyxgh9R9EnWJKtr2Y&e=>
>>> "
>>>
>>>     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)
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=AwMFaQ&c=-dg2m7zWuuDZ0MUcV7Sdqw&r=uKbh2SXDxGKvLk5QzayNO82syruaWpicjIReiqrlroo&m=in-kyqdBB_SrcaUe8NduEiwvdug6jD8--IAlddvlGUM&s=DBUC6JC9tObdztE4E4BXvNWNjeDLWWz5Tt8hQQUWF30&e=>
>>>
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150623/9a539f1a/attachment.html 


More information about the ncl-talk mailing list