CONTOUR problem [message #7115] |
Tue, 01 October 1996 00:00  |
Reginald Tang
Messages: 1 Registered: October 1996
|
Junior Member |
|
|
Hello,
I would appreciate helpful suggestions to a problem i've been having
with plotting contour lines in IDL.
I am plotting over a stereographic projection of the Northern hemisphere
centered on the North Pole and I am getting a weird "jump" of all levels
of the contour lines towards the pole around latitude -10 degrees. My
plot looks a bit like a pie-chart with a 10-degree slice taken out of
it. Otherwise, the plot is perfectly acceptable (as compared with output
using DISPLAA). I use the following statement:
CONTOUR, H, LON, LAT
where H is height data to be contoured and is a 36x16 array and LON is a
36-vector containing the longitude lines going from 0 to 180 and -170 to
-10. LAT is a 16-vector going from 90 (North pole) to 0 (Equator).
There are only 455 data points to be plotted, and their positions are
concentric and regularly spaced wrt longitude and latitude. however,
data from latitude 90 to 66 are spaced 20 degrees apart in longitude, as
opposed to 10 at lower latitudes than 66.
I've tried giving H, LON and LAT as three arrays of the same dimensions
to CONTOUR (an alternative suggested in the Reference) but this
inexplicably gave me a chaotic mess. A colleague and I have checked and
double-checked the contents of the parameters to make sure they are OK.
Any help, hints or clarifying questions will be appreciated. I hope it's
not a bug in IDL but just something i overlooked!
Reg
------------------
Environment Canada
4905 Dufferin
Downsview, Ontario
M3H 5T4
(416)739-4711
|
|
|
Re: Contour Problem [message #39072 is a reply to message #7115] |
Mon, 26 April 2004 06:22   |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Christopher Lee wrote:
> On Fri, 23 Apr 2004 17:11:11 -0500, Jeff Patrick wrote:
>
>
>> I keep getting the following error in my code and I can't figure out why.
>> Any help would be appreciated.
>>
>> % Internal error: Triangulation is invalid.
>>
>
> There are identical points in the data, triangulate works (in a fluffy,
> wordy kind of way) by drawing circles which have the points on the
> circumference. If the points are identical, it can't work. (This would be
> my guess).
>
> There are colinear points which otherwise satisfy the Delauney
> Triangulation algorithm, (good luck finding these). The triangle will be
> 'flat', i.e not a triangle. If this is going to happen, it would most
> likely happen on the first three points, which are needed to bootstrap the
> algorithm.
>
Hello,
The GRID_INPUT (IDL 5.5+) can be used to fish out the duplicate data
triplets before the call to TRIANGULATE. See the DUPLICATES keywprd to
GRID_INPUT.
Ben
|
|
|
Re: Contour Problem [message #39078 is a reply to message #7115] |
Sat, 24 April 2004 04:39   |
Christopher Lee
Messages: 4 Registered: February 2001
|
Junior Member |
|
|
On Fri, 23 Apr 2004 17:11:11 -0500, Jeff Patrick wrote:
> I keep getting the following error in my code and I can't figure out why.
> Any help would be appreciated.
>
> % Internal error: Triangulation is invalid.
>
> CONTOUR, X, Y, Z, IRREGULAR=1, ISOTROPIC=1, /CLOSED, /CELL_FILL, /OVERPLOT,
> .....
> each array is 32400 in size.
>
> Thank you,
>
> Jeff
> jeff.patrick@computer.org
Your getting the error because the contour function calls the triangulate
function internally, which throws an error on your data. If you can
separate the data from the Widget program, do it :) (save it to a file).
Then run TRIANGULATE on the data, if that throws an error, it probably
will, something is wrong with the data. e.g
There are identical points in the data, triangulate works (in a fluffy,
wordy kind of way) by drawing circles which have the points on the
circumference. If the points are identical, it can't work. (This would be
my guess).
There are colinear points which otherwise satisfy the Delauney
Triangulation algorithm, (good luck finding these). The triangle will be
'flat', i.e not a triangle. If this is going to happen, it would most
likely happen on the first three points, which are needed to bootstrap the
algorithm.
Chris.
|
|
|
|
Re: Contour Problem [message #39217 is a reply to message #39078] |
Mon, 26 April 2004 09:04   |
Jeff Patrick
Messages: 4 Registered: April 2004
|
Junior Member |
|
|
I've checked the latitude and longitude and do not see any duplicate data,
so I guess my next question is what data type (int, single, double, etc.) is
Contour looking for? I could see that it may think there is duplicate data
if it is rounding the values I'm sending it. Also does Contour use the
value stored in the zero (0) index of the array (it seems that other IDL
function may not)?
Thanks for the help on this,
Jeff
"Christopher Lee" <lc@127.0.0.1> wrote in message
news:pan.2004.04.24.11.39.58.346601@127.0.0.1...
> On Fri, 23 Apr 2004 17:11:11 -0500, Jeff Patrick wrote:
>
>> I keep getting the following error in my code and I can't figure out
why.
>> Any help would be appreciated.
>>
>> % Internal error: Triangulation is invalid.
>>
>> CONTOUR, X, Y, Z, IRREGULAR=1, ISOTROPIC=1, /CLOSED, /CELL_FILL,
/OVERPLOT,
>> .....
>> each array is 32400 in size.
>>
>> Thank you,
>>
>> Jeff
>> jeff.patrick@computer.org
>
> Your getting the error because the contour function calls the triangulate
> function internally, which throws an error on your data. If you can
> separate the data from the Widget program, do it :) (save it to a file).
>
> Then run TRIANGULATE on the data, if that throws an error, it probably
> will, something is wrong with the data. e.g
>
> There are identical points in the data, triangulate works (in a fluffy,
> wordy kind of way) by drawing circles which have the points on the
> circumference. If the points are identical, it can't work. (This would be
> my guess).
>
> There are colinear points which otherwise satisfy the Delauney
> Triangulation algorithm, (good luck finding these). The triangle will be
> 'flat', i.e not a triangle. If this is going to happen, it would most
> likely happen on the first three points, which are needed to bootstrap the
> algorithm.
>
> Chris.
|
|
|
Re: CONTOUR problem [message #62121 is a reply to message #7115] |
Wed, 27 August 2008 07:09   |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Aug 27, 9:02 am, xiao <littledd...@gmail.com> wrote:
> On Aug 27, 3:06 am, Wox <nom...@hotmail.com> wrote:
>
>
>
>> On Tue, 26 Aug 2008 16:21:05 -0700 (PDT), xiao <littledd...@gmail.com>
>> wrote:
>
>>> HI~ everyone~ i use the contour pro to display a 2Darray named s11.
>>> And I wrote it like this:
>
>>> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],ytitl e='Viewing
>>> zenith angle',xtitle='Relative azimuth angle',/C_LABELS
>
>>> But the xrange and yrange do not work and it only labeled on line in
>>> the image , Any one see where the problem is ?
>
>>> Thank you very much~
>
>> nlevels=5
>> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],xstyl e=1,ystyle=1,ytitle='Viewing
>> zenith angle',xtitle='Relative azimuth
>> angle',C_LABELS=replicate(1,nlevels)
>
>> To know how many levels there are (nlevels), you must set the LEVELS
>> keyword yourself., otherwise make nlevels big enough.
>
> Thanks , it works. but the xrange still does not work......
Btw, how can I set the intervals of the contour ?
thanx
|
|
|
Re: CONTOUR problem [message #62122 is a reply to message #7115] |
Wed, 27 August 2008 07:02   |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Aug 27, 3:06 am, Wox <nom...@hotmail.com> wrote:
> On Tue, 26 Aug 2008 16:21:05 -0700 (PDT), xiao <littledd...@gmail.com>
> wrote:
>
>> HI~ everyone~ i use the contour pro to display a 2Darray named s11.
>> And I wrote it like this:
>
>> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],ytitl e='Viewing
>> zenith angle',xtitle='Relative azimuth angle',/C_LABELS
>
>> But the xrange and yrange do not work and it only labeled on line in
>> the image , Any one see where the problem is ?
>
>> Thank you very much~
>
> nlevels=5
> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],xstyl e=1,ystyle=1,ytitle='Viewing
> zenith angle',xtitle='Relative azimuth
> angle',C_LABELS=replicate(1,nlevels)
>
> To know how many levels there are (nlevels), you must set the LEVELS
> keyword yourself., otherwise make nlevels big enough.
Thanks , it works. but the xrange still does not work......
|
|
|
Re: CONTOUR problem [message #62128 is a reply to message #7115] |
Wed, 27 August 2008 01:06   |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On Tue, 26 Aug 2008 16:21:05 -0700 (PDT), xiao <littledddna@gmail.com>
wrote:
> HI~ everyone~ i use the contour pro to display a 2Darray named s11.
> And I wrote it like this:
>
> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],ytitl e='Viewing
> zenith angle',xtitle='Relative azimuth angle',/C_LABELS
>
> But the xrange and yrange do not work and it only labeled on line in
> the image , Any one see where the problem is ?
>
> Thank you very much~
nlevels=5
CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],xstyl e=1,ystyle=1,ytitle='Viewing
zenith angle',xtitle='Relative azimuth
angle',C_LABELS=replicate(1,nlevels)
To know how many levels there are (nlevels), you must set the LEVELS
keyword yourself., otherwise make nlevels big enough.
|
|
|
Re: CONTOUR problem [message #62210 is a reply to message #7115] |
Wed, 27 August 2008 08:02   |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Aug 27, 10:00 am, Wox <nom...@hotmail.com> wrote:
> On Wed, 27 Aug 2008 07:41:23 -0700 (PDT), xiao <littledd...@gmail.com>
> wrote:
>
>> Sorry, another question....why i always get red as the back ground
>> color when i use this statement?
>
>> !P.background=255 i thought it should be white.... :(
>
> The quick answer would be:
>
> device,decomposed=0
> !P.background=255
> CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],color =0,xstyle=1,ystyle=1,ytitle='Viewing
> zenith angle',xtitle='Relative azimuth angle',C_LABELS=replicate(1,10)
>
> => note the xstyle,ystyle and color keywords
THanks~ I got it ~ :)
|
|
|
Re: CONTOUR problem [message #62211 is a reply to message #7115] |
Wed, 27 August 2008 08:00   |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On Wed, 27 Aug 2008 07:41:23 -0700 (PDT), xiao <littledddna@gmail.com>
wrote:
> Sorry, another question....why i always get red as the back ground
> color when i use this statement?
>
> !P.background=255 i thought it should be white.... :(
The quick answer would be:
device,decomposed=0
!P.background=255
CONTOUR,s11,rangle,vangle,xrange=[0,180],yrange=[0,90],color =0,xstyle=1,ystyle=1,ytitle='Viewing
zenith angle',xtitle='Relative azimuth angle',C_LABELS=replicate(1,10)
=> note the xstyle,ystyle and color keywords
|
|
|
|
Re: CONTOUR problem [message #62214 is a reply to message #7115] |
Wed, 27 August 2008 07:41   |
xiao zhang
Messages: 81 Registered: June 2008
|
Member |
|
|
On Aug 27, 9:16 am, xiao <littledd...@gmail.com> wrote:
> On Aug 27, 9:14 am, David Fanning <n...@dfanning.com> wrote:
>
>> xiao writes:
>>> Btw, how can I set the intervals of the contour ?
>
>> http://www.dfanning.com/tips/nlevels.html
>
>> Cheers,
>
>> David
>> --
>> 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.")
>
> Thank you ,David :)
Sorry, another question....why i always get red as the back ground
color when i use this statement?
!P.background=255 i thought it should be white.... :(
|
|
|
|
|
|
Re: Contour Problem [message #77036 is a reply to message #7115] |
Mon, 25 July 2011 11:13  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Alexa writes:
> I think this is probably a pretty easy problem but I could get help
> that'd be great.
>
> I'm making a contour plot and and I want to change the values of the
> axes so I'm doing
>
> x=[-6, 0]
> y=[-3, 1]
>
> Contour, x, y, z
>
> But I get an error that says that x and y need to be 2D arrays, but
> aren't those already 2D arrays? Do I have the syntax wrong?
Well, usually the syntax of the Contour plot is like this:
Contour, z, x, y
Maybe you want something like this:
s = Size(z, /Dimensions)
x = Scale_Vector(Findgen(s[0]), -6, 0)
y = Scale_Vector(Findgen(s[1]), -3, 1)
Contour, z, x, y
You can find Scale_Vector here:
http://www.idlcoyote.com/programs/scale_vector.pro
You might need other routines from the Coyote Library, too.
It is best to download the whole thing.
http://www.idlcoyote.com/code_tips/installcoyote.php
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|