[ncl-talk] esmf regrid

Marston Johnston shejo284 at gmail.com
Thu Sep 21 14:00:34 MDT 2017


Hi,

You could try and set the boundaries of your domain and simply give the resolution you are after.
Here’s a workhorse example of mine that is works. If you take a look at the ESMF_regrid doc you can see the following:

“This function is an "all-in-one" function that performs all of these steps:

    Writes the description of the source grid to a SCRIP or ESMF description NetCDF file.
    Writes the description of the destination grid to a SCRIP or ESMF description NetCDF file.
    Generates the weights and writes them to a NetCDF file.
    Regrids the data by applying the weights.
    Copies metadata (attributes and coordinate arrays) where possible.”

You will need to set some of the options for this function to work. NCL folks have done a wonderful job with this function wrapper and the documentation is superb. Have a good read through the docs.

Perhaps you can follow my example, which is a copy of the NCL example: 

undef("Regrid2d")
function Regrid2d(temp:numeric,op:logical)
local Opt
begin
  print("Regridding data using ESMF")
  ;printVarInfo(temp,"temp b4")

 ; Try and set these work files
  Opt                = True
  Opt at SrcFileName    = "_src.nc"
  Opt at DstFileName    = "_dst.nc"
  Opt at WgtFileName    = "_wgt.nc"
  Opt at ForceOverwrite = True

  ; Make sure you mask out missing values and set _FillValue in the array you are passing to the function.
  Opt at SrcGridMask    = where(.not.ismissing(temp),1,0)

  ; Set the resolution here and make sure you set the boundaries: 
  Opt at DstGridType    = “0.5x0.5”
  Opt at DstLLCorner    = (/-90.d,0.d/)
  Opt at DstURCorner    = (/90.d, 360.d/)
  Opt at SrcRegional = True
  Opt at DstRegional = True
  Opt at InterpMethod = "bilinear"

  temp_regrid = ESMF_regrid(temp,Opt)
 printVarInfo(temp_regrid,"temp_regrid")
 system("/bin/rm -f _*.nc PET0*.Log")
  return(temp_regrid)
end

/M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marston S. Ward, PhD
Department of Earth Sciences
University of Gothenburg, Sweden
Email: marston.johnston at gu.se
SkypeID: marston.johnston 
Phone: +46-31-7864901 
Only the fruitful thing is true!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

On 2017-09-21, 21:38, "Buzan, Jonathan R" <jbuzan at purdue.edu> wrote:

    Thanks Marston Ward,
    
    I rewrote the script, and I am using a proper domain file that does not have the -90.25/90.25.
    I still receive the same error:
    
    (0)	get_src_grid_info: source lat dims = (17400)
    (0)	get_src_grid_info: source lon dims = (43200)
    (0)	get_src_grid_info: source grid type is 'rectilinear'
    ncendef: ncid 196608: NetCDF: One or more variable sizes violate format constraints
    fatal:NetCDF: Operation not allowed in define mode: error attempting to write variable (grid_dims) to file (source_grid_file.nc)
    fatal:["Execute.c":8575]:Execute: Error occurred at or near line 1704 in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
    
    fatal:["Execute.c":8575]:Execute: Error occurred at or near line 1840 in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
    
    fatal:["Execute.c":8575]:Execute: Error occurred at or near line 3869 in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
    
    fatal:["Execute.c":8575]:Execute: Error occurred at or near line 4001 in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
    
    fatal:["Execute.c":8573]:Execute: Error occurred at or near line 106
    
    
    
    
    
    
    
    > On Sep 21, 2017, at 3:33 PM, Marston Johnston <shejo284 at gmail.com> wrote:
    > 
    > If you read the output error you can see that:
    > 
    >  min/max Extlat2d: -90.25/90.25
    > 
    > is clearly wrong as there can be no such points.
    > 
    > It good practice to read the error messages carefully. They often times tell you what’s wrong.
    > 
    > /M
    > 
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Marston S. Ward, PhD
    > Department of Earth Sciences
    > University of Gothenburg, Sweden
    > Email: marston.johnston at gu.se
    > SkypeID: marston.johnston 
    > Phone: +46-31-7864901 
    > Only the fruitful thing is true!
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > 
    > 
    > On 2017-09-21, 20:32, "ncl-talk on behalf of Buzan, Jonathan R" <ncl-talk-bounces at ucar.edu on behalf of jbuzan at purdue.edu> wrote:
    > 
    >      min/max Extlat2d: -90.25/90.25
    > 
    > 
    
    




More information about the ncl-talk mailing list