- 积分
- 1502
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-4-12
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2014-10-22 10:51:39
|
显示全部楼层
脚本:
; Example script to produce dbz plots for a WRF real-data run,
; with the ARW coordinate dynamics option.
; November 2008
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
a = addfile("/home/Huanglei/data/d032"+".nc","r")
; We generate plots, but what kind do we prefer?
type = "pdf"
; type = "pdf"
; type = "ps"
; type = "ncgm"
wks = gsn_open_wks(type,"plt_dbzaddlightning")
gsn_define_colormap(wks,"sunshine_9lev")
; gsn_define_colormap(wks, "wgne15") ; choose colormap
; Set some basic resources
res = True
res@MainTitle = "REAL-TIME WRF"
pltres = True
pltres@PanelPlot = True ; Tells wrf_map_overlays not to remove overlays
mpres = True
mpres@mpOutlineOn = False ; Turn off map outlines
mpres@mpFillOn = False ; Turn off map fill
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Which times and how many time steps are in the data set?
times = wrf_user_getvar(a,"times",-1) ; get all times in the file
ntimes = dimsizes(times) ; number of times in the file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; do it = 48,ntimes-1 ; TIME LOOP
it=48
print("Working on time: " + times(it) )
res@TimeLabel = times(it) ; Set Valid time to use on plots
; First get the variables we will need
; Both dbz and mdbz will be calculated using intercept parameters
; for rain, snow, and graupel, which are consistent with
; Thompson, Rasmussen, and Manning (2004, Monthly Weather Review,
; Vol. 132, No. 2, pp. 519-542.)
; First "1" in wrf_user_getvar
; Frozen particles that are at a temperature above freezing will be
; assumed to scatter as a liquid particle.
; Second "1" in wrf_user_getvar
mdbz = wrf_user_getvar(a,(/"mdbz","1","1"/),it)
dbz = wrf_user_getvar(a,(/"dbz","1","1"/),it)
opts = res
; opts@cnLineColor = "Black"
opts@cnFillOn = False
opts@gsnSpreadColors = False
opts@cnMonoLineColor = False
; opts@cnFillOn = True
opts@pmLabelBarDisplayMode="Always"
opts@cnLineLabelsOn = False
opts@pmLabelBarWidthF = 0.06 ; default is shorter
opts@pmLabelBarHeightF = 0.8 ; default is taller
opts@lbLabelFontHeightF = 0.0001 ; default is HUGE
opts@cnLineDrawOrder = "PreDraw"
; opts@cnLineLabelBackgroundColor = "white"
opts@lbPerimOn = False
opts@ContourParameters = (/ 5., 65.,10./)
contour = wrf_contour(a,wks,dbz(1,:,:),opts) ; plot only lowest level
plot= wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
; contour = wrf_contour(a,wks,mdbz,opts)
; plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
;>============================================================<
; add China map
;>------------------------------------------------------------<
shp_name1 = "/home/Huanglei/map/China/diquJie_polyline.shp"
lnres = True
lnres@gsLineColor = "gray25"
lnres@gsLineThicknessF = 0.5
id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)
shp_name2 = "/home/Huanglei/map/China/cnmap/cnhimap.shp"
prres=True
prres@gsLineThicknessF = 2.0
prres@gsLineColor = "black"
plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)
;draw(plot)
tes = True
tes@returnInt = False ; return real values
loc1 = wrf_user_ll_to_ij(a, 103.3, 30.3, tes)
print("X/Y location is: " + loc1)
loc2 = wrf_user_ll_to_ij(a, 105., 32., tes)
print("X/Y location is: " + loc2)
;; draw(plot) ; This will draw the map and the shapefile outlines.
lnres = True
lnres@gsLineThicknessF = 5.0
lnres@gsLineColor = "Red"
gsn_polyline(wks,plot,(/103.3, 105./),(/30.3, 32./),lnres)
;draw(plot)
ascii_filename = "/home/Huanglei/data/new16jia.txt"
seismic = asciiread(ascii_filename,(/521,3/),"float")
y = seismic(:,0) ; Column 1 of file contains X values.
x = seismic(:,1) ; Column 2 of file contains Y values.
z = seismic(:,2) ; Column 3 of file contains Z values.
txres2 = True
txres2@txFont = 0.01
txres2@txFontHeightF =0.01
txres2@txFontColor = "Red"
idx = ind(z .gt. 0)
print(idx)
if .not. all(ismissing(idx))
str = new(dimsizes(idx), "string")
str = "+"
txdum1 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if
txres2@txFontColor = "Blue"
idx := ind(z .lt. 0)
if .not. all(ismissing(idx))
str := new(dimsizes(idx), "string")
str = "-"
txdum2 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if
draw(plot)
frame(wks)
delete(opts)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end
|
|