See http://lofar9.astron.nl/bugzilla/show_bug.cgi?id=639 for initial discussion.
Jan has also requested more meaningful Vells labels in the result plotter, so I'm thinking we need a simple general mechanism for passing this information around. This should work the same way for both the Result Plotter and the Collections Plotter.
Requiremnents
Here are some requirements for the scheme:
* we now put together all sorts of tensors in various interesting ways, and the mechanism should be able to accomodate all that. For example, it should be able to describe an [N,2,2] tensor with N baseline labels for the first axis, and 4 labels such as "XX", "XY", "YX", "YY" for the second & third axes. It should also be able to describe an [N,3] tensor with N baseline labels for the first axis and 3 labels ("l", "m", "n") for the second axis. Etc, etc.
* there should be global defaults for all this in the forest state (we don't want to store this info in every node that's likely to be visualized), and they can be overridden locally in the node state.
* the mechanism should be able to refer both to numbered axes, and to axis sizes. For example, you should be able to specify things like "a 2x2 matrix represents XX,XY,YX,YY" as a global default, and have that apply to tensors of shape [2,2], [N,2,2], [2,2,N], etc. On the other hand, you should also be able to specify things like "labels for axis #3 are foo,bar,...".
* the scheme should be reasonably clear and unambiguous -- Tony needs a robust implementation.
Proposed scheme
I propose the following algorithm (looking at it from a Plotter's point of view).
1. Say you're presented with an [L,M,N] tensor shape.
2. Start examining tensor dimensions last to first. Dimension #0 is L, dimension #1 is M, dimension #2 is N. Start with #2.
3. Check for a field called vells_labels_dim_2 (first in the node state, then in the forest state -- this double-check should be done for all fields, so I will not specify it from here on). If it exists, this should be a list of size N. You now have labels for the #2 dimension -- go back to step 1 with shape [L,M].
4. Check for a field called vells_labels_N (where the actual numeric value for N is inserted into the field name). If it exists, this should be a list of size N. You now have labels for the #2 dimension -- go back to step 1 with shape [L,M].
5. Check for a field called vells_labels_dim_1_2 (first in the node state, then in the forest state -- this double-check should be done for all fields, so I will not specify it from here on). If it exists, this should be a list of size M*N. You now have labels for dimensions 1 and 2 -- go back to step 1 with shape [L].
6. Check for a field called vells_labels_M_N. If it exists, this should be a list of size M*N. You now have labels for dimensions 1 and 2 -- go back to step 1 with shape [L].
7. Still no labels? Repeat steps 5-6 for "vells_labels_dim_0_1_2" and "vells_labels_L_M_N".
8. Still no labels? Generate default labels of "0","1",...,"N-1" for dimension #2. Go back to step 1 with shape [L,M].
I think this is clear & unambiguous enough, and should be straightforward to implement in Python. On the TDL size, we would (most of the time) set forest_state.vells_labels_2_2 to XX","XY","YX","YY (or RR etc., depending on the tree), which would cover most 2x2 matrices. Then in particular Collector nodes, we would set vells_labels_dim_0 to, e.g., a list of baselines.
Stacking plots
One tricky part for Tony is deciding which dimension to stack in the Collections Plotter. I.e. for an [N,2,2] tensor, you want to stack N plots, while making the other two dimensions available via the Vells selector.
I suggest that to keep things simple, only the first one (or more) dimension(s) are stacked. By default the first one is stacked, but this can be overriden by the stack_dims keyword. I.e. stack_dims=2 causes the first two dimensions to be stacked.
IQUV conversions
Built-in conversion of XX etc. into IQUV is also slightly tricky. To simplify things, I uggest the following rules:
* conversion can only involve the non-stacked dimensions
* the non-stacked dimensions must have a single list of labels. I.e. "XX","XY" etc. for the last two dimensions of an [N,2,2] tensor.
