Re: Making a 2D Array from 3 columns [message #35882] |
Thu, 24 July 2003 19:53 |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
astronomer wrote:
> Hello everyone, i just came to this newsgroup and already have two
> posts! Shows how much I love IDL!!
>
> Basically: Many programs such as contour programs or just 3-d
> graphing programs need a 2-array as an input.
> I do not have a 2-d array as input.
> What I do have is three 1d arrays. One of these has the x positions
> of several objects. Another has y positions of the same objects. The
> last array has the density or flux or something else of these objects.
> Note, only in the places of the xy field where there is an object do I
> have data. I have nothing for the other regions of the xy field.
> This to say that I do not have a continuous function z=f(x,y), mine is
> discrete....
>
> However, I would like to have contour plots of the density or flux, so
> I would need to make the famous 2-d array the programs use as input.
How are the (x,y) points defined by your x & y position arrays arranged?
In a straight line? In a grid? Or scattered on the x-y plane? I'm
guessing the latter, so you want to set up a 2D grid and generate
plausible values for your field at each point on the grid.
In IDL this is done by the GRIDDATA function. (This was introduced in
5.5; before that there were various functions like TRIGRID, but GRIDDATA
has made them redundant.) GRIDDATA is a multi-faceted complicated beast,
but its documentation includes several examples, one of which you should
be able to adapt.
Also check out the IDL demo under menu item Visualization/Gridding.
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|