- 积分
- 1991
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-8-18
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
NCL小白,在官网上看到计算散度的例子(http://www.ncl.ucar.edu/Applications/Scripts/wind_5.ncl),经过努力修改终于出图,但却不知道对不对,两个图哪个是平时个例分析用的散度,敬请高手指导!附脚本:
;*************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; 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"
;*************************************************
begin
;*************************************************
; open file and read in data: data are on a gaussian grid
;*************************************************
f = addfile (".\fnl_20180730_18_00.grib2", "r")
u = short2flt(f->UGRD_P0_L100_GLL0({30000},:,:)) ; (time,lev,lat,lon)
v = short2flt(f->VGRD_P0_L100_GLL0({30000},:,:))
lat = f->lat_0
lon = f->lon_0
;*************************************************
; Reorder from N-S to S->N
;*************************************************
;u = u(:,:,::-1,:)
;v = v(:,:,::-1,:)
printVarSummary(u)
printVarSummary(v)
;*************************************************
; calculate divergence on a gaussian grid
; divs - spherical harmonics
; divf - finite difference
;*************************************************
divs = uv2dvG_Wrap(u,v)
divs@long_name = "divergence: uv2dvG"
print("divs: min="+min(divs)+" max="+max(divs))
printVarSummary(divs)
divf = uv2dv_cfd (u,v,lat,lon, 3)
copy_VarCoords(u,divf)
divf@long_name = "divergence: uv2dv_cfd"
print("divf: min="+min(divf)+" max="+max(divf))
printVarSummary(divf)
;*************************************************
; plot results
;*************************************************
wks = gsn_open_wks("png","wind") ; send graphics to PNG file
plot = new(2,graphic) ; create a plot array
res = True
res@mpMaxLatF =60
res@mpMinLatF =15
res@mpMaxLonF =140
res@mpMinLonF =70
res@pmTickMarkDisplayMode = "Always"
res@mpFillOn = True
res@mpOutlineOn = False ; Use outlines from shapefile
res@mpDataSetName = "Earth..4"
res@mpDataBaseVersion = "MediumRes"
res@mpOutlineOn = True
res@mpOutlineSpecifiers = (/"China:states","Taiwan"/)
res@mpGeophysicalLineThicknessF = 2
res@mpNationalLineThicknessF = 2
res@mpFillOn = True
res@mpFillAreaSpecifiers = (/"water", "land" /)
res@mpSpecifiedFillColors = (/"skyblue1","white"/)
; res@mpSpecifiedFillColors = (/100,0/)
res@mpMaskAreaSpecifiers = (/"China:states","Taiwan"/)
res@pmTickMarkDisplayMode = "Always"
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnFillOn = True ; color on (default for 6.1.0 onward)
res@cnFillPalette = "BlAqGrYeOrRe" ; set color map
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour line labels
;res@cnFillMode = "RasterFill"
res@cnInfoLabelOn = False ; turn off cn info label
res@lbLabelBarOn = False ; turn off individual cb's
; to have a common label bar, both plots should be set to the same interval
; b/c the label bar is drawn by default from the interval of the first plot.
; Here, the levels are set manually
res@cnLevelSelectionMode = "ManualLevels"
res@cnMinLevelValF = -3e-05
res@cnMaxLevelValF = 3e-05
res@cnLevelSpacingF = 1e-06
;res@lbLabelStrings= sprintf(“%4.1f”,ispan(-3e-05,3e-05,1e-06))
res@lbBoxEndCapStyle ="TriangleBothEnds"
;res@cnFillPalette ="BlueWhiteOrangeRed"; 选择中间带白色的彩色地图
nt =0 ; plot 1st time step only
plev = 700
;res@gsnCenterString = plev+"hPa"
;plot(0) = gsn_csm_contour_map(wks,divs(20:50,60:120),res)
;plot(1) = gsn_csm_contour_map(wks,divf(20:50,60:120),res)
plot(0) = gsn_csm_contour_map(wks,divs(:,:),res)
plot(1) = gsn_csm_contour_map(wks,divf(:,:),res)
;************************************************
; create panel
;************************************************
resP = True ; modify the panel plot
resP@gsnPanelMainString = "Insert your own title here"
resP@gsnMaximize = True ; make ps, eps, pdf large
resP@gsnPanelLabelBar = True ; add common colorbar
gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot
;draw(plot)
;frame(wks)
end
|
-
|