Correct TiledDataset.plot mosaic ordering#504
Conversation
SolarDrew
left a comment
There was a problem hiding this comment.
Thanks for this, @eigenbrot , it looks like a great fix. It needs some tests but no other comments from me 👍
|
Oops, I forgot about tests! Thanks for the reminder. I'll whip those up. |
Previously it had been the matplotlib default of the upper left, which didn't look right.
And update image hashes
Needed to flip sample dataset WCS to have the option actually do anything
7df7828 to
d9bd0de
Compare
dkist/dataset/tiled_dataset.py
Outdated
|
|
||
| return | ||
|
|
||
| def plot(self, slice_index, share_zscale=False, fig=None, limits_from_wcs=True, **kwargs): |
There was a problem hiding this comment.
I would like to throw a warning here if the user loads an old ASDF file with this new .plot to go and tell them to redownload a new ADSF.
There was a problem hiding this comment.
I'm fine with this idea, but I'm not sure how to implement it. A user will get wrong plots (and should thus be warned) iff these two conditions are BOTH true:
dkist-processing-vbiversion is < 1.19.0dkist-inventoryversion is < 1.?.?
We can check 1 easily, but I don't know about checking the dkist-inventory version. Ideas?
There was a problem hiding this comment.
Given the current implementation of #513 I think this check would be something along the lines of:
if len(self.meta.get("history", {}).get("entries", [])):which would check for any asdf which has the extra history entries.
Cadair
left a comment
There was a problem hiding this comment.
I am going to put this on hold until I can chat to @astrofrog about the best way to do the WCSAxes flipping.
The automatic logic was becoming increasingly fragile and complicated. Much easier to let the user decide what they want to do.
Cadair
left a comment
There was a problem hiding this comment.
This is now blocked on needing a warning if this changed plot ordering is used with currently available ASDF files.
Otherwise looks good.
Currently
TiledDataset.plotflattens the tile list and places them in a subplot based on matplotlib's ordering of theadd_subplotindex ordering. The result is a grid that starts in the upper left. Furthermore, the fix in this inventory PR will swap the MINDEX keys so that the currentTiledDataset.plotmethod would plot a row-major grid, which is counter to the column-major intention of the MINDEX keys.This PR fixes the first issue and prepares for the update mentioned in the second by using
GridSpecto be more explicit about how the subplot grid should be laid our and exactly which tiles go into each subplot. The result is a (MAXIS1, MAXIS2)-shaped grid (FITS ordering) where the origin is in the bottom left and the subplot at grid position (x, y) corresponds to the tile with MINDEX1=x, MINDEX2=y.As an additional refinement, there is also a new option (
limits_from_wcs) to swap axis limits so that the minimum values of the WCS axes are also in the bottom left. This was written to help display some DLNIRSP data where the at-rest data array is oriented strangely, but it should be applicable to all instruments.To show some before and after images I've taken headers from a real DLNIRSP dataset and modified the data arrays to simply show the (MINDEX1, MINDEX2) value of each tile. Here is
.plot()as it is now:Note that the labels are upside down and backwards and the tiles are not organized in an intuitive grid.
Here are the same data after the fix for how the subplot grid is constructed
Note that the tiles are now in the right places, but the labels are still flipped around. This is because the axes are "backward", in a WCS sense.
Finally here is the same plot with
limits_from_wcs=TrueThe labels are now readable because the smallest WCS values are now at the bottom left of each subplot.