[ncl-talk] ESMF bilinear regridding - error: Opt at Mask2D is not the correct dimensionality

Mirce Morales mirce.morales at gmail.com
Sat Apr 27 19:48:22 MDT 2019


Hi all,

I am trying to regrid precipitation data from TRMM3B42 using ESMF bilinear
regridding, however, when I try to generate the weights I get the following
error:

*curvilinear_to_SCRIP: Opt at Mask2D is not the correct dimensionality*

I successfully did the regridding in the past for the same data, but now
some attributes of the data have changed for the period of time I
interested in and I am getting the last error.

These are the attributes of my data:
*netcdf \3B42.20090101.00.7A.HDF {*
*dimensions:*
*        nlon = 1440 ;*
*        nlat = 400 ;*
*variables:*
*        float precipitation(nlon, nlat) ;*
*                precipitation:units = "mm/hr" ;*
*                precipitation:coordinates = "nlon nlat" ;*
*                precipitation:_FillValue = -9999.9f ;*
*        float nlon(nlon) ;*
*                nlon:long_name = "longitude" ;*
*                nlon:standard_name = "longitude" ;*
*                nlon:units = "degrees_east" ;*
*        float nlat(nlat) ;*
*                nlat:long_name = "latitude" ;*
*                nlat:standard_name = "latitude" ;*
*                nlat:units = "degrees_north" ;*

And this is my 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

;----------------------------------------------------------------------
; User settings
;----------------------------------------------------------------------

  ;---------------------------------------------------------------;
  ; Set source and destination grid filenames.                    ;
  ; Define weight filename.                                       ;
  ;---------------------------------------------------------------;
    interp_opt = "bilinear"
    wgtFileName = "./TRMM2WRFHydro_weight_"+interp_opt+".nc"

    srcGridName = "./3B42.20090101.00.7A.HDF.nc4"
  if ( .not.isfilepresent( srcGridName ) ) then
     print( " ... source grid file not found : "+ srcGridName )
     exit
  end if

    dstGridName = "/glade/work/mirce/DOMAINS/DOMAIN_Files_250m_200/
geo_em.d04.nc"
  if ( .not.isfilepresent( dstGridName ) ) then
     print( " ... destination grid file not found : "+ dstGridName )
     exit
  end if

  ;---------------------------------------------------------------;
  ; Field names for lat and lon coordinates in the source file.   ;
  ;---------------------------------------------------------------;
  LatName = "nlat"
  LonName = "nlon"

;----------------------------------------------------------------------
; Convert source grid to a SCRIP convention file.
;----------------------------------------------------------------------
    src_file = addfile(srcGridName,"r")
    vNames   = getfilevarnames( src_file )

    if ( isfilevar( src_file, LatName ) .and. isfilevar( src_file, LonName
) ) then
       src_lat = src_file->$LatName$
       src_lon = src_file->$LonName$
    else
       print( " ... no such lat/lon fieldnames" )
       exit
    end if

    if ( isfilevar( src_file, "precipitation" ) ) then
       test_mask = src_file->precipitation(:,:)
    else
       print( " ... no such data field " )
       exit
    end if

    Opt                = True
    Opt at Mask2D         = where(.not.ismissing(test_mask),1,0)
    Opt at SrcRegional    = False
    Opt at ForceOverwrite = True
    Opt at PrintTimings   = True
    Opt at Title          = "TRMM"

    src_SCRIP_filename     = "SCRIP_TRMM_"+interp_opt+".nc"
    rectilinear_to_SCRIP( src_SCRIP_filename, src_lat, src_lon, Opt)

    delete(Opt)

;----------------------------------------------------------------------
; Convert destination grid to a SCRIP convention file.
;----------------------------------------------------------------------
    dst_file = addfile(dstGridName,"r")

    if ( isfilevar( dst_file, "XLAT" ) .and. .not. isfilevar( dst_file,
"XLAT_M") ) then
       dst_lat = dst_file->XLAT(0,:,:)
       dst_lon = dst_file->XLONG(0,:,:)
    end if

    Opt                = True
    Opt at DstRegional    = True
    Opt at ForceOverwrite = True
    Opt at PrintTimings   = True
    Opt at Title          = dstGridName

    dst_SCRIP_filename     = "SCRIP_WRFHydro_"+interp_opt+".nc"
    curvilinear_to_SCRIP( dst_SCRIP_filename, dst_lat, dst_lon,Opt)

    delete(Opt)

;----------------------------------------------------------------------
; Generate the weights that take you from the source grid to
; destination degree grid.
;----------------------------------------------------------------------
    Opt                      = True
    Opt at InterpMethod         = interp_opt
    Opt at DstRegional          = True
    Opt at ForceOverwrite       = True
    Opt at PrintTimings         = True
    Opt at Debug                = True

    ESMF_regrid_gen_weights( src_SCRIP_filename, dst_SCRIP_filename,
wgtFileName, Opt)

    delete(Opt)

;----------------------------------------------------------------------
;----------------------------------------------------------------------
end

If it's helpful, my data is in the following path in Cheyenne:

*/glade/scratch/mirce/LaSierra/FullDomainForcing/TRMM_3B24/Test*

I will appreciate any help about how to fix this error.

Thanks!,
Mirce.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190427/69905b8a/attachment.html>


More information about the ncl-talk mailing list