-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct TiledDataset.plot
mosaic ordering
#504
base: main
Are you sure you want to change the base?
Conversation
@@ -184,6 +206,9 @@ def plot(self, slice_index, share_zscale=False, fig=None, **kwargs): | |||
fig : `matplotlib.figure.Figure` | |||
A figure to use for the plot. If not specified the current pyplot | |||
figure will be used, or a new one created. | |||
limits_from_wcs : `bool` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced limits_from_wcs
is the best name for this option. Suggestions welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps auto-rotate
or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe auto_orient
? I like where you're going, but I'm worried "rotate" might imply that it can rotate by something other than 180 degrees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Currently
TiledDataset.plot
flattens the tile list and places them in a subplot based on matplotlib's ordering of theadd_subplot
index 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.plot
method 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
GridSpec
to 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=True
The labels are now readable because the smallest WCS values are now at the bottom left of each subplot.