Dear NCL Users:
I am using the sample application for trajectories (traj1-traj3.ncl). This shows how to plot trajectories.
What I was looking for was the same type of script but rather than just a line showing where a storm
center is going or a ship track is going. I wanted an arrow to mark the last point and the direction of
movement:
------x--------x-------> showing the track moving "east"
Probably could make a vector out of the last point in do it that way.
Does anyone know how to plot arrows at the end of a trajectory (included is the sample script that
I used in my application)?.
Mahalo,
Craig Motell
Joint Typhoon Warning Center
Honolulu
;*************************************************
; traj_2.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"
;**************************************************
begin
;*************************************
; read in data
;************************************
; note this trajectory file contains data in the form of
; 9 variables x 131 timesteps x 100 trajectories
ntime = 131
path= "/fs/cgd/home0/murphys/Tutorials/Csm_graphics/special_topics/traj/"
big = fbinrecread(path+"traj.bin",0,(/9,ntime,100/),"float")
time= fbinrecread(path+"traj.bin",1,(/ntime/),"float")
;********************************************
wks = gsn_open_wks("ps","traj") ; open workstation
;*********************************************
; color preps
;*********************************************
cnLevels=fspan(34.5,34.8,8)
cmap = RGBtoCmap ("/cgd/cas/murphys/Data/colormaps/redyellowblue.rgb")
gsn_define_colormap (wks,cmap)
res = True ; map resources
res_at_gsnDraw = False ; don't draw
res_at_gsnFrame = False ; don't advance frame
res_at_vpWidthF = 0.80 ; make map bigger
res_at_vpHeightF = 0.80
res_at_mpMaxLatF = -20 ; select subregion
res_at_mpMinLatF = -60
res_at_mpMinLonF = -75
res_at_mpMaxLonF = -25
; label bar resources
res_lb = True
res_lb_at_vpWidthF = 0.60
res_lb_at_vpHeightF = 0.10
res_lb_at_lbPerimOn = False ; Turn off perimeter.
res_lb_at_lbOrientation = "Horizontal" ; Default is vertical.
res_lb_at_lbLabelStride = 2
res_lb_at_lbLabelAlignment = "InteriorEdges" ; Default is "BoxCenters".
res_lb_at_lbFillColors = cmap(2:,:) ; Colors for boxes.
res_lb_at_lbMonoFillPattern = True ; Fill them all solid.
res_lb_at_lbLabelFontHeightF = 0.015
res_at_tiMainString = "Trajectories colored by salinity (ppt)" ; title
map = gsn_csm_map_ce(wks,res) ; create map
;*********************************************
; trajectory parameters
;*********************************************
xpt = new(ntime,float) ; allocate memory
ypt = new(ntime,float)
traj = (/1,10,53,67,80/) ; choose which trajectories to plot
;*********************************************
; some plot parameters
;*********************************************
pres = True ; polyline resources
pres_at_gsLineThicknessF = 2.0 ; line thickness
mres = True ; marker resources
first = True ; start of traj resources
;********************************
do i = 0,dimsizes(traj)-1 ; loop through chosen traj
ypt = big(2,:,traj(i)) ; extract lat from whole array
xpt = big(1,:,traj(i)) ; extract lon from whole array
sst = big(8,:,traj(i))
do j=0,dimsizes(ypt)-2
pres_at_gsLineColor=GetFillColor(cnLevels,cmap,avg( (/sst(j),sst(j+1)/)))
gsn_polyline(wks,map,(/xpt(j),xpt(j+1)/),(/ypt(j),ypt(j+1)/),pres)
end do
; create a unique marker to indicate the start of the trajectory
first_at_gsMarkerSizeF = 9.0 ; marker size
first_at_gsMarkerColor = "red" ; marker color
gsn_polymarker(wks,map,xpt(0),ypt(0),first) ; draw start of traj
delete(first_at_gsMarkerColor)
delete(first_at_gsMarkerSizeF)
end do
gsn_labelbar_ndc(wks,dimsizes(cnLevels)+1,cnLevels,0.30,0.30,res_lb)
draw(map)
frame(wks)
end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 23 2007 - 12:55:52 MDT
This archive was generated by hypermail 2.2.0 : Thu Apr 26 2007 - 08:55:37 MDT