Typically, when you have a source/destination grid with missing
values, one would see
optESMF@SrcMask2D = where(.not.ismissing(var_in),1,0)
Also, the output grid would have some specification
of the missing template. I think ESMF will regrid to all destination
lat an lon by default. I think WRF has a LAND_MASK variable
XLAND(Time, south_north, west_east)
msk_dst = f_dst->XLAND(0,:,:) ; MASK (1 FOR LAND, 2 FOR WATER)
optESMF@DstMask2D = where(ismissing(msk_dst),0,1) ; or ,1,0)
===========
In any event, we have no idea where files like
~/era_i/domain/alaska/geo_em.d01.nc
are located.
--- See ESMG-26 or -28 D 03/10/2014 10:45 AM, Elizabeth Cassano wrote: > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ; extract_erai.ncl > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ; load in the libraries > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" > load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl" > load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ; start the main program > begin > title_dst = "Alaska domain" > ; set the time units > TimeUnits = "hours since 1979-01-01 00:00:00" > ; set the value and attributes for the time > time = cd_inv_calendar(1990, 1, 1, 6, 0, 0, TimeUnits, 0) > time@long_name = "Time" > time@standard_name = "time" > time@units = TimeUnits > time@calendar = "standard" > time@_FillValue = 1e20 > time!0 = "time" > time&time = time > ; read in the lat/lon from the file with the destination domain > f_dst = addfile("~/era_i/domain/alaska/geo_em.d01.nc", "r") > lat_dst = f_dst->XLAT_M(0,:,:) > lon_dst = f_dst->XLONG_M(0,:,:) > ; -determine the dimensions of the destination grid > DimLat = dimsizes(lat_dst) > nS_N = DimLat(0) > nW_E = DimLat(1) > ; -edit some of the attributes > lat_dst@long_name = "Latitude" > lat_dst@standard_name = "latitude" > lat_dst@units = "degrees_north" > lat_dst!0 = "south_north" > lat_dst!1 = "west_east" > lon_dst@long_name = "Longitude" > lon_dst@standard_name = "longitude" > lon_dst@units = "degrees_east" > lon_dst!0 = "south_north" > lon_dst!1 = "west_east" > ; set the file name for the weights > WgtFile = "~/esmf_test/esmf_test-ESMF_weight" > ; create the list of settings for ESMF_regrid -> non-source related > optESMF = True > optESMF@InterpMethod = "bilinear" > optESMF@WgtFileName = WgtFile > optESMF@DstGridLat = lat_dst > optESMF@DstGridLon = lon_dst > optESMF@DstRegional = True > optESMF@DstInputFileName = "esmf_test-1990010106.nc" > optESMF@DstTitle = "Alaska Domain" > optESMF@CopyVarAtts = True > optESMF@CopyVarCoords = True > optESMF@ForceOverwrite = True > optESMF@RemoveSrcFile = True > optESMF@RemoveDstFile = True > optESMF@RemoveWgtFile = False > optESMF@Debug = False > ; open the ERA-I GRIB files from NCAR-CISL RDA > f_sfc1 = > addfile("/glade/p/rda/data/ds627.0/ei.oper.an.sfc/199001/"+ \ > > "ei.oper.an.sfc.regn128sc.1990010100.grb", "r") > f_sfc2 = > addfile("/glade/p/rda/data/ds627.0/ei.oper.fc.sfc/199001/"+ \ > > "ei.oper.fc.sfc.regn128sc.1990010100.grb", "r") > ; set the values for the lat/lon of the source domain > lat_src = f_sfc1->g4_lat_0 > lon_src = f_sfc1->g4_lon_1 > ; find the values for Z_sfc and LandMask > ; create the list of settings for ESMF_regrid -> source related > optESMF@SrcGridLat = lat_src > optESMF@SrcGridLon = lon_src > optESMF@SrcInputFileName = "ei.oper.an.sfc.regn128sc.1990010100" > optESMF@SrcTitle = "ERA-Interim" > ; surface elevation > Z_sfc_in = f_sfc1->Z_GDS4_SFC ; read in the data > Z_sfc_1 = Z_sfc_in / 9.81 ; calculate the height > ; -call ESMF_regrid with the generation of weights > Z_sfc = ESMF_regrid(Z_sfc_1, optESMF) > ; -copy the attributes (atts were lost with calc) > copy_VarAtts(Z_sfc_in, Z_sfc) > ; -delete some attributes > delete_VarAtts(Z_sfc,(/"lat2d","lon2d"/)) > ; -fix/add some of the attributes/coordinates > Z_sfc@long_name = "Terrain Height" > Z_sfc@units = "m" > Z_sfc@coordinates = "lon lat" > Z_sfc!0 = "south_north" > Z_sfc!1 = "west_east" > ; read the variable from the ERA-I file > x0 = f_sfc2->TP_GDS4_SFC > x1 = x0(1,:,:) > ; regrid the data to the destination grid, using weights > x2 = ESMF_regrid_with_weights(x1, WgtFile, optESMF) > ; create set equal the new variable with time > x3 = new((/1,nS_N,nW_E/),"float",0) > x3(0,:,:) = x2 > ; delete some attributes > delete_VarAtts(x3, (/"lat2d","lon2d"/)) > ; add some attributes / coordinates > x3@coordinates = "lon lat" > x3!0 = "time" > x3!1 = "south_north" > x3!2 = "west_east" > x3&time = time > ; open the file to be written > path_file_out = "~/esmf_test/esmf_test-1990010106.nc" > ; -check to see if file is present, if so, delete the previous file > if isfilepresent(path_file_out) then > system ("rm "+path_file_out) > end if > ; -create the file > f_out = addfile(path_file_out,"c") > ; set time to be the unlimited record variable > filedimdef(f_out,"time",-1,True) > ; write the data to the file > f_out->time=time > f_out->lat=lat_dst > f_out->lon=lon_dst > f_out->Z_sfc=Z_sfc > f_out->precip_t = x3 > end _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Mon Mar 10 16:09:56 2014
This archive was generated by hypermail 2.1.8 : Fri Mar 14 2014 - 15:08:52 MDT