- 积分
- 85
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-12-4
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2017-2-14 14:38:41
|
显示全部楼层
;======================================================================
; narr_5.ncl
;
; Concepts illustrated:
; - Use a weight file generated via ESMF to:
; (a) Regrid the curvilinear NARR grig to a rectilinear grid "ESMF_regrid_with_weights"
; The ESMF weight file is generated via ESMF_30.ncl
; (b) Generate a pressure x latitude cross-section
; (c) Generate a pressure x longitude cross-section
; (d) Generate a pressure x user_specified_points cross-section
; Here, the user specified points are a great circle path between locations
;======================================================================
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; not needed for 6.1.0 onward
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
;======================================================================
; User specifications
;======================================================================
InterpMethod = "bilinear" ; "bilinear", "conserve"
varName = (/ "TMP_221_ISBL" /) ; could be multiple variables
wgtDirName = "./" ; directory where weight file is located
wgtFileName = "NARR_to_Rect.WgtFile_"+InterpMethod+".nc"
srcDirName = "./"
srcFileName = "merged_AWIP32.1979010100.3D.NARR.grb"
latXsec = 45.0 ; (b)
latLonStrt = 260.0
latLonLast = 305.0
lonXsec = 290.0 ; (c)
lonLatStrt = 25.0
lonLatLast = 75.0
NPTS = 100 ; (d) user specified number of points
ptsXsec = gc_latlon( 25.5, 250., 70., 285.75, NPTS, 2)
nLabels = 8
wksType = "ps" ; ps, png, pdf, x11, ....
wksDirName = "./"
wksFileName = "narr"
;======================================================================
; Miscellaneous; One time settings
;======================================================================
nvar = dimsizes(varName)
wgtFilePath = wgtDirName + wgtFileName
srcFilePath = srcDirName + srcFileName
wksFilePath = wksDirName + wksFileName
sfile = addfile(srcFilePath,"r")
latXsecUser = ptsXsec@gclat ; convenience
lonXsecUser = ptsXsec@gclon
N1 = NPTS-1
XBValues = toint( fspan(0,N1,nLabels) )
XBLabels = new(nLabels,"string")
do i=0,nLabels-1
x = lonXsecUser(XBValues(i))
y = latXsecUser(XBValues(i))
XBLabels(i) = sprintf("%5.1f", y)+"~C~"+sprintf("%5.1f", x)
end do
;************************************************
; graphic resources
;************************************************
res = True
res@gsnMaximize = True
;res@gsnSpreadColors = True ; spread out color table [default v6.1.0]
;res@lbLabelAutoStride = True ; default v6.1.0
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = True ; turn lines on/off ; True is default
res@cnLineLabelsOn = True ; turn line labels on/off ; True is default
wks = gsn_open_wks(wksType,wksFilePath)
;************************************************
; Loop over variables; generate 3 X-Sections
;************************************************
do nv=0,nvar-1
x := sfile->$varName(nv)$
x_regrid := ESMF_regrid_with_weights(x, wgtFilePath, False)
printVarSummary(x_regrid)
res@gsnMajorLonSpacing = 10
res@tiMainString = "Pressure x Longitude at "+latXsec+"N"
plot = gsn_csm_pres_hgt(wks,x_regrid(:,{latXsec},{latLonStrt:latLonLast}),res) ; (b)
delete(res@gsnMajorLonSpacing)
res@gsnMajorLatSpacing = 10
res@tiMainString = "Pressure x Latitude at "+lonXsec+"E"
plot = gsn_csm_pres_hgt(wks,x_regrid(:,{lonLatStrt:lonLatLast},{lonXsec}),res) ; (c)
delete(res@gsnMajorLatSpacing)
res@tmXBMode = "Explicit"
res@tmXBValues = XBValues
res@tmXBLabels = XBLabels
res@tiMainString = "Pressure x User_Specified_Locations"
xsecUser = linint2_points_Wrap(x_regrid&lon ,x_regrid&lat,x_regrid, False \
,lonXsecUser, latXsecUser, 2)
printVarSummary(xsecUser)
plot = gsn_csm_pres_hgt(wks,xsecUser,res) ; (d)
delete( [/ res@tmXBMode, res@tmXBValues, res@tmXBLabels /] )
end do
|
|