[Moving discussion from opendx-dev to the opendx-users mail list -
original post at the very bottom of this message.]
Chris & Joel,
First, thanks for your quick response. It turns out I need to handle
this in C versus export to a file...mainly because I need to have DX
view the data as it arrives. The data will arrive in "chunks" (for lack
of a better word) which I will display in DX, and then update when
additional data arrives on the axes.
So I believe I understand your explanation below - that's very helpful.
However, it turns out that data will arrive at different rates with
respect to time, so at some time points, some axes may have no data. In
other words, every data axis / component will have a corresponding time
point in the time positions component, but not every point in the time
positions component will have a corresponding data point for every axis.
Conceptually, I envision the time component to essentially be the union
of all time points acquired over all the data components. So when data
arrives, it is placed in it's own 1-D array at a certain position, and
the time is placed in 1-D array at the same position (array index). If
multiple pieces of data arrive at the same time (on different
components), how do I associate them with the same time in the time
component (array index on the time component)? I guess I don't see how
this will work, since the data arrays are growing at different rates, as
is the time array. How do I link them up w.r.t. array index ("positions")?
Thanks again for your help,
Matt
--
Chris Pelkie wrote:
The 'basis set' in DX is the "positions" component. You are close to
what you need.
You need a 1-D (rank 1 shape 1) "positions". They can be simply
0..n-1, where n = number of items in (each of) your data array(s).
This is what binds the other components together, in this case, just
like an array index, but more generally, even if these were 3-D
positions representing points in 3-D space, you would still associate
your "data" components with the "positions". You can make this beast
with Enumerate and Compute. Enumerate outputs a scalar array, Compute
can make it 1-D vector (see below).
By virtue of associating the 4 data components (time is not special in
DX) with the same positions, you 'relate' them as in a relational
database, if you like to think of it that way. You have also
guaranteed that each array has the same length and appears in the
proper order, i.e., you've arranged it so that position 0 == time "0"
(whatever actual time value that may be) == data0[0] == data1[0] ==
data2[0] (where "==" means "corresponds to" or "associates with"). So
on up to position n-1 ==...data2[n-1]. These 5 components are bound
into a Field because most DX modules like to work on Fields (because
they know where things are stored, how they are associated, etc.).
So now it's trivial to Extract(data0) and Extract(data2) in parallel
operations from the Field, Compute(float([a,b])) to make an array (of
length n) of 2-vector floats [data0, data2]. These will become the new
"positions" of the new Field that you will actually render. I like to
do things the simple clean way, so trying to reinsert these over the
old positions is not necessarily the best way to proceed. Instead,
just send this 2-vector array into Construct's origin input. Viola,
you get a new Field whose positions are your 2-vectors. You also get
unnecessary (and sometimes annoying) line connections that join all
these points in order, so I will often Remove("connections") right
after Construct. Glyph, AutoColor, Image and you have a 2-d
scatterplot. Add axes in Image. Any 2 of the 4 data components can be
used. You can expand Compute to handle [a,b,c] and you get 3-d
scatterplots. You can send any of the 4 data components (even if
you've used them in positions) into the Construct "data" input to
insert data onto each 2-vector position. Then AutoColor and Glyph will
react to those data values (by default, Construct kicks out no data,
so you have to put a "1" into "data" to avoid AutoColor bitching about
the lack of data to color).
By the way, a scalar is not one-dimensional. It is zero-dimensional by
definition. There is a precise meaning to 1-dimensional as you will
find if you try to make a positions array with a scalar array. Doesn't
work. You have to 'cast' it to 1-vector as follows: scalar input "a"
-> Compute([a]). Further, positions MUST be float, thus the cast I did
above for safety since one never knows what the 4 data input types are.
rank 0 = scalar (has no shape)
rank 1 = vector, now you must declare shape = n, where n = number of
vector components (usually 1, 2, or 3, but DX has no known limit: I've
worked with 57, and strings are character vectors that go to at least
1024)
rank 2 = tensor (read the manual)
On Jul 29, 2005, at 1:55 AM, Matt Genovese wrote:
Hello,
I am a little confused regarding the OpenDX data model, and would
like to solicit input from those who understand it better than I.
My project is fairly simple: I am writing a C program to capture
data as time progresses, and plot it in DX. There are one or more
axes (sources of data values), and obviously the time-axis is
another source of data (there can actually be multiple discrete
time axes, but I'll keep it simple for now). Note that time does
not progress at a constant rate.
The goal is to be able to plot any axis vs. a time axis. However,
more generally, I'd like to be able to plot any axis vs. any other
axis....which is really a scatter plot. The points on the scatter
plot are correlated (linked) by the discrete time which they were
captured in the simulation.
I'd like to understand how to best assemble this into the DX data
model. My attempt is to group all the axes under a DX Field. Each
axis is essentially a DX Array of data, which is a component of
the Field. However, does this allow me to formulate the time-based
plots or scatter plots I am looking for? The Arrays I was building
are scalar (rank 0) - just raw values (doubles) obtained over
time...one for each axis. I am also confused as to the "rank" and
"shape" parameters, and how they affect organization of the data
in the Array....so perhaps this is part of my problem.
So for example, my thinking is that if I had 3 data sources, and
they're sampled over time, I have: 4 "axes" - 4 DX Arrays as
components under 1 DX Field object. Three of the arrays are
one-dimensional and contain the data values, and the fouth array
is one-dimensional and contains the capture times for all points.
Then the three data arrays are somehow linked to the fourth array
to correlate the data value with time-of-capture. Again, I'm
worried I am going about this all-wrong.
I hope this is not too vague. Thanks in advance for any guidance
you can provide.
Best Regards,
Matt Genovese
University of Texas at Austin
--
_______________________________
Chris Pelkie
Scientific Visualization Producer
622 Rhodes Hall, Cornell Theory Center
Ithaca, NY 14853 (607) 254-8794