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

Dennis Shea shea at ucar.edu
Mon Apr 29 07:42:49 MDT 2019


The 'golden rule' of data processing is "Look at your data"

The variable is dimensioned as follows:

*  float precipitation(nlon, nlat) ;*

The ESMF software is expecting:* (nlat, nlon)*

*    prc_trmm  = f->precipitation*
*    prc_trmm := prc_trmm(nlat|:,nlon|:)*    *; reorder* *t**o that
expected* *by ESMF**; overwrite*


Try and see what happens.
===

Comment: the TRMM grid spans approximately 50S to 50N and is global in
longitude.
I have not looked but I speculate the WRF grid spans a *MUCH* smaller
spatial extent.

I suggest using NCL's coordinate subscripting to extract a subset of the
TRMM grid.

 fn_wrf     = "geo_em.d04.nc"
  fwrf       = addfile(path_wrf+fn_wrf,"r")
  lat2d      = fwrf->XLAT_M(0,:,:)                   ; WRF
  lon2d      = fwrf->XLONG_M(0,:,:)

;---Create an 'extra' large boundary around the WRF grid
  extra      = 2          ; arbitrary
  minLat2D   = min(lat2d) - extra
  maxLat2D   = max(lat2d) + extra
  minLon2D   = min(lon2d) - extra
  maxLon2D   = max(lon2d) + extra

  prc_region = prc_trmm(*{minLat2D:maxLat2D},{minLon2D:maxLon2D}*)
  printVarSummary(prc_region)
  printMinMax(prc_region,0)

On Sat, Apr 27, 2019 at 7:49 PM Mirce Morales <mirce.morales at gmail.com>
wrote:

> 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.
>
>
> _______________________________________________
> 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/20190429/497d74b8/attachment.html>


More information about the ncl-talk mailing list