[ncl-talk] error ESMF_regrid

Mary Haley haley at ucar.edu
Mon May 15 23:57:46 MDT 2017


Vanúcia,

I was able to download your files and run your script. Thanks for providing
these.

There was main issue with your script: You are subsetting the source lat /
lon grid with:

 latSrc   = g->XLAT(::6,::6)
 lonSrc   = g->XLONG(::6,::6)

but you are not subsetting the source variable in the same way.

In order to correctly regrid a data array, you must provide the lat/lon
point for every element of your data array. To fix this, you either need to
NOT subset the latSrc/lonSrc grids, or you need to subset varSrc0 with
(::6,::6) as well. I chose the first option.

Once I made this change, the regridding seemed to work fine.

I created a panel plot so you could compare the plots from the first time.
I don't know the correct projection of your source data, so I just plotted
the data in a basic lat/lon plot.  The shape looks funny, but the
contouring is correct.

See the attached modified version of your script and the graphic. I also
included a version of the script that creates an animation.

--Mary




On Mon, May 15, 2017 at 9:42 PM, Mary Haley <haley at ucar.edu> wrote:

> ​Hi Vanúcia,
>
>> Just an FYI about what's going on here:
>
> With the destination grid, if you provide one-dimensional arrays for lat
> and lon that are both the same length (let's called the length DLEN), the
> regridding code has no idea if your intention is to regrid the data to a
> rectilinear grid that is DLEN x DLEN, or to an unstructured set of random
> points of length DLEN.  This is why you
> ​ are​
> get the warning:
>
>  get_dst_grid_info: Error: the lat/lon arrays are both 1D and the same
> length.
>    This could be a rectilinear or unstructured grid. Please set 'grid_type'
>
>
> Since you
> ​said you wanted
>  to regrid to a 1 degree grid, you did the right thing by setting:
>
> Opt at DstGridType = "rectilinear"
>
>
> ​I should point out, however, that if you want to regrid to a 1 degree
> grid, you could have also just set:
>
> Opt at DstGridType = "1deg"
>
>
> and then you don't need to set:
>
> Opt at DstGridLat     = latDst
> Opt at DstGridLon     = lonDst
>
>
> ​How​ever, setting DstGridLat and DstGridLon yourself should be okay.
>
> I'm not sure what you mean by "the out_file It's a mess, with the
> curvilinear grid."
> ​  I am downloading the files you provided and will take a look.
>
> --Mary
>
>
> On Mon, May 15, 2017 at 7:35 PM, Vanúcia Schumacher <
> vanucia-schumacher at hotmail.com> wrote:
>
>> Hi
>>
>>
>> I sent via ftp site the complete script, and
>>
>> the 2_file and 3_file used. Sorry, but I can't to reduze the size of the
>> 1_file (shf_asr-2000-classic.nc) to send via ftp, but I attached in this
>> e-mail (https://1drv.ms/f/s!AhH-sSGcLfkLj0WsaPkz5a_nbuo4)
>> [image: imageData708542]
>> <https://1drv.ms/f/s!AhH-sSGcLfkLj0WsaPkz5a_nbuo4>
>> help <https://1drv.ms/f/s!AhH-sSGcLfkLj0WsaPkz5a_nbuo4>
>> Compartilhado via OneDrive
>>
>>
>> I include the line Opt at DstGridType = "rectilinear" and  the script
>> works, but the out_file It's a mess, with the curvilinear grid.
>>
>> I would like to regress the file_1 (shf_asr-2000-classic.nc) to
>> resolution of 1ºx1º with the grid rectilinear. I can not do this correctly.
>>
>>
>> The names of the files:
>>
>>
>> file_1 used: shf_asr-2000-classic.nc
>>
>>
>> file_2: asr15km.static.2d.2007070100.nc
>>
>> file_3: shf_era-1x1.nc
>>
>>
>> Thanks
>> ------------------------------
>> *De:* Kevin Hallock <hallock at ucar.edu>
>> *Enviado:* segunda-feira, 15 de maio de 2017 21:53:51
>> *Para:* Vanúcia Schumacher
>> *Cc:* ncl-talk at ucar.edu
>> *Assunto:* Re: [ncl-talk] error ESMF_regrid
>>
>> Hi,
>>
>> Could you please provide the complete script you are trying to run?
>>
>> Thanks,
>> Kevin
>>
>> On May 15, 2017, at 10:57 AM, Vanúcia Schumacher <
>> vanucia-schumacher at hotmail.com> wrote:
>>
>> Hi NCL users,
>>
>> I am trying to interpolate a data to a resolution of 1x1, but it is
>> returning the following error:
>>
>> Thank you any collaboration
>>
>> (0) get_src_grid_info: source lat dims = (120,120)
>> (0) get_src_grid_info: source lon dims = (120,120)
>> (0) get_src_grid_info: source grid type is 'curvilinear'
>> (0) curvilinear_to_SCRIP: calculating grid corners...
>> (0) curvilinear_to_SCRIP: no lat values are at the poles, so
>> (0)       calculating grid corners using
>> (0)       calc_SCRIP_corners_noboundaries...
>> (0) calc_SCRIP_corners_noboundaries
>> (0)     min/max original lat: 24.6335/89.8972
>> (0)     min/max original lon: -179.998/179.975
>> (0) calc_SCRIP_corners_noboundaries
>> (0)     min/max Extlat2d: 23.76/89.8972
>> (0)     min/max Extlon2d: -179.998/179.975
>> (0) calc_SCRIP_corners_noboundaries
>> (0)     min/max ExtGridCenter_lat: 24.1982/89.2938
>> (0)     min/max ExtGridCenter_lon: -179.399/179.417
>> (0) get_dst_grid_info: destination lat dims = (360)
>> (0) get_dst_grid_info: destination lon dims = (360)
>> (0) get_dst_grid_info: Error: the lat/lon arrays are both 1D and the
>> same length.
>> (0)   This could be a rectilinear or unstructured grid. Please set
>> 'grid_type'
>> (0)   to 'rectilinear' or 'unstructured'.
>>
>>
>> Variable: varSrc0
>> Type: float
>> Total Size: 323481600 bytes
>>             80870400 values
>> Number of Dimensions: 3
>> Dimensions and sizes:  [Time | 156] x [XLAT | 720] x [XLONG | 720]
>> Coordinates:
>>             Time: [868188..981394.5]
>> Number Of Attributes: 6
>>   FieldType : 104
>>   MemoryOrder :  XY
>>   description :  LATENT HEAT FLUX AT THE SURFACE
>>   units : W m-2
>>   stagger :
>>   coordinates :  XLONG XLAT
>>
>> Opt                = True
>> Opt at SrcGridLat     = latSrc
>> Opt at SrcGridLon     = lonSrc
>> Opt at DstGridLat     = latDst
>> Opt at DstGridLon     = lonDst
>> Opt at SrcRegional    = True ; because the source grid (ASR)  is a regional
>> grid
>> Opt at DstRegional    = False ; if regriddin to global; set to True if
>> smoothing ASR
>> Opt at InterpMethod   = "bilinear" ; this is the default method
>> Opt at NoPETLog       = True
>> Opt at RemoveSrcFile  = True
>> Opt at RemoveDstFile  = True
>> Opt at RemoveWgtFile  = True
>> Opt at Debug          = True ; set this to False to make it less verbose
>> Opt at CopyVarCoords  = True ; if True, the lat-lon data will be attached as
>> Opt at ForceOverwrite = True
>>
>>
>> ; Regridding function
>>
>> varDst0 = ESMF_regrid(varSrc0,Opt)
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/70c3e9e2/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OutlookEmoji-imageData708542.png
Type: image/png
Size: 1785 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/70c3e9e2/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asr_era.png
Type: image/png
Size: 190861 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/70c3e9e2/attachment-0003.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: regrid_esmf_mod.ncl
Type: application/octet-stream
Size: 5389 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/70c3e9e2/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: regrid_esmf_anim.ncl
Type: application/octet-stream
Size: 5877 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170515/70c3e9e2/attachment-0003.obj 


More information about the ncl-talk mailing list