From the docs and based on Slab's behavior, Slice generates incorrect
origins and deltas for regular grids. I have an example below for those
that don't follow dx-users.
I propose to change Slice's behavior for regular grids to the
following:
Slice( field, dim, pos )
------------------------
1. Look for a unique non-zero component in field.deltas[dim]
2. If found:
a. Call that index "axis" (0=x, 1=y, 2=z, etc.)
b. series position = ( origin + pos * deltas[dim] )[ axis ]
c. origin_new = ( origin + pos * deltas[dim] ) with
'axis' component removed
d. deltas_new = deltas with deltas[dim] removed, and
'axis' component removed from the remaining deltas
e. counts_new = counts with counts[dim] removed
3. Else
?
If there are no objections, I'll submit a patch early next week.
Any thoughts on the Else? The Else includes cases like
non-axis-aligned grids (e.g. deltas={[-1,1],[1,1]}), with either orthogonal
or non-orthogonal connections. If no one cares, we can just leave the
current behavior alone for those cases (though creating spatially
meaningful origins/deltas based on distance measurements might be more
useful).
Randy
P.S. Why not just ignore Slice and use Slab you ask? One reason is: 2D
operations on a 3D volume. For example, Reduce won't let you reduce in
some dimensions but not others (e.g. X&Y, but not Z).
Slice(all)->Reduce->Stack does the job efficiently, except that origin and
deltas are corrupted by Slice. And you can't use Slab instead in this
pipeline as Stack insists on increasing the dimensionality.
----------------------------------------------------------------------------
EXAMPLE: y
/\
||
202 * ---- * ---- * ---- *
| | | |
| | | |
201 * ---- * ---- * ---- *
| | | |
| | | |
200 * ---- * ---- * ---- *
100 102 104 106 ==> x
field = Construct( origin = [ 100,200 ],
deltas = { [ 0,1 ], [ 2,0 ] },
counts = [ 3,4 ] );
slice = Slab( field, dimension=0, position=1, thickness=0 );
--> returns: origin=[100,201], deltas={ [0,1],[2,0] }, counts=[1,4]
slice = Slice( field, dimension=0, position=1 );
--> returns : origin=[200], deltas={ [1] }, counts=[4]
--> SHOULD RETURN: origin=[100], deltas={ [2] }, counts=[4]
----------------------------------------------------------------------------
--
Randall Hopper (mailto:[EMAIL PROTECTED])
Lockheed Martin Operation Support
EPA Scientific Visualization Center
US EPA MD/24 ERC-1A; RTP, NC 27711