Marissa Forbes:
 |I currently have an animation going that cycles through 48 files of data
 |using ForEachN ---> Format ---> Import.  Now, I would like to add a vector
 |field to the animation.  However, the 48 time series of data for the
 |vector field are all in one file.  How can I tell import to grab data
 |for only one series at a time so that both components of the animation
 |match up?  I've tried hooking up another ForEachN to "start" and "end" of
 |Import, but that doesn't seem to do the trick.

Assuming memory isn't a problem, just import the entire Series, and use a
Select driven by the timestep number to pick off the timestep you need for
each iteration.

Randall


It's true that you cannot use two "For.." modules in the same scope as there is no guarantee of which runs first on each iteration. That's why they are usually wrapped inside a macro (the whole net is considered a "macro", thus only one For... at top level is permitted.) (You might consider using Sequencer. It has better user controls and will accomplish the same end if you just hit "Play". Note that you can only use 1 Sequencer and not inside a user macro, just at top level).

But you can certainly take the same output value from ForEachN (or Sequencer) and send it to two or more different places downstream; use Compute if you have to offset the value of one set of numbers. Then take Donna's suggestion to drive Import to load only the n'th series member if they are in one file.

For future reference, consider making separate time step files with logical numbered names, then use output of ForEachN/Sequencer to Format(s) the new name(s) for each (pair of) time step file(s) and send the name(s) into Import(s).

In either case, unite the two imported objects with Replace (assuming they have a one-to-one correspondence in structure).

Now, here's a completely different solution:
You may not be aware that you could have more than one "data"-like component simultaneously in each series member field. Rough example:

object "time_step_nnn" class field
component "positions" value "positions_nnn"
component "connections" value "connections_nnn"
component "scalar data" value "scalar_data_nnn"
component "vector data" value "vector_data_nnn"

The presumption is that both "scalar_data_nnn" and "vector_data_nnn" are in one-to-one correspondence with either "positions_nnn" or "connection_nnn" and that all components were previously defined with appropriate "dep" attributes.

Then Import just as you are doing now, and Mark("scalar data") before processing the scalar values, and in parallel Mark("vector data") then do vector things to that downstream flow. Join them if desired with Collect before sending to Image, or pipe the two outputs to two Images.

This technique would support either separate time step files, each with a field definition shown above, or you can put them all into one group file, using the same field definition template.

One last thought: you don't have to write both the fields and the group stuff into one big unwieldy file. Write the separate fields into separate time step files. Then create one or more series header files (series.dx) that look like this:

object "test_series" class series
member 0 file time_step_000
member 1 file time_step_001

etc.

This way allows you to create quick short test series, before appending all the file names of every time step, if that is helpful. You just Import the series.dx filename, then use ForEachN/Sequencer to pick out the time step you want by sending N to Import "start" and "end" (hidden inputs by default).

OK, one more note: series handling can have one more important ramification. IF you can load the whole series, you can immediately determine the data range for the entire set of data in all time steps (Statistics or Colormap). This means that "red" will always map to "max" for all time steps. ELSEIF you cannot load the whole series, the meaning of "red" will be the value of "max" for each time step. Usually pretty confusing output results.

So, the workaround in your case is to run through the series once and determine the min/max of each data item, then set these values, say in Colormap, then run the series again to make the images for output.

This can be automated with an accumulation-like macro, but that's for another day or another correspondent. See the Sum macro in the samples directory for the general idea.
--
Chris Pelkie
Managing Partner
Practical Video LLC
30 West Meadow Drive,  Ithaca,  NY  14850

Reply via email to