Hi,
I am trying to plot some data on a sphere and create a Delaunay
triangulation out of it and fill colors into each of the triangles using a
custom color map. Following code does a good job of creating the
triangulation: (ncl v. 6.1.2 in cygwin)
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
NARC = 50
jps = asciiread("illdt1.txt",(/101,4/),"float")
id_in = jps(1:100,0)
lat_in = jps(1:100,1)
lon_in = jps(1:100,2)
dt_in = jps(1:100,3)
N = 100
gsres = True
; Create the triangulation.
;
triangles = csstri(lat_in,lon_in)
tri_sizes = dimsizes(triangles)
num_triangles = tri_sizes(0)
cmap = (/ \
(/ 1., 1., 1. /), \
(/ 0., 0., 0. /), \
(/ 1., 0., 0. /), \
(/ 0., 0., 1. /), \
(/ 1., 0., 0. /), \
(/ 0., 1., 0. /), \
(/ 0., .8, 0. /), \
(/ .65, .65, .65 /) \
/)
NCGM=1
X11=0
PS=0
PDF=0
if (NCGM .eq. 1) then
wks = gsn_open_wks("ncgm","nm21n")
end if
if (X11 .eq. 1) then
wks = gsn_open_wks("x11","nm21n")
end if
if (PS .eq. 1) then
wks = gsn_open_wks("ps","nm21n")
end if
if (PDF .eq. 1) then
wks = gsn_open_wks("pdf","nm21n")
end if
gsn_define_colormap(wks,cmap)
;
; Draw a globe
;
map_resources = True
map_resources@gsnFrame = False
map_resources@mpOutlineBoundarySets = "National"
map_resources@mpNationalLineColor = 1
map_resources@mpGeophysicalLineColor = 7
map_resources@mpLimbLineColor = 7
map_resources@mpGridLineColor = 0
map_resources@mpGridAndLimbDrawOrder = "PreDraw"
map_resources@mpCenterLatF = 40.
map_resources@mpCenterLonF = -105.
map_resources@vpXF = 0.06
map_resources@vpYF = 0.90
map_resources@vpWidthF = 0.88
map_resources@vpHeightF = 0.88
map_resources@mpSatelliteDistF = 4.0
map_resources@mpGreatCircleLinesOn = True
map = gsn_map(wks,"Satellite",map_resources)
; Draw the triangles.
;Ignore the blue for now
qlat = new(4,float)
qlon = new(4,float)
gsres@gsLineColor = 5
do np=0,num_triangles-1
qlat(0) = lat_in(triangles(np,0))
qlon(0) = lon_in(triangles(np,0))
qlat(1) = lat_in(triangles(np,1))
qlon(1) = lon_in(triangles(np,1))
qlat(2) = lat_in(triangles(np,2))
qlon(2) = lon_in(triangles(np,2))
qlat(3) = lat_in(triangles(np,0))
qlon(3) = lon_in(triangles(np,0))
gsn_polyline(wks,map,qlon,qlat,gsres)
end do
end
However, is there a way to fill colors into the triangles created using
polylines? I didn't find any. So, I thought maybe I could give the end
points of triangles as an input to gsn_polygon. If that created the
triangles, that would have given me a full set of resources to modify,
including the fill colors. So, I replaced the blue part with the following
code:
qlat = new(3,float)
qlon = new(3,float)
gsres@gsEdgesOn = True
gsres@gsEdgeColor = 4
gsres@gsFillColor = False
do np=0,num_triangles-1
qlat(0) = lat_in(triangles(np,0))
qlon(0) = lon_in(triangles(np,0))
qlat(1) = lat_in(triangles(np,1))
qlon(1) = lon_in(triangles(np,1))
qlat(2) = lat_in(triangles(np,2))
qlon(2) = lon_in(triangles(np,2))
gsn_polygon(wks,map,qlon,qlat,gsres)
end do
But this doesn't even create all the triangles. So, is there a way to fix
this problem? I have attached the data I used for this (illdt1.txt).
Thank you,
Roshil
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.1.8 : Fri Jul 12 2013 - 16:37:39 MDT