-
Notifications
You must be signed in to change notification settings - Fork 74
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
ENH: Cubeviz metadata viewer #1325
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1325 +/- ##
==========================================
+ Coverage 83.75% 84.77% +1.02%
==========================================
Files 91 91
Lines 7761 7836 +75
==========================================
+ Hits 6500 6643 +143
+ Misses 1261 1193 -68
Continue to review full report at Codecov.
|
for badkey in ('COMMENT', 'HISTORY', ''): | ||
# Some FITS keywords cause "# ipykernel cannot clean for JSON" messages. | ||
# Also, we want to hide internal metadata that starts with underscore. | ||
badkeys = ['COMMENT', 'HISTORY', ''] + [k for k in d if k.startswith('_')] |
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.
@kecnry , I think we talked about automatically hiding "hidden" metadata? This would do it for you.
'S_REGION' not in data.meta): | ||
data.meta['S_REGION'] = data.meta['header']['S_REGION'] | ||
# Make metadata layout conform with other viz. | ||
if 'header' in data.meta: |
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.
With this change, we should no longer worry about meta[somekey]
vs meta['header'][somekey]
.
It seems like the meta['header']
stuff was imposed by specutils
, so in the future if we add new parsing logic that loads stuff from specutils
, we will need to remember to do this along with the new code. A little messy but seems to work. 🤷
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.
Awesome! With this change, the WCS logic for detecting data-type should also probably be updated (either in #1313 if this is merged first, or here if #1313 is merged first).
d.meta.update(meta) | ||
data_list.append(d) | ||
# We do not use the generated labels | ||
data_list = [d for d, _ in get_image_data_iterator(app, hdulist, "Image", ext=None)] |
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.
Metadata stuff is already taken care of in get_image_data_iterator
(Imviz parsing logic).
@@ -24,7 +28,7 @@ def test_load_spectrum1d(mosviz_helper, spectrum1d): | |||
|
|||
assert isinstance(data[label], Spectrum1D) | |||
|
|||
with pytest.raises(TypeError): | |||
with pytest.raises(AttributeError): |
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.
Exception class changed because it now crashes in metadata parsing. I don't think it matters?
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 played around with this a bit. I think the toggle is fine. I would suggest two changes.
- That the UI remembers the toggled state as users select new extensions from the data dropdown. I see this more as a global toggle rather than a per extension toggle. I'd like to toggle it once for everything and leave it until I toggle it back.
- Add in any header comments for each key name, value. Either as a third column or as a hover tooltip on the key name or the row.
This comment was marked as resolved.
This comment was marked as resolved.
Fair points.
Ahh yeah. I guess in those cases you could fall back to the existing header and de-toggle with a notice, similar to what happens now.
You could time box it and see how hard it is. I think it'd be useful for users to have some sort of description of what the header keys are. I imagine at some point before the data get parsed and passed into the machinery hole, the main HDUList is accessible to extract out the Header cards. But yeah, if it's not easy to pull that out, then it can be out of scope for this PR. |
Also enable metadata viewer for Specviz2d
Have show_primary be more sticky.
Well, this is more code than I thought I would write for this feature but I think I have addressed your feedback, @havok2063 . |
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.
Tested with all the configurations and works great, nice work!
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.
Never expected extending the metadata viewer to cubeviz would get this... messy... but its definitely nice to have it across all viztools now. Just a few minor thoughts that you can take or leave, but otherwise I'm happy with merging this and we can iterate on any tweaks as people use it for real. Thanks!
metadata = standardize_metadata(hdulist[ext].header) | ||
metadata.update(wcs_dict) # To be internally consistent | ||
if hdulist[ext].name != 'PRIMARY' and 'PRIMARY' in hdulist: | ||
metadata[PRIHDR_KEY] = standardize_metadata(hdulist['PRIMARY'].header) |
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.
this seems to be a re-used block of code in a few places... could this logic be moved entirely into standardize_metadata
or no?
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.
Not really, as passing in hdulist
into standardize_metadata
would make it too specific to FITS, which should stay in the realm of parsers.
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 mean standardize_metadata
already checks for fits.Header
but you could embed fits.Header
in a plain dict
, which is what specutils
does, but one would/should never put the whole HDUList
inside metadata.
<v-row v-if="has_primary"> | ||
<v-switch | ||
label="Show primary header" | ||
hint="Show MEF primary header metadata instead." | ||
v-model="show_primary" | ||
persistent-hint> | ||
</v-switch> | ||
</v-row> |
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 sure this is the most-intuitive.... but that can be covered in docs or iterated based on user-feedback (I don't really have any suggestions except a full extension-dropdown, but that might not be any more clear).
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.
In Ginga, we have a checkbox toggle that would mix in primary header keys into the display, together with actual header. Not that that is not messy but no one has complained over there... 🤷
|
||
This plugin allows viewing of any metadata associated with the selected data. | ||
|
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 worth a mention explaining the primary switch here?
This is looking good. My only comments are about the styling. When the plugin tray size is small, everything gets squished together and word wraps. This improves when the plugin tray is expanded out, but that takes up real estate. Could we tweak the styles here to try to mitigate some of this? Maybe reducing the font size of the values and comments? Or making the header key bold? Something to try to reduce the amount of whitespace/padding and to visually distinguish a header key with the comment underneath when the plugin tray is small. Jenn might have some thoughts for this. |
I am really afraid this is going to drag on and then go stale, so I am going to merge and address doc and styling in a follow-up PR (see #1331). Thanks! |
now that spacetelescope#1325 is merged and rebased Co-authored-by: P. L. Lim <[email protected]>
Description
This pull request is to parse metadata for Cubeviz and show it in Metadata Viewer plugin.
When there is primary header:
Fixes #1324
TODO
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.CHANGES.rst
?