- 积分
- 676
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-1-10
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2019-7-18 09:45:32
|
显示全部楼层
我这个问题应该不是另外低压的干扰,因为自己根据最小slp定的路径还比较符合,但移动网格中slp的值变化是不连续的,其实直接用ATCF画台风路径和强度变化很方便,我担心的是用wrf_user_getvar提取slp出错,会不会其他变量也出错呢?
附上自己提取最小slp定台风中心的脚本:
- begin
- ;**************read best track data**********************************************
- f0 ="/data/data1/xwang/Katrina/try_ncl/Katrina_track/best_track_Katrina(NHC).txt"
- btdata = asciiread(f0,-1,"string")
- ; length1 = dimsizes(data1)-1 ;Skip first row of "data1" because it's just a header line
- ; print(length1)
- lat0 = stringtofloat(str_get_field(btdata(1::), 5," ")) ;Use a space (" ") as a delimiter in str_get_field.
- lon0 = -stringtofloat(str_get_field(btdata(1::), 6," ")) ;The first field is field=1 (unlike str_get_cols, in which the first column is column=0).
- p0 = stringtofloat(str_get_field(btdata(1::), 8," ")) ; data(1::)----the second line to the last line(not sure)
- printVarSummary(lat0)
- ;*************read wrfout d01 data**************************************************
- a1 =addfile("/data/data1/xwang/WRF/WRF/test/em_real/wrfout2/wrfout_d01_2005-08-27_00:00:00","r")
- times = wrf_user_getvar(a1,"times",-1) ; get all times in the file
- nt = dimsizes(times) ; number of times in the file
- print(nt)
- lat1 = new(nt,float)
- lon1 = new(nt,float)
- do n=0,nt-1
- ps = wrf_user_getvar(a1,"slp",n)
- nps = dimsizes(ps) ; nps=(/*,*/),nps(0)---south_north(lat); nps(1)---west_east(lon)
- ; print(nps)
- psmin = ps(0,0)
- do i=0,nps(0)-1
- do j=0,nps(1)-1
- if(ps(i,j).lt.psmin)then
- psmin =ps(i,j)
- center_x=j
- center_y=i
- end if
- end do
- end do
- lat1(n) = a1->XLAT(n,center_y,center_x)
- lon1(n) = a1->XLONG(n,center_y,center_x)
- end do
- printVarSummary(lon1)
- delete([/times,nt,ps,nps,psmin,center_x,center_y/]) ;!!!Must exist! If not, the d02 reading will go wrong.
- ;*************read wrfout d02 data**************************************************
- a2 =addfile("/data/data1/xwang/WRF/WRF/test/em_real/wrfout2/wrfout_d02_2005-08-27_00:00:00","r")
- times = wrf_user_getvar(a2,"times",-1) ; get all times in the file
- nt = dimsizes(times) ; number of times in the file
- print(nt)
- lat2 = new(nt,float)
- lon2 = new(nt,float)
- do n=0,nt-1
- ps = wrf_user_getvar(a2,"slp",n)
- nps = dimsizes(ps) ; nps=(/*,*/),nps(0)---south_north(lat); nps(1)---west_east(lon)
- ; print(nps)
- psmin = ps(0,0)
- do i=0,nps(0)-1
- do j=0,nps(1)-1
- if(ps(i,j).lt.psmin)then
- psmin =ps(i,j)
- center_x=j
- center_y=i
- end if
- end do
- end do
- lat2(n) = a2->XLAT(n,center_y,center_x)
- lon2(n) = a2->XLONG(n,center_y,center_x)
- end do
- printVarSummary(lon2)
- ;***************plot Katrina track*****************************
- wks = gsn_open_wks("png","Katrina_track(wrfout)") ; send graphics to PNG file
- res = True
- res@gsnDraw = False ; don't draw
- res@gsnFrame = False ; don't advance frame
- res@gsnMaximize = True
- res@mpGridLineDashPattern = 1 ; lat/lon lines dashed
- res@mpGridLatSpacingF = 5
- res@mpGridLonSpacingF = 5
- res@mpGridAndLimbDrawOrder = "Postdraw" ; Draw grid first
- res@mpGridLineColor = "black"
- res@mpGridMaskMode = "MaskLand"
- res@mpDataBaseVersion = "MediumRes" ; better and more map outlines
- res@mpDataSetName = "Earth..4"
- res@mpOutlineBoundarySets = "AllBoundaries"
- res@mpOutlineOn = True
- res@mpGeophysicalLineThicknessF = 2.
- res@mpNationalLineThicknessF = 2.
- res@mpFillOn = False
- res@mpPerimOn = True
- ;res@mpOutlineBoundarySets = "GeophysicalAndUSStates"
- res@pmTickMarkDisplayMode = "Always"
- res@mpLimitMode = "LatLon" ; select subregion
- res@mpMinLatF = 20
- res@mpMaxLatF = 45
- res@mpMinLonF = -100
- res@mpMaxLonF = -70
- res@tmYROn = False ; turn off right and top tickmarks
- res@tmXTOn = False
- res@tiMainString = "Katrina track" ; title
- res@tiMainFontHeightF = 0.02
- map = gsn_csm_map(wks,res) ; create map
- ; Set up some legend resources.
- lgres = True
- lgres@lgLineColors = (/"black","red","blue"/)
- lgres@lgLineThicknessF = 4.
- lgres@lgLabelFontHeightF = .08 ; set the legend label font thickness
- lgres@vpWidthF = 0.15 ; width of legend (NDC)
- lgres@vpHeightF = 0.15 ; height of legend (NDC)
- lgres@lgMonoDashIndex = True
- lgres@lgPerimColor = "black" ; draw the box perimeter in orange
- lgres@lgPerimThicknessF = 3.0 ; thicken the box perimeter
- labels = (/"best_track","wrfout_d01","wrfout_d02"/)
- ; ; Set up some legend resources.
- ; lgres = True
- ; lgres@lgLineColors = (/"black","red"/)
- ; lgres@lgLineThicknessF = 4.
- ; lgres@lgLabelFontHeightF = .08 ; set the legend label font thickness
- ; lgres@vpWidthF = 0.15 ; width of legend (NDC)
- ; lgres@vpHeightF = 0.15 ; height of legend (NDC)
- ; lgres@lgMonoDashIndex = True
- ; lgres@lgPerimColor = "black" ; draw the box perimeter in orange
- ; lgres@lgPerimThicknessF = 3.0 ; thicken the box perimeter
- ; labels = (/"best_track","wrfout_d01"/)
- ; Create the legend.
- lbid = gsn_create_legend(wks,3,labels,lgres) ; create legend
- ; Set up resources to attach legend to map.
- amres = True
- amres@amParallelPosF = 0.4 ; positive move legend to the right
- amres@amOrthogonalPosF = -0.32 ; positive move the legend down
- annoid1 = gsn_add_annotation(map,lbid,amres) ; attach legend to plot
-
- ; Add text of every 6 hours
- ; txres = True
- ; txres@txFontHeightF = 0.015
- ; txres@txFontColor = "black"
- ; text1 = gsn_add_text(wks,map,"06",xp(0,0)+0.1,yp(0,0)+0.1,txres)
- ; text2 = gsn_add_text(wks,map,"12",xp(0,1)+0.15,yp(0,1),txres)
- ; text3 = gsn_add_text(wks,map,"18",xp(0,2)+0.15,yp(0,2),txres)
- ; text4 = gsn_add_text(wks,map,"00",xp(0,3), yp(0,3)+0.1,txres)
- ; Add trajectory lines.
- pres = True ; polyline resources
- pres@gsLineThicknessF = 6.0 ; line thickness
- pres@gsLineColor = "black"
- line0 = gsn_add_polyline(wks,map,lon0(:),lat0(:),pres) ; draw the traj
- pres = True ; polyline resources
- pres@gsLineColor = "red"
- line1 = gsn_add_polyline(wks,map,lon1(:),lat1(:),pres) ; draw the traj
- pres = True ; polyline resources
- pres@gsLineColor = "blue"
- line2 = gsn_add_polyline(wks,map,lon2(:),lat2(:),pres) ; draw the traj
- ; ; Add markers to the trajectories.
- ; mres0 = True ; marker resources for best track
- ; mres0@gsMarkerIndex = 16 ; marker style (filled circle)
- ; mres0@gsMarkerSizeF = 8.0 ; marker size
- ; mres0@gsMarkerColor = "black" ; maker color
- ; markers0=gsn_add_polymarker(wks,map,lon0(:),lat0(:),mres0)
- ; mres1 = True ; marker resources for best track
- ; mres1@gsMarkerIndex = 16 ; marker style (filled circle)
- ; mres1@gsMarkerSizeF = 8.0 ; marker size
- ; mres1@gsMarkerColor = "red" ; maker color
- ; markers1=gsn_add_polymarker(wks,map,lon1(:),lat1(:),mres1)
- ; mres2 = True ; marker resources for best track
- ; mres2@gsMarkerIndex = 16 ; marker style (filled circle)
- ; mres2@gsMarkerSizeF = 8.0 ; marker size
- ; mres2@gsMarkerColor = "blue" ; maker color
- ; markers2=gsn_add_polymarker(wks,map,lon2(:),lat2(:),mres2)
- draw(map)
- frame(wks)
-
- end
复制代码
以及画最小slp及最大风速随时间变化的脚本:
- ;*************read min slp and max surface wind from wrfout_d03* data**************************************************
- diri1 ="/data/data1/xwang/WRF/WRF/test/em_real/wrfout/"
- fs1 =systemfunc(" ls "+diri1+"wrfout_d03* ")
- inputfiles =addfiles(fs1,"r")
- x =new(40,integer)
- do i = 0, 39
- x(i) =i+1
- end do
- allt =new(40,string)
- minslp = new(40,float)
- maxwnd = new(40,float)
- do ifile = 0,4 ; not contain "wrfout_d03_2005-09-01"
- a1 = inputfiles[ifile]
- ; times = wrf_user_getvar(a1,"times",-1) ; get all times in the file. No attributes of variables in wrfout*.nc
- ; nt = dimsizes(times) ; number of times in the file
-
- ; ;____wrfout*.nc中变量的time该coordinate并无赋值--> 该方法不可取!_____________________
- ; slp = wrf_user_getvar(a1,"slp",-1)
- ; printVarSummary(slp)
- ; times = slp&time ; get time information(type:float)
- ; nt = dimsizes(times) ; number of times in the file
- ;____________________________________________________________________________________
-
- ;____读取wrfout*.nc中的times,格式为string,不能直接作为坐标轴变量,需与numeric values(如x)配合作为坐标___________
- times_in_file = wrf_user_list_times(a1) ;!!!Get time information (type:string, 2005-08-27_00:00:00)
- day = str_get_cols(times_in_file,8,9) ;Strip out the day
- hour = str_get_cols(times_in_file,11,12) ;Strip out the hour
- times =(/hour+"/"+day/)
- printVarSummary(times)
- print(times)
- nt = dimsizes(times) ; number of times in the file
-
- ;__Available in version 6.4.0 and later________________________________________________
- ; instring = "time"
- ; format = "%D_%H"
- ; times = cd_inv_string(instring, format)
- ;______________________________________________________________________________________
- mslp = new(nt,float)
- mwnd = new(nt,float)
- do n=0,nt-1
- slp = wrf_user_getvar(a1,"slp",n)
- mslp(n) = min(slp)
- u10 = wrf_user_getvar(a1,"U10",n) ; u at 10 m, mass point
- v10 = wrf_user_getvar(a1,"V10",n) ; v at 10 m, mass point
- wnd = sqrt(u10^2+v10^2)/0.5144 ;compute and convert to 'knot' units
- mwnd(n) = max(wnd)
- end do
-
- istrt =ifile*nt
- iend =(ifile+1)*nt-1
- allt(istrt:iend) =times(:)
- minslp(istrt:iend) =mslp(:)
- maxwnd(istrt:iend) =mwnd(:)
- end do
- printVarSummary(allt)
- print(allt)
- printVarSummary(minslp)
- printVarSummary(maxwnd)
- ;***************plot*****************************
- wks = gsn_open_wks("png","Minimum_SLP") ; send graphics to PNG file
- res = True
- ;---Titles
- res@tiMainString = "Minimum SLP of Katrina"
- res@tiMainFontHeightF = 0.02
- res@tiYAxisFontHeightF = 0.02
- res@tiXAxisString = "Time/Date (UTC)"
- res@tiYAxisString = "Minimum SLP (hPa)"
- ;---TickMark
- res@tmXBMode = "Explicit" ; Define own tick mark labels. "Automatic","Mannual","Explicit"
- res@tmXBValues = x(0:39:8) ; location of explicit labels(x轴实际变量). "Explicit"
- res@tmXBLabels = allt(0:39:8) ; labels are the locations(x轴显示的坐标). "Explicit"
- res@tmLabelAutoStride = True ; control the step automatically
- res@tmXTOn = False ; turn off the top tick marks
- res@xyLineThicknesses = 2 ; increase line thickness
- res@xyLineColor = "blue" ; set line color
- plot = gsn_csm_xy (wks,x(:),minslp(:),res) ; create plot
- delete([/wks,res/])
- ;__________________________________________________
- wks = gsn_open_wks("png","Maximum_surfacewnd") ; send graphics to PNG file
- res = True
- ;---Titles
- res@tiMainString = "Maximum Surface Wind of Katrina"
- res@tiMainFontHeightF = 0.02
- res@tiYAxisFontHeightF = 0.02
- res@tiXAxisString = "Time/Date (UTC)"
- res@tiYAxisString = "Minimum SLP (hPa)"
- res@tmXBMode = "Explicit" ; Define own tick mark labels.
- res@tmXBValues = x(0:39:8) ; location of explicit labels(x轴实际变量)
- res@tmXBLabels = allt(0:39:8) ; labels are the locations(x轴显示的坐标)
- res@tmXTOn = False ; turn off the top tick marks
- res@xyLineThicknesses = 2 ; increase line thickness
- res@xyLineColor = "red" ; set line color
- plot = gsn_csm_xy (wks,x(:),maxwnd(:),res) ; create plot
-
-
- end
复制代码 |
|