- 积分
- 242
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2022-2-27
- 最后登录
- 1970-1-1
|
发表于 2022-12-14 09:55:50
|
显示全部楼层
单独看这一部分好像没有错,我也是这样写的。
opt = True ; Background options
;opt@gsnMaximize = True ; make large
opt@tiMainString = pltTitle
plMark = True ; poly marker
plMark@gsMarkerIndex = 16 ; solid circle
plMark@gsMarkerSizeF = 0.005
plMark@gsMarkerThicknessF = 1
plLine = True ; line segments
plLine@gsLineThicknessF = 1.0 ; 1.0 is default
txres = True
txres@txFontHeightF = 0.010 ; size of font for printed day
namMonth = (/ "Jan","Feb","Mar","Apr","May","June" \
,"July","Aug","Sep","Oct","Nov","Dec" /)
colMonth = (/12,20,5,6,7,8,10,11,12,13,18,20/) ; indices into color table
imon = floattoint( ymdmon ) ; convenience
iday = floattoint( ymdday ) ; sunscripts must be integer
pltPath = pltDir+pltName
if (.not.pltMovie) then
wks = gsn_open_wks(pltType, pltPath) ; open workstation
gsn_define_colormap(wks,"radar_1")
end if
plot = mjo_phase_background(wks, opt) ; generic phase space background
xBegin= pc1(0) ; need for start of the line
yBegin= pc2(0)
plMark@gsMarkerColor = "black" ; indicate initial point
plMark@gsMarkerSizeF = 2.5*plMark@gsMarkerSizeF ; make larger
plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, yBegin, plMark)
plMark@gsMarkerSizeF = plMark@gsMarkerSizeF/2.5 ; reset
nMon = 0
monInfo = new ((/12,2/),"string")
monInfo(nMon,0) = namMonth(imon(0)-1)
monInfo(nMon,1) = colMonth(imon(0)-1)
label_opt = 5 ; label every # day 0 = don't label days
label_color = True ; draw month label with its proper color
do nt=1,ntim-2
if (pltMovie) then
ext = "_"+sprinti("%4.0i", nt )
wks = gsn_open_wks(pltType,pltName+ext)
gsn_define_colormap(wks,"radar_1")
end if
; color changes w month
plLine@gsLineColor = colMonth(imon(nt)-1) ; -1 is cuz NCL is 0-based
plot@$unique_string("dum")$ = gsn_add_polyline(wks, plot, (/xBegin,pc1(nt)/), (/yBegin,pc2(nt)/), plLine)
xBegin= pc1(nt)
yBegin= pc2(nt)
if (label_opt.eq.0) then
plMark@gsMarkerColor = plLine@gsLineColor ; same as line color
plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, yBegin, plMark)
else
if (mod(iday(nt),label_opt).eq.0) then
txres@txFontColor = "black"
plot@$unique_string("dum")$ = gsn_add_text(wks, plot, iday(nt)+"", xBegin, yBegin, txres)
print(iday(nt)+" "+xBegin+" "+yBegin)
else ; marker only
plMark@gsMarkerColor = plLine@gsLineColor ; same as line color
plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, yBegin, plMark)
print(iday(nt)+" "+xBegin+" "+yBegin)
end if
end if
if (iday(nt).eq.1) then
nMon = nMon+1
monInfo(nMon,0) = namMonth(imon(nt)-1)
monInfo(nMon,1) = colMonth(imon(nt)-1)
end if
if (pltMovie) then
draw(plot)
frame(wks)
end if
end do
xBegin= pc1(nt)
yBegin= pc2(nt)
plMark@gsMarkerColor = "black" ; indicate last point
plMark@gsMarkerSizeF = 2.5*plMark@gsMarkerSizeF ; make larger
plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, yBegin, plMark)
if (.not.pltMovie) then
if (label_color) then ; fancy coloring of months
getvalues plot
"trXMinF" : xmin
end getvalues
xinc = (xmin*-2) / (nMon+1+2.) ; total number months = nMon+1. +2
; for spacing on ends
txres@txJust = "CenterLeft"
txres@txFontHeightF = 0.013 ; size of font for printed month
xstart = xmin+(1.25*xinc)
if (nMon.gt.0) then
do n=0, nMon
txres@txFontColor = monInfo(n,1)
plot@$unique_string("dum")$ = gsn_add_text(wks, plot, monInfo(n,0) ,xstart , -3.75, txres)
xstart = xstart+xinc
end do
end if
end if
draw(plot)
frame(wks)
if (pltType.eq."png") then
if (isatt(opt,"pltConvert")) then
pltConvert = opt@pltConvert ; convert options
else
pltConvert = "-trim +repage -border 8 -bordercolor white"
end if
system("convert "+pltConvert+" "+pltPath+".png "+pltPath+".png")
end if
end if |
|