Re: [3610719] Edge issue in Regridding Daymet Joined Tiles with ESMF_Regridding on NCL 6.1.0

From: Ping Yang <pyang_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 23 2013 - 15:01:45 MDT

Dear NCL,

I was trying to use the SrcMask2D function to do the regridding from 1KM to
3 armin based on the joined Daymet data,

Is that possible to update the example for using SrcMask2D function?

Actually I tried to create a mask grid from the 1KM resolution Daymet
(which I think it will be best in resolution), however, I got errors:

(0) write_grid_description: source lat dims = (2082,1551)
(0) write_grid_description: source lon dims = (2082,1551)
(0) write_grid_description: source grid type is 'curvilinear'
fatal:Eq: Dimension size, for dimension number 0, of operands does not
match, can't continue
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 943 in
file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 2543 in
file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 2654 in
file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 110 in
file daymet_1KM-3MIN.ncl
fatal:Variable (var_regrid) is undefined
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 111 in
file daymet_1KM-3MIN.ncl
fatal:Variable (var_regrid) is undefined, can not assign attribute
(grid_mapping)
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 112 in
file daymet_1KM-3MIN.ncl
fatal:Variable (var_regrid) is undefined
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 113 in
file daymet_1KM-3MIN.ncl

However if I remove this code:
Opt@SrcMask2D = where(.not.ismissing(var),1,0)
The script runs fine.

I've already uploaded my data onto the ftp(previous message) and my script
is as follows:

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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"

;======================================================================
; The main code
;======================================================================

vname = "prcp"
year = 1980
print("start to process the year of "+ year + " for variable " + vname)
;---Input file (Daymet joined tile) ;NE_all_1980_correct_$vname$ .nc
    srcDirName = "/data/ecr/yangping/DAYMET/Grid/1KM/011213/"
    srcFileName = vname + ".NE." + year +".nc"
    srcPathName = srcDirName+srcFileName
    sfile = addfile(srcPathName,"r")

;---Set the destination file name
    dstDirName = "/data/ecr/yangping/DAYMET/Grid/Intermediate/"
    system("/bin/mkdir -p "+ dstDirName)
    dstFileName = str_upper(vname)+"."+year+"_1KM.esmf.nc"
    dstPathName = dstDirName+dstFileName

    setfileoption("nc","Format","LargeFile")

    outDirName = "/data/ecr/yangping/DAYMET/Grid/3MIN/"
    outFileName = vname + ".3MIN.lonlat." + year+".nc"
    outPathName = outDirName + outFileName
    system("/bin/rm -f "+outPathName) ; delete any pre-existing file
    out=addfile(outPathName,"c")

;--- ESMF regrid method: "conserve", "bilinear", "patch"
     method = "conserve"

;===================================================

;---Options
    Opt = True
    Opt@SrcTitle = "Daymet Joined Grid "+year+" to rectlinear" ;
optional
    Opt@WgtFileName = dstDirName + "Daymet_to_Rect.Wgt.nc"

    Opt@ForceOverwrite = True
  ;;Opt@PrintTimings = True

;---Get the source file Daymet lat/lon grid
    lat2d = sfile->lat
    lon2d = sfile->lon

    dim2d = dimsizes(lat2d)
    nlat = dim2d(0)
    nlon = dim2d(1)

    print(nlat)
    print(nlon)

;---Get the Daymet source variable
    var = sfile->$vname$ ; (time, y, x)=>(365,232,221)
    printVarSummary(var)
   ;Opt@SrcGridType = "curvilinear"
    Opt@SrcGridLat = lat2d
    Opt@SrcGridLon = lon2d
    Opt@SrcMask2D = where(.not.ismissing(var),1,0)
;---Create the destination lat/lon grid
    dll=0.05 ;3MIN
    latrange=abs(max(lat2d)-min(lat2d))
    lonrange=abs(max(lon2d)-min(lon2d))
    kpts_lat= toint(latrange/dll)+1
    kpts_lon= toint(lonrange/dll)+1
    lat = fspan( min(lat2d),max(lat2d), kpts_lat )
    lon = fspan( min(lon2d),max(lon2d), kpts_lon )

    newlon = fspan(-84.025,-64.875,384)
    newlat = fspan(34.875,50.125,306)
    Opt@Debug = True
    Opt@DstGridType = "rectilinear"
    ;Opt@DstGridLat = lat
    Opt@DstGridLat = newlat
    ;Opt@DstGridLon = lon
    Opt@DstGridLon = newlon

    Opt@CopyVarCoords= True ; default for 6.1.0

    Opt@InterpMethod = method
    Opt@SrcRegional = True
    Opt@DstRegional = True

    var_regrid = ESMF_regrid(var,Opt) ; Do the regridding for 'var'
    printVarSummary(var_regrid)
    var_regrid@grid_mapping = "lonlat" ;
    out->$vname$=var_regrid ;output the regridding result

I was using the original 1KM Daymet data as a mask by using the SrcMask2D
function, Is this a correct way to do this? Any suggestions or comments
will be appreciated.

Thanks,

Ping

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 23 15:01:53 2013

This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:26 MDT