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

Mary Haley haley at ucar.edu
Fri Jun 23 15:13:30 MDT 2017


Juris,

I should have used better titles on the plots.

The leftmost plot is the original WRF grid, and the pink grid lines
represent the destination grid.

The rightmost plot is the WRF data regridded to the destination (pink) grid.

You can see that the original WRF plot (which I didn't draw a grid of)
covers a much smaller area than the destination grid. The regridding will
basically take place only at the locations where the two grids intersect.

--Mary


On Fri, Jun 23, 2017 at 3:04 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi Juris,
>
> I ran your script on my Mac and it seemed to work fine. This is likely due
> to the fact I just upgraded my ESMF_RegridWeightGen to version 7.0.1 (NCL
> comes with 6.3.0rp1).
>
> If you tell me what kind of system you have, I can try to build a new
> ESMF_RegridWeightGen for you.
>
> Meanwhile, here's a modified version of your script that creates a panel
> plot, and also draws the grid lines of the destination grid so you can see
> where the two grids intersect. This script will only work once
> ESMF_RegridWeightGen is upgraded.  I included the PNG images so you can see
> what it looks like.
>
> Note: Once you have the WRF_to_CMC_RDPA_APCP_conserve.nc weights file and
> you feel that the regridding is working
> ​ correctly​
> , then you can regrid subsequent variables by calling the following:
>
>   Opt = True
>   var_regrid = ESMF_regrid_with_weights(var,"WRF_to_CMC_RDPA_APCP_conserve
> .nc",Opt)
> --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/20170623/9988e1f6/attachment.html 


More information about the ncl-talk mailing list