Re: problem with TRIANGULATION option in CONTOUR [message #73048] |
Sat, 23 October 2010 16:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ben Tupper writes:
> You might consider running the points through GRID_INPUT first. I
> really have no idea if that will help in this case, but it often comes
> to the rescue when interpolating.
Yes, that's a good suggestion.
Or, I would try just gridding the data with Triangulate
and Trigrid, and pass the gridded data to Contour.
In other words, don't try to use the TRIANGULATION
keyword. (I have to admit, I had never heard of this
keyword!)
Here are the commands I use to grid irregular data
from a book that will be hot of the press in a month
or so. I get the X and Y vectors that go with the
gridded data from the XGRID and YGRID output
keywords to TriGrid.
Triangulate, lonIrr, latIrr, triangles
gridData = Trigrid(lonIrr, latIrr, dataIrr, $
triangles, NX=41, NY=41, $
XGrid=xgrid, YGrid=ygrid)
Contour, gridData, xgrid, ygrid, /Cell_Fill, $
Levels=levels, Background=FSC_Color('white'),$
Position=[0.125, 0.125, 0.95, 0.80], $
Color=FSC_Color('black'), XStyle=1, YStyle=1, $
C_Colors=Indgen(nlevels)+1
Cheers,
David
P.S. If you want to send the data, I'm always looking
for perverse examples to add to the book! :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: problem with TRIANGULATION option in CONTOUR [message #73049 is a reply to message #73048] |
Sat, 23 October 2010 15:52   |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On 10/23/10 8:35 AM, Ardhuin wrote:
> Dear all,
> I have been having problems with plotting output of a numerical model
> that uses unstructured grids using IDL: this model computes wave
> heights in the ocean. If I use the set of triangles from the model, I
> get really funny errors:
> Out of range subscript encountered:<LONG Array[66453]>.
> although I only have 9626 points and about 16000 triangles.
>
> The command I use is
> CONTOUR,tablep,x,y,$
> xstyle=5,ystyle=5,/FOLLOW,/CELL_FILL, TRIANGULATION=tri,
> $
> C_COLOR=colorind(0:c_numlev-2+addmini+addmaxi), $
> LEVELS=lev,/
> NOERASE,TITLE=title,CLIP=[rangex(0),rangey(0),rangex(1),rang ey(1)], $
> XRANGE=rangex,YRANGE=rangey,MAX_VALUE=maxval, $
> POSITION=[blx*winx/mwinx,bly*winy/mwiny,trx*winx/
> mwinx,try*winy/mwiny]
>
> Where tablep , x and y
> If I first do TRIANGULATE,X,Y,tri then the contours comes out OK...
> but they cut out through land boundaries and islands.
>
> So I was thinking: my triangles must be wrong ...
> but if I do a TRIGRID with my triangles then I can plot nicely with
> TV ...
> array=trigrid(X,Y,tablep,tri,[dx,dy],
> [rangex(0),rangey(0),rangex(1),rangey(1)], $
> MAX_VALUE=maxval)
>
> So my triangles are OK for TRIGRID but not for CONTOUR... How is that
> possible ??
>
Hi,
You might consider running the points through GRID_INPUT first. I
really have no idea if that will help in this case, but it often comes
to the rescue when interpolating.
Cheers,
Ben
|
|
|
Re: problem with TRIANGULATION option in CONTOUR [message #73050 is a reply to message #73049] |
Sat, 23 October 2010 15:00   |
Ardhuin
Messages: 5 Registered: October 2010
|
Junior Member |
|
|
Yes, the CLIP was useless, but even simplifying the command to
CONTOUR,tablep,x,y,$
xstyle=5,ystyle=5,/FOLLOW,/CELL_FILL, TRIANGULATION=tri, $
C_COLOR=colorind(0:c_numlev-2+addmini+addmaxi), $
LEVELS=lev,/
XRANGE=rangex,YRANGE=rangey, $
POSITION=[blx*winx/mwinx,bly*winy/mwiny,trx*winx/
mwinx,try*winy/mwiny]
I do get the same error...
Fabrice Ardhuin
|
|
|
|
|