comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » plot (x,y,z) triplets as a surface?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
plot (x,y,z) triplets as a surface? [message #17584] Tue, 02 November 1999 00:00 Go to next message
noymer is currently offline  noymer
Messages: 65
Registered: June 1999
Member
Dear comp.lang.idl-pvwave,

I have some surface data that are generated by a computer
simulation I wrote. The simulation itself is not written in IDL,
it's an external program that produces an ASCII data set. Before
switching to IDL, I used a plotting program that required the surface
data to be z only, with x and y determined by column and row.

As far as I can tell, this is also IDL's preferred way to read
surface data. Obviously, it is a more economical way to store surface
data. However, economy aside, for many reasons I would prefer to
have my simulation output (x,y,z) triplets. The x,y values ARE evenly
spaced but I would STILL like to output the data as triplets. Call
me stubborn.

Is there any way to read (x,y,z) triplets into IDL and make a
surface? Sorry if this is a terrible newbie question.

TIA,
Andrew
noymer@my-deja.com


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: plot (x,y,z) triplets as a surface? [message #17641 is a reply to message #17584] Thu, 04 November 1999 00:00 Go to previous message
Mirko Vukovic is currently offline  Mirko Vukovic
Messages: 124
Registered: January 1996
Senior Member
In article <7vrdi6$8ov$1@nnrp1.deja.com>,
Andrew <noymer@my-deja.com> wrote:
> In article <941660333.808073@clam-55>,
> "Mark Hadfield" <m.hadfield@niwa.cri.nz> wrote:

>
> No amount of rotation, changing aspect, etc., can switch between
> RH/LH, but there must be some clever way to REFORM the data to get RH
> or LH system? The trick is to be very sure the axis labels are
> correct at the end of it all.
>
> Thanks to those who responded. Any ideas about the RH/LH systems?
> Sometimes I mess with surfaces from a million angles, only to find
that
> the ONLY way to make them "look right" is to switch to a LH coordinate
> system. It's simple yet very powerful.
>
> Thanks in advance if you have any more thoughts.
>
Consider using the rotate function to rotate/transpose the array.
A judicious combination of that with axis reversal should give
you what you want.

Mirko


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: plot (x,y,z) triplets as a surface? [message #17645 is a reply to message #17584] Thu, 04 November 1999 00:00 Go to previous message
noymer is currently offline  noymer
Messages: 65
Registered: June 1999
Member
In article <941660333.808073@clam-55>,
"Mark Hadfield" <m.hadfield@niwa.cri.nz> wrote:
> As I understand it you want to read in a series of (x,y,z) triplets
> which actually represent vertices in a m x n rectangular array, i.e.
> something like this (for m=2, n=3) [SNIP]
> and you want to reorganise the data into an X vector (dimensioned
> [m]), a Y vector (dimensioned [n]) and a Z array (dimensioned [m,n])
> and generate a surface plot. Can you confirm that this is the problem
> you are trying to solve, and indicate which part you are having
> difficulty with.

That's exactly it. I have not had a chance to mess around with
Craig's suggestion (thanks Craig) of REFORM, but if I had known about
that function I would have tried that before posting.

> Do you know m and n in advance?

Yes.

> Can you control the order in which the data are written into
> the file?

I can control everything ;-). It's a Pascal program written by me,
so I can have it write the data any-which-way.

Allow me to give some more information, and you'll see why this has
been such a vexing problem for me. There is also an adjunct problem
that I hope people will have some ideas for.

Before starting to use IDL, I used a plotting program that *ONLY*
could plot surfaces in the way I indicated: an array of Z-values
with X,Y determined by column and row. The REFORMation suggested
by Craig does not have an analogue in my old program. It could make
a 3D scatterplot from (X,Y,Z) triplets, but to grid a surface it
needed the data in an array. The problem of unevenly-spaced data,
discussed by David, is likewise impossible in the package I used
before.

MAIN PROBLEM: Now, the data I have are evenly spaced in X (age) and Y
(time), but there was always a problem with axis labeling. The axis
labels always popped up 1..50, 1..100 if the array was 50x100, for
example. Never mind that the units were in months, so 12=1year, but I
needed labels in years etc. In X-Y-Z, I have control over units! I
used to always have to go in and change the axis labels by hand when I
was on my "final" version, but inevitably, I would want to change
something again, and it became a nightmare to keep the axis labels
accurate. Part of the reason I want triplets is to keep track of my
age/time variables in their real units, not in arbitrary units. It
seems that IDL can work this much better: from the manual for SURFACE:
"X -- A vector or two-dimensional array specifying the X coordinates
of the grid. If this argument is a vector, each element of X specifies
the X coordinate for a column of Z (e.g., X[0] specifies the X
coordinate for Z[0,*] )." So I specify my X,Y vectors and I'm home
free? This used to cause me no end of aggravation.

ADJUNCT PROBLEM: My old package could switch between RH and LH
coordinate systems with the touch of a button. I was just looking at
some of the graphs, and I wrote down an example. In RH, we have (in
this case) X on the horizontal axis and Y on the vertical axis and Z
the depth axis. Z starts at 0 (away from the viewer) and goes to 80
(closer to the viewer). X is 0 at left, 100 at right, and Y is 0 at
bottom and 150 at top. In LH, Z and Y are unchanged, but X goes from
100 at left to 0 at right.

I asked someone at RSI about changing between RH/LH coordinate
systems, and got a response that IDL doesn't have a setting to do
this. But upon considering the above, it seems to me that IDL could
do this, no? In a 2D PLOT, it is trivial in IDL to reverse one axis
but leave the other. I'm less sure about SURFACE.

No amount of rotation, changing aspect, etc., can switch between
RH/LH, but there must be some clever way to REFORM the data to get RH
or LH system? The trick is to be very sure the axis labels are
correct at the end of it all.

Thanks to those who responded. Any ideas about the RH/LH systems?
Sometimes I mess with surfaces from a million angles, only to find that
the ONLY way to make them "look right" is to switch to a LH coordinate
system. It's simple yet very powerful.

Thanks in advance if you have any more thoughts.

-- Andrew

noymer@my-deja.com



Sent via Deja.com http://www.deja.com/
Before you buy.
Re: plot (x,y,z) triplets as a surface? [message #17646 is a reply to message #17584] Thu, 04 November 1999 00:00 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning <davidf@dfanning.com> wrote in message
news:MPG.128a5893802727dc989939@news.frii.com...
> Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
>
>> David--That's a very useful article, but Andrew's original post said
that
>> the data ARE evenly spaced.
>
> Yes, I know. And I thought Craig's response about REFORMing
> the Z data answered the question nicely.

Oh, I still haven't seen that one. The sun may rise earlier in NZ than
(almost) anywhere else in the world, but the delay before news articles
arrive seems to be large and highly variable.

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
Re: plot (x,y,z) triplets as a surface? [message #17648 is a reply to message #17584] Thu, 04 November 1999 00:00 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning <davidf@dfanning.com> wrote in message
news:MPG.128a0f352e8e5f8e989937@news.frii.com...
> Andrew (noymer@my-deja.com) writes:
>
>> ...The x,y values ARE evenly
>> spaced but I would STILL like to output the data as triplets. Call
>> me stubborn.
>>
>> Is there any way to read (x,y,z) triplets into IDL and make a
>> surface? Sorry if this is a terrible newbie question.
>
> I've been meaning to write an article about gridding
> data for a SURFACE plot for about 5 years now. This
> question finally pushed me over the edge. You can find
> it here:
>
> http://www.dfanning.com/tips/grid_surface.html

David--That's a very useful article, but Andrew's original post said that
the data ARE evenly spaced.

Andrew--As I understand it you want to read in a series of (x,y,z) triplets
which actually represent vertices in a m x n rectangular array, i.e.
something like this (for m=2, n=3)

0 0 [Z value]
0 1 [Z value]
0 2 [Z value]
1 0 [Z value]
1 1 [Z value]
1 2 [Z value]

and you want to reorganise the data into an X vector (dimensioned [m]), a Y
vector (dimensioned [n]) and a Z array (dimensioned [m,n]) and generate a
surface plot. Can you confirm that this is the problem you are trying to
solve, and indicate which part you are having difficulty with. Is it reading
the data from the file or recovering X, Y and Z? Do you know m and n in
advance? Can you control the order in which the data are written into the
file?

Cheers...

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand
Re: plot (x,y,z) triplets as a surface? [message #17649 is a reply to message #17584] Wed, 03 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:

> Oh, I still haven't seen that one. The sun may rise earlier in NZ than
> (almost) anywhere else in the world, but the delay before news articles
> arrive seems to be large and highly variable.

Yes. I chose my current ISP because I felt like I was
going deaf with the previous one: every time I read a
newsgroup article they were replying to one I hadn't
seen. It was like catching every other word of a
conversation. It was to the point that I was
even grateful for those people who quote every
damn word of the previous article. :-)

Cheers,

David

P.S. Now, if I could just find an ISP who would
cache my articles for 24-hours before sending them
out, so I wouldn't keep embarrassing myself...

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: plot (x,y,z) triplets as a surface? [message #17658 is a reply to message #17584] Wed, 03 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:

> David--That's a very useful article, but Andrew's original post said that
> the data ARE evenly spaced.

Yes, I know. And I thought Craig's response about REFORMing
the Z data answered the question nicely. I was just pointing
out that this problem of gridding data has come up too many
times to be ignored anymore. An article we can point the
folks towards just seemed needed. And Andrew indicates
in a private e-mail that even he found it useful. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: plot (x,y,z) triplets as a surface? [message #17666 is a reply to message #17584] Wed, 03 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Andrew (noymer@my-deja.com) writes:

> I have some surface data that are generated by a computer
> simulation I wrote. The simulation itself is not written in IDL,
> it's an external program that produces an ASCII data set. Before
> switching to IDL, I used a plotting program that required the surface
> data to be z only, with x and y determined by column and row.
>
> As far as I can tell, this is also IDL's preferred way to read
> surface data. Obviously, it is a more economical way to store surface
> data. However, economy aside, for many reasons I would prefer to
> have my simulation output (x,y,z) triplets. The x,y values ARE evenly
> spaced but I would STILL like to output the data as triplets. Call
> me stubborn.
>
> Is there any way to read (x,y,z) triplets into IDL and make a
> surface? Sorry if this is a terrible newbie question.

I've been meaning to write an article about gridding
data for a SURFACE plot for about 5 years now. This
question finally pushed me over the edge. You can find
it here:

http://www.dfanning.com/tips/grid_surface.html

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: point_lun question, Solution
Next Topic: idl emacs question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:16:31 PDT 2025

Total time taken to generate the page: 0.00656 seconds