ndcube
ndcube copied to clipboard
Multi-dimensional lookup tables must be passed to ExtraCoords in world order
This is following on from https://github.com/sunpy/ndcube/pull/327#discussion_r526960030. Due to perfectly sensible design decisions in the LookupTableCoord
layer of the new ExtraCoords
stack, currently when calling ExtraCoords.add_coordinate
is called the lookup_table
argument must be in world order if it is multi-dimensional, i.e transposed with respect to the NDCube
data array.
We probably want to change this to automatically transpose, but doing that in the add_coordinate
method is a little fiddily and needs some thought.
@Cadair, is the main challenge here that the ExtraCoords
object, just like a WCS
, has no knowledge of the data array? And therefore, there's no obvious way for it to interpret array order inputs?
If so, then why not add an add_extra_coord
method to NDCube
which takes the inputs in array order, uses NDCube
's knowledge of both the data
and extra_coords
to convert them to ExtraCoords
world order, and then hand them off to ExtraCoord.add
?
At first glance, this might seem like it's cluttering the NDCube
API and a self-contained ExtraCoords
API is preferable. However, one could argue that cases like this, requiring knowledge of both the data and coordinates, are exactly what NDCube
is designed for! And so an add_extra_coord
is in fact perfectly within the scope of the NDCube
API.
Note to self: You now have to specify the array axes in world order as well as the array. It's at least consistent but still crazy talk.
Just a note, as of #414 this is now irrelevant until #416 is fixed.