[ncl-talk] regridding WRF to coarser grid using "conserve" method

Mary Haley haley at ucar.edu
Thu Jun 22 10:35:38 MDT 2017


Hi Juris,

When you use conservative regridding, an additional array is needed that
provides the "bounds" of each data point. If you don't provide one, NCL
tries to calculate one for you by generating a rectangle that encloses each
data point. This is what becomes "grid_corner_lat" and "grid_corner_lon" on
the NetCDF file.

This "guess" is likely not going to be accurate for your own data, because
NCL has no way of knowing what the true bounds are. The error you are
seeing is likely because over the poles, this guesswork can be especially
bad.

The best way to handle this is to provide your own "bounds" via the special
SrcGridCornerLat and Opt at SrcGridCornerLon options
​​.

I'm interested in seeing if we can improve the "guessing" algorithm,
however, or maybe finding another solution for you.

Can you provide me with the data to run this script? If it's not too large,
you can use our ftp:

http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP

Feel free to email me offline about this if you can provide the file but
don't want to make it public.

--Mary




On Wed, Jun 21, 2017 at 5:05 PM, Juris Almonte <Juris.Almonte at umanitoba.ca>
wrote:

> Dear NCL help,
>
> I am having trouble regridding my WRF precipitation data (4 km) to a
> coarser grid (10 km grid with a polar stereographic projection) using the
> “conserve” method. I should note that it works for the “bilinear method”. I
> get the following error when using the “conserve” method. I am using NCL
> V6.3.
>
> 20170621 172919.788 INFO             PET0 Running with ESMF Version
> 6.3.0rp1
> 20170621 172940.034 ERROR            PET0 ~~~~~~~~~~~~~~~~~~~~ Concave
> Element Detected ~~~~~~~~~~~~~~~~~~~~
> 20170621 172940.034 ERROR            PET0   concave elem. id=683007
> 20170621 172940.034 ERROR            PET0
> 20170621 172940.034 ERROR            PET0   concave elem. coords (lon
> [-180 to 180], lat [-90 to 90]) (x,y,z)
> 20170621 172940.034 ERROR            PET0   ------------------------------
> -----------------------------------
> 20170621 172940.034 ERROR            PET0     0  (-100.720581,
> 89.804306)  (-0.000635, -0.003356, 0.999994)
> 20170621 172940.034 ERROR            PET0     1  (-76.010437,  89.767494)
> (0.000981, -0.003938, 0.999992)
> 20170621 172940.034 ERROR            PET0     2  (-133.219574,
> 89.857407)  (-0.001704, -0.001814, 0.999997)
> 20170621 172940.034 ERROR            PET0     3  (130.780121,  89.925125)
> (-0.000854, 0.000990, 0.999999)
> 20170621 172940.034 ERROR            PET0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 20170621 172940.035 ERROR            PET0 ESMCI_Regrid_F.C:178
> c_esmc_regrid_create() Invalid argument - Dst contains a concave cell
> 20170621 172940.035 ERROR            PET0 ESMCI_Regrid_F.C:434
> c_esmc_regrid_create() Invalid argument Internal subroutine call returned
> Error
> 20170621 172940.035 ERROR            PET0 ESMF_Regrid.F90:321
> ESMF_RegridStore Invalid argument - Internal subroutine call returned Error
> 20170621 172940.035 ERROR            PET0 ESMF_FieldRegrid.F90:1008
> ESMF_FieldRegridStoreNX Invalid argument - Internal subroutine call
> returned Error
> 20170621 172940.035 ERROR            PET0 ESMF_RegridWeightGen.F90:1152
> ESMF_RegridWeightGenFile Invalid argument - Internal subroutine call
> returned Error
>
>
>  I have searched the archives regarding this error and have changed the
> longitudes of both the source and destination grids so that it goes from
> 0-360 instead of -180 to 180 as suggested,  but I still get the same
> error.  I have FTP’d the files in the following script.
>
> 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
> ;---Data file containing source grid
>     src_file = "/home/umalmonj/Jan_Apr_monthly_total_2d.nc"
>      ;;---Change (likely)
>     src_constants = "/global/scratch/umalmonj/WRF/juris/CTRL/2D/
> wrfout_conus_constants.nc"
>     sfile    = addfile(src_file,"r")
>     constants = addfile(src_constants,"r")
>
> ;---Get variable to regrid
> prec_acc_nc = sfile->PREC_ACC_NC
> var = dim_sum_n_Wrap(prec_acc_nc,0) ; this sums the variable for the 4
> months
>     src_lat  = constants->XLAT(0,:,:)                   ;;---Change (maybe)
>     src_lon  = constants->XLONG(0,:,:)                 ;;---Change (maybe)
>     var at lat2d = src_lat            ;;---Change (likely)
>     src_lon = where(src_lon.lt.0,src_lon+360,src_lon)
>     var at lon2d=src_lon
>
> ;---Data file containing destination grid
>     dst_file = "/global/scratch/umalmonj/WRF/juris/CaPA/
> AccumulatedtotalPrecipitation.nc"                    ;;---Change (likely)
>     dfile    = addfile(dst_file,"r")
>     dst_lat  = dfile->gridlat_0                   ;;---Change (likely)
>     dst_long  = dfile->gridlon_0                  ;;---Change (likely)
>     dst_lon = where(dst_long.lt.0,dst_long+360,dst_long)
>
> ;---Set up regridding options
>     Opt                   = True
>
> ;---"bilinear" is the default. "patch" and "conserve" are other options.
>     Opt at InterpMethod      = "conserve"       ; might want to use
> conservative for precip
>
>     Opt at WgtFileName       = "curv_to_curv.nc"  ; optional
>
>     Opt at SrcGridLat        = src_lat           ; source grid
>     Opt at SrcGridLon        = src_lon
>     Opt at SrcRegional       = True              ;;--Change (maybe)
>     Opt at SrcFileName  = src_file          ; optional, but good idea
>     Opt at SrcGridMask         = where(.not.ismissing(var),1,0) ; Necessary
> if has
>                                                            ; missing
> values.
>
>
>     Opt at DstGridLat        = dst_lat             ; destination grid
>     Opt at DstGridLon        = dst_lon
>     Opt at DstRegional       = True              ;;--Change (maybe)
>     Opt at DstGridMask = where(.not.ismissing(dst_lat).and.\
>                           .not.ismissing(dst_lon),1,0) ; Necessary if
> lat/lon
>                                                       ; has missing values.
> ; there is an attribute in the dest. file called "corners", but there are
> four
> ; diff. numbers for both the lon and lat variables
> ; just let NCL figure out the corners...
> ;    Opt at DstLLCorner = (/12.21208,217.1075/)
> ;    Opt at DstURCorner = (/79.82558,147.6248/)
>     Opt at ForceOverwrite    = True
>     Opt at PrintTimings      = True
>     Opt at Debug             = True
>
>     var_regrid = ESMF_regrid(var,Opt)     ; Do the regridding
>
>     printVarSummary(var_regrid)
>
>
> Any help would be greatly appreciated,
>
> Juris
>
>
>
> _______________________________________________
> 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/20170622/b455a050/attachment.html 


More information about the ncl-talk mailing list