From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>

Date: Mon Jul 08 2013 - 12:34:10 MDT

Received on Mon Jul 8 12:34:20 2013

Date: Mon Jul 08 2013 - 12:34:10 MDT

Hi Roshil,

This is a rather complicated issue. First off, you are setting

gsFillColor = False, when you should be setting it to a color index or

color name.

See:

http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml#gsFillColor

Second, according to a search I did on the NCL web page, it's better to

have your input longitude coordinates to be in the 0:360 range, EXCEPT

when your coordinates cross the prime meridian where they should range

from -180:180. You will see where statement coding in the attached

script to account for this.

Third, there are two triangles that you are trying to draw that are

rather large. Here are their coordinates:

(0) (40.719,245.982) (45.591,237.4) (-37.733,145.4) (40.719,245.982)

(0) (40.719,245.982) (-37.733,145.4) (-13.533,288.067) (40.719,245.982)

These 2 triangles are large enough that they are causing NCL to color

fill outside the triangles instead of inside. I am not sure how to get

NCL to fill inside those two triangles as opposed to outside. Someone

else will need to answer that.

Finally, I used gsn_add_polygon due to personal preference. In this case

it automatically switched the drawing of the continental outlines to be

drawn last, which I assume you prefer.

I have attached a script and the example graphic.

Good luck,

Adam

On 7/8/13 9:38 AM, Roshil Paudyal wrote:

*> Hi,
*

*>
*

*> Thank you for your reply.
*

*> I tried that but it still doesn't solve the problem. Using polyline
*

*> gives good results; so I don't think there is anything wrong in the
*

*> rest of the code. The problem must lie somewhere in executing the
*

*> gsn_polygon function.
*

*>
*

*> It would be great if you could run this script once, which may make
*

*> the problem clearer. It does give some output; but that is very
*

*> different from what is expected (or what polyline gives). I have
*

*> already attached the only datafile I used (illdt1).
*

*>
*

*> Thank you,
*

*> Roshil
*

*>
*

*> On Mon, Jul 8, 2013 at 10:38 AM, Adam Phillips <asphilli@ucar.edu
*

*> <mailto:asphilli@ucar.edu>> wrote:
*

*>
*

*> Hi Roshil,
*

*> I believe you have to enclose a complete polygon for gsn_polygon
*

*> to work. In other words, the first and last latitude/longitude
*

*> points are usually the same. Also, you need to make sure that you
*

*> are advancing the frame at the end of your script.
*

*>
*

*> Try changing this:
*

*>
*

*> 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
*

*>
*

*> to this:
*

*>
*

*> qlat = new(4,float)
*

*> qlon = new(4,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))
*

*> qlat(3) = qlat(0)
*

*> qlon(3) = qlon(0)
*

*> gsn_polygon(wks,map,qlon,qlat,gsres)
*

*> end do
*

*> frame(wks)
*

*>
*

*>
*

*> If that does not solve the problem, please respond to ncl-talk to
*

*> let everyone know.
*

*> Adam
*

*>
*

*>
*

*> On 07/07/2013 11:31 AM, Roshil Paudyal wrote:
*

*>> 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
*

*>
*

*> --
*

*> ______________________________________________________________
*

*> Adam Phillipsasphilli@ucar.edu <mailto:asphilli@ucar.edu>
*

*> NCAR/Climate and Global Dynamics Division(303) 497-1726 <tel:%28303%29%20497-1726>
*

*> P.O. Box 3000
*

*> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
*

*>
*

*>
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

- text/plain attachment: script1.ncl

*
This archive was generated by hypermail 2.1.8
: Fri Jul 12 2013 - 16:37:39 MDT
*