[ncl-talk] rcm2rgrid

Dennis Shea shea at ucar.edu
Mon Dec 5 19:49:30 MST 2016


yellowstone.ucar.edu

cd /glade/p/work/shea/DEBASISH

===
Read & Plot: Read the file and plot the data

rcm_plot.ncl
Daymet.png

===
ESMF script to generate the weights

rcm2recl.ncl

The problem is that the source grid is quite large: (8075, 7814)

Both the source grid description file:

   daymet_src_SCRIP.nc:  5300236936 bytes

and the generated weight file, located in:
   /glade/p/ncldev/users/debasish/rcm

6312576491 WGT_daymet2Rect_bilinear.nc

are > 2GB. This requires using netCDF-4.  The following option does this:

    Opt at NetCDFType  = "netcdf4"   ; necessary for writing large variables

Further, when you get ESMF errors is is suggested that you use:

     Opt at Debug           = True          ; provide additional information

======

Punch line: copy the WGT file to /some/directory/of/yours

%> cd /some/directory/of/yours
%> cp  /glade/p/ncldev/users/debasish/rcm/WGT_daymet2Rect_bilinear.nc  .

Use:

http://www.ncl.ucar.edu/Document/Functions/ESMF/ESMF_regrid_with_weights.shtml

    var     = sfile->tmax            ; (time, y, x )
    printVarSummary(var)        ; [time |  ] x [y | 8075] x [x | 7814]


    wgtFilePath = "/some/directory/of/yours/WGT_daymet2Rect_bilinear.nc"

  var_regrid = *ESMF_regrid_with_weights*(var,wgtFilePath,False)
  printVarSummary(var_regrid)
.
===

This should be VERY fast.

Let us know when you have copied the file so it can be deleted.

Good Luck




On Thu, Dec 1, 2016 at 3:23 PM, debasish mazumder <debasish at ucar.edu> wrote:

> Thanks. I have used your suggestion. However, I got following error- (0)
> ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was not successful.
>
> with regards
> -Deb
>
> Here is my scripts
>
> 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"
>
> begin
> ;---Read data off source file
> srcFileName = "daymet_v3_tmax_monavg_1980_na.nc4"
> sfile       = addfile(srcFileName,"r")
>     madis       = sfile->tmax(0,:,:)
>     madis at lat2d = sfile->lat
>     madis at lon2d = sfile->lon
>
> ;---Assign zoom region
>     minlon = min(madis at lon2d)
>     maxlon = max(madis at lon2d)
>     minlat = min(madis at lat2d)
>     maxlat = max(madis at lat2d)
>
> ;---Read data off destination file
>     dfile = addfile("/glade/scratch/debasish/CCSM4/CCSM4_T2_1958.nc","r")
>     lat   = dfile->lat    ; Need these for coordinate arrays
>     lon   = dfile->lon    ; for regridding
>     lon = where(lon.gt.180,lon-360,lon)
>
>     ;---Options for regridding
>     Opt                 = True
>
>     Opt at SrcFileName     = "AusSnow_src_SCRIP.nc"
>     Opt at DstFileName     = "AusSnow_dst_SCRIP.nc"
>     Opt at ForceOverwrite  = True
>
>     Opt at SrcTitle        = srcFileName                  ; source grid
>     Opt at SrcMask2D       = where(ismissing(madis),0,1)
>     Opt at SrcRegional     = True
>
>     Opt at DstTitle        = "Australia Rectilinear Grid" ; destination grid
>     Opt at DstGridLat      = lat
>     Opt at DstGridLon      = lon
>     Opt at DstRegional     = True
>
>     ;;Opt at PrintTimings  = True
>
>     Opt at InterpMethod = "bilinear"
>
>    Opt at WgtFileName  = "AUS_Swath_2_Rect_bilinear.nc"
>     madis_regrid_b   = ESMF_regrid(madis,Opt)
>
>     printVarSummary(madis_regrid_b)
>     printMinMax(madis_regrid_b, True)
>
> end
>
>
>
>
> On 12/1/16 2:58 PM, Dennis Shea wrote:
>
>> As suggested by Andrew, the ESMF approach is the way to go.
>>
>> [1] Save the weight file. Note: generating the weight file may be slow
>> but it is done once.
>> [2] Regrid using the weight file generated in [1]. This should be VERY
>> FAST! It is basically a sparse matrix multiply.
>>
>> http://www.ncl.ucar.edu/Document/Functions/ESMF/ESMF_regrid_
>> with_weights.shtml
>> [3] See
>>
>> http://www.ncl.ucar.edu/Applications/ESMF.shtml
>> EXample 4 + numerous others.
>>
>> Good luck
>>
>>
>>
>> On Thu, Dec 1, 2016 at 2:17 PM, debasish mazumder <debasish at ucar.edu
>> <mailto:debasish at ucar.edu>> wrote:
>>
>>     I tried with ESMF regridding but it is still slow. Any other
>> suggestion?
>>     -Deb
>>
>>     On 12/1/16 1:14 PM, Andrew Kren - NOAA Affiliate wrote:
>>     > I would try to use the NCL ESMF regridding tools, much faster and
>> more
>>     > options
>>     >
>>     > On Thu, Dec 1, 2016 at 1:12 PM, debasish mazumder <
>> debasish at ucar.edu <mailto:debasish at ucar.edu>
>>     > <mailto:debasish at ucar.edu <mailto:debasish at ucar.edu>>> wrote:
>>     >
>>     >     Hi All,
>>     >
>>     >     I am trying to interpolates data on a curvilinear grid to to a
>>     >     rectilinear grid using rcm2rgrid.
>>     >     Input data dimension is tmax(time = 12 months, y = 8075, x =
>> 7814) and
>>     >     lat2d(y = 8075, x = 7814), lon2d(y = 8075, x = 7814)
>>     >
>>     >     output lat(192) and lon(288)
>>     >
>>     >     tmaxi  = rcm2rgrid(lat2d,lon2d,tmax,lat,lon,0)
>>     >
>>     >     It took forever to perform the interpolation. Is there any
>> faster way do
>>     >     that.
>>     >
>>     >     with regards
>>     >     -Deb
>>     >     _______________________________________________
>>     >     ncl-talk mailing list
>>     >     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>>     <mailto:ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>>
>>     >     List instructions, subscriber options, unsubscribe:
>>     >     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>     >     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>>
>>     >
>>     >
>>     >
>>     >
>>     > --
>>     > Andrew Kren, PhD
>>     > Research Scientist I, Global Observing Systems Analysis (GOSA) Group
>>     > NOAA ESRL Global Systems Division (Rm 3C515)
>>     > 325 Broadway, Boulder, CO 80305
>>     > (303) 497-5418 <tel:%28303%29%20497-5418>
>> <tel:%28303%29%20497-5418>
>>     _______________________________________________
>>     ncl-talk mailing list
>>     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>>     List instructions, subscriber options, unsubscribe:
>>     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>     <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161205/36081faa/attachment.html 


More information about the ncl-talk mailing list