- 积分
- 2419
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-1-28
- 最后登录
- 1970-1-1
|
发表于 2017-5-25 21:51:20
|
显示全部楼层
本帖最后由 sun_shine_Xia 于 2017-5-28 10:14 编辑
- ;*********************************************
- ; route.ncl
- ;*********************************************
- 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"
- load "/nuist/scratch/Xiayang/regcm_output/work/picture/cnmap/cnmap.ncl"
- begin
- lines = new((/29,4/),"float")
-
- lines = asciiread("real_route.txt",(/29,4/),"float") ;以字符串形式读取参数文件入数组argu
- t = lines(:,0) ;从数组lines中获取时间
- lat = lines(:,1) ;从数组lines中获取经度值lon
- lon = lines(:,2) ;从数组lines中获取纬度值lat
- cslp = lines(:,3)
- times= flt2string(t)
- ;print(times)
- ;***************** DATES ******************************
- ndate = dimsizes(t)
-
- f = addfile("../wrfout_d02_2014-09-14_00:00:00.nc","r")
- lat2d = f->XLAT(0,:,:)
- lon2d = f->XLONG(0,:,:)
- times1 = wrf_user_getvar(f,"times",-1) ; get all times in the file
- print(times1)
- slp = wrf_user_getvar(f,"slp",-1)
- dims = dimsizes(slp(0,:,:))
- printVarSummary(slp)
- ; Array for track
- time = new(79,string)
- imin = new(79,integer)
- jmin = new(79,integer)
- smin = new(79,integer)
- slpmin = new(79,float)
- ;***************************
- ; ndate
- ; ***************************
- do ifs=0,78
- slp2d = wrf_user_getvar(f,"slp",ifs)
- ; We need to convert 2-D array to 1-D array to find the minima.
- slp1d = ndtooned(slp2d)
- smin(ifs) = minind(slp1d)
- slpmin(ifs)= min(slp1d)
- ; Convert the index for 1-D array back to the indeces for 2-D array.
- minij = ind_resolve(ind(slp1d.eq.min(slp2d)),dims)
- imin(ifs) = minij(0,0)
- jmin(ifs) = minij(0,1)
- end do
- ;***********************************************
- wks = gsn_open_wks("pdf","route2")
- gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
-
- res = True
- res@gsnDraw = False ; will panel later
- res@gsnFrame = False ; will panel later
- res@mpLimitMode = "LatLon"
- res@mpMinLatF = 12
- res@mpMaxLatF = 28
- res@mpMinLonF = 95
- res@mpMaxLonF = 125
- res@mpCenterLonF = 110
- res@gsnMajorLatSpacing= 4
- res@gsnMajorLonSpacing= 5
- res@gsnMinorLatSpacing= 2
- res@gsnMinorLonSpacing= 5
- res@tmXBLabelFontHeightF = 0.0175
- res@tmYLLabelFontHeightF = 0.0175
-
-
- ;res@gsnAddCyclic = False
- res@mpFillOn = False
- res@mpFillDrawOrder = "PreDraw"
- res@mpOutlineOn = True
- res@mpDataBaseVersion = "MediumRes"
- res@mpDataSetName = "Earth..4"
- ;res@mpAreaMaskingOn = True
- ;res@mpMaskAreaSpecifiers = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
- res@mpLandFillColor = -1
- res@mpInlandWaterFillColor = -1
- res@mpOceanFillColor = -1
- ;res@mpOutlineBoundarySets = "NoBoundaries"
- cnres = True
- cnres@china = True ;draw china map or not
- cnres@river = False ;draw changjiang&huanghe or not
- cnres@province = True ;draw province boundary or not
- cnres@nanhai = False ;draw nanhai or not
- cnres@diqu = False ; draw diqujie or not
- plot = gsn_csm_map_ce(wks,res)
- ;***********************************************
- ; 添加观测台风中心标示
- ;***********************************************
- txres = True
- txres@txFont = 137
- txres@txFontHeightF = 0.025
- txres@txFontThicknessF= 4.0
- txres@txFontColor = "black"
- do i = 10,28,4
- text=gsn_add_text(wks,plot,"p",lon(i),lat(i),txres)
- delete(text)
- end do
- text=gsn_add_text(wks,plot,"p",lon(28),lat(28),txres)
-
- ;************************************************
- ; add the Line
- ;************************************************
- resp = True ; polyline mods desired
- resp@gsLineColor = "black" ; color of lines
- resp@gsLineThicknessF = 5.0 ; thickness of lines
- resp@gsLineLabelString= ""
-
- gsn_polyline(wks,plot,lon(10:28),lat(10:28),resp)
- delete(resp)
-
-
- ;************************************************
- ; add the Time
- ;************************************************
- tres = True
- tres@txFont = 25
- tres@txFontHeightF = 0.0175
- tres@txFontThicknessF= 5
- do i = 10,28,4
- text=gsn_add_text(wks,plot,times(i),lon(i),lat(i)+1.8,tres)
- delete(text)
- end do
- text=gsn_add_text(wks,plot,times(28),lon(28)-1,lat(28)+1.8,tres)
- delete(text)
-
- ;************************************************
- ; add the (a)
- ;************************************************
- tres@txFontHeightF = 0.0225
- text=gsn_add_text(wks,plot,"(a)",96,27,tres)
- ;************************************************
- ; add the simulaton line
- ;************************************************
-
- resp = True ; polyline mods desired
- resp@gsLineColor = "red" ; color of lines
- resp@gsLineThicknessF = 5.0 ; thickness of lines
- resp@gsLineLabelString= ""
-
- tres@txFontHeightF = 0.02
- tres@txFontColor = "red"
- txres@txFontColor = "red"
- j=10
- do i = 24,77
- xx=(/lon2d(imin(i),jmin(i)),lon2d(imin(i+1),jmin(i+1))/)
- yy=(/lat2d(imin(i),jmin(i)),lat2d(imin(i+1),jmin(i+1))/)
- gsn_polyline(wks,plot,xx,yy,resp)
-
- if(.not.mod(i,12))then
- text1 = gsn_add_text(wks,plot,times(j),lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i))-2,tres)
-
- text2 = gsn_add_text(wks,plot,"p",lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i)),txres)
- j=j+4
- delete(text1)
- delete(text2)
- end if
- end do
- i = 78
- text1 = gsn_add_text(wks,plot,times(28),lon2d(imin(i),jmin(i))-1,lat2d(imin(i),jmin(i))-2,tres)
- text2 = gsn_add_text(wks,plot,"p",lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i)),txres)
- print(slpmin)
-
- write_table("simu_route.txt","w",[/times1(24),lat2d(imin(24),jmin(24)),lon2d(imin(24),jmin(24)),slp(24,imin(24),jmin(24))/],"%s %6.1f %6.1f %7.1f")
- do i=0,78,3
- write_table("simu_route.txt","a",[/times1(i),lat2d(imin(i),jmin(i)),lon2d(imin(i),jmin(i)),slp(i,imin(i),jmin(i))/],"%s %6.1f %6.1f %7.1f")
- end do
-
- ;************************************************
- ; add the China map
- ;************************************************
- chinamap = add_china_map(wks,plot,cnres)
- tres@txFontHeightF = 0.0165
- txres@txFontHeightF = 0.0172
- txres@txFontThicknessF= 3.0
- lgtext1 = gsn_add_text(wks,plot,"p",99,16,txres)
- lgtext11 = gsn_add_text(wks,plot,"Simulation",102,16,tres)
-
- txres@txFontColor = "black"
- tres@txFontColor = "black"
- lgtext2 = gsn_add_text(wks,plot,"p",99,14.3,txres)
- lgtext22 = gsn_add_text(wks,plot,"Observation",102.2,14.3,tres)
-
- draw(plot)
- frame(wks)
- end
复制代码 |
|