[ncl-talk] Sub: ESMF_ Regrid...
Adv
advita6 at gmail.com
Mon Feb 8 21:30:48 MST 2016
Hi NCL users,
I have printed below the program I use to plot a figure attached here. I
doubt whether the regrid function works or not? Because, the figure looks
so weird. Could someone help me to fix this bug?
Thank you
Adv
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
begin
;a = (/1,2,3,4,5,6,7,8/)
;a0 = onedtond(a,(/4,2/))
;print(a0)
;printVarSummary(a0)
;return
strll = asciiread("stationmac.txt", -1, "string") ;
print(strll) ; STATION","STATION_NAME", "LAT", "LON"
print("=====")
sloc = str_get_field(strll , 2, ",")
lat = tofloat( str_get_field(strll , 3, ",") )
lon = tofloat( str_get_field(strll , 4, ",") )
print(sloc +" : "+lat+" "+lon)
print(lon)
;&&&&&&&&&&&
lonm=lon(0:389)
latm=lat(0:389)
;minlat=min(latm)
;minlon=min(lonm)
;maxlat=max(latm)
;****************
mlon = 390
dlon = -90.35 / mlon
lonn = fspan (-116.1, (mlon - 1) * dlon, mlon)
mlat = 390
dlat = 49.0 / mlat
latt = fspan (40.00, (mlat - 1) * dlat, mlat)
print(lonn)
minlat=min(latt)
minlon=min(lonn)
maxlat=max(latt)
maxlon=max(lonn)
diri="/home/dailysimms/prec-obs/"
z1 = asciiread(diri+"prec_avg_Jan-Dec1965-2005",-1,"float")
print(z1)
printVarSummary(z1)
z0 = onedtond(z1,(/390,390/))
print(z0)
printVarSummary(z0)
z0!0="lat"
z0!1="lon"
z0&lat=latm
z0&lon=lonm
printVarSummary(z0)
;print(z0)
;print(min(z0)-min(z1))
;print(max(z0)-max(z1))
print(min(z0))
print(max(z0))
;ESMF REGRID *******************
;---Set up options for regridding to 0.1 degree grid
Opt = True
Opt at SrcGridLat = latm
Opt at SrcGridLon = lonm
;---If you don't set these two, the regridding will be VERY slow
Opt at DstLLCorner = (/floor(minlat)-0.1,floor(minlon)+0.1/)
Opt at DstURCorner = (/ ceil(maxlat)-0.1, ceil(maxlon)+0.1/)
Opt at DstGridType = "0.1deg" ; destination grid
Opt at ForceOverwrite = True
; Opt at SrcGridMask = where(.not.ismissing(z0),1,0)
Opt at Debug = True
Opt at InterpMethod = "bilinear"
pwv_regrid_p = ESMF_regrid(z0,Opt)
printVarSummary(pwv_regrid_p)
;---Plotting section
wks = gsn_open_wks("pdf","ESMF_regrid")
gsn_define_colormap(wks,"rainbow") ; Change color map
;---Resources to share between both plots
res = True ; Plot modes desired.
res at gsnMaximize = True ; Maximize plot
res at gsnDraw = False
res at gsnFrame = False
res at cnFillOn = True ; color plot desired
res at cnLinesOn = False ; turn off contour lines
res at cnLineLabelsOn = False ; turn off contour labels
res at cnFillMode = "RasterFill" ; turn raster on
; res at cnLevelSelectionMode = "ExplicitLevels"
; res at cnLevels = ispan(270,300,2)
res at mpFillOn = False
res at mpLimitMode = "LatLon"
res at mpMinLatF = 40.
res at mpMaxLatF = 49.
res at mpMinLonF = -116
res at mpMaxLonF = -90.1
res at mpFillOn = False
res at trGridType = "TriangularMesh" ; allow missing coordinates
res at gsnAddCyclic = False
res at lbLabelBarOn = False
res at gsnAddCyclic = False
;---Draw US states in a light gray
res at mpOutlineBoundarySets = "GeophysicalAndUSStates"
res at mpUSStateLineColor = "Gray10"
res at tiMainString = "GPS PWV (18Z) (original)"
res at tiMainString = "Regridded to 0.1 deg using 'patch'"
map_regrid_p = gsn_csm_contour_map(wks,pwv_regrid_p,res)
pres = True
pres at gsnPanelLabelBar = True
pres at pmLabelBarWidthF = 0.7
pres at gsnMaximize = True
pres at lbBoxLinesOn = False
pres at lbLabelFontHeightF = 0.01
gsn_panel(wks,(/map_regrid_p/),(/1,1/),pres)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160208/e67ec343/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ESMF_regrid.pdf
Type: application/pdf
Size: 51644 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160208/e67ec343/attachment.pdf
More information about the ncl-talk
mailing list