Skip to content

Commit

Permalink
fix data-filtering for NIRISS
Browse files Browse the repository at this point in the history
* and only show "show from other MOS rows" if there are entries... since NIRISS can have only a single image data entry
  • Loading branch information
kecnry committed May 20, 2022
1 parent 44a9ed3 commit 6eca4b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
18 changes: 13 additions & 5 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,19 +1234,27 @@ def _on_data_deleted(self, msg):
def _create_data_item(data):
ndims = len(data.shape)
wcsaxes = data.meta.get('WCSAXES', None)
if wcsaxes is None:
# then we'll need to determine type another way, we want to avoid
# this when we can though since its not as cheap
component_ids = [str(c) for c in data.component_ids()]
if data.label == 'MOS Table':
typ = 'table'
elif ndims == 1:
typ = '1d spectrum'
elif ndims == 2 and wcsaxes == 3:
typ = '2d spectrum'
elif ndims == 2 and wcsaxes == 2:
typ = 'image'
elif ndims == 2 and wcsaxes is not None:
if wcsaxes == 3:
typ = '2d spectrum'
elif wcsaxes == 2:
typ = 'image'
else:
typ = 'unknown'
elif ndims == 2 and wcsaxes is None:
typ = '2d spectrum' if 'Wavelength' in component_ids else 'image'
elif ndims == 3:
typ = 'cube'
else:
typ = 'unknown'

return {
'id': str(uuid.uuid4()),
'name': data.label,
Expand Down
10 changes: 3 additions & 7 deletions jdaviz/components/viewer_data_select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
></j-viewer-data-select-item>
</v-row>

<div v-if="viewer.config === 'mosviz'" style="margin-bottom: -8px">
<div v-if="viewer.config === 'mosviz' && mosvizExtraDataItems.length" style="margin-bottom: -8px">
<v-row key="mosviz-expand" style="padding-left: 25px; margin-right: 0px; padding-bottom: 4px; background-color: #E3F2FD">
<span
@click="toggleMosvizShowExtraItems"
Expand All @@ -58,7 +58,7 @@
</span>
</v-row>

<v-row v-for="item in mosvizExtraDataItems" :key="item.id" style="padding-left: 25px; margin-right: 0px">
<v-row v-if="mosvizShowExtraItems" v-for="item in mosvizExtraDataItems" :key="item.id" style="padding-left: 25px; margin-right: 0px">
<j-viewer-data-select-item
:item="item"
:viewer="viewer"
Expand Down Expand Up @@ -116,18 +116,14 @@ module.exports = {
return false
} else if (item.meta.mosviz_row !== undefined) {
if (mosvizExtraItems) {
// then show ONLY items from OTHER rows
if (!this.mosvizShowExtraItems) {
return false
}
// then show only plugin items and only those in a different row
return item.meta.mosviz_row !== this.$props.app_settings.mosviz_row
} else {
// show ONLY items from the SAME row
return item.meta.mosviz_row == this.$props.app_settings.mosviz_row
}
}
return true
return !mosvizExtraItems
} else if (this.$props.viewer.config === 'cubeviz') {
if (this.$props.viewer.reference === 'spectrum-viewer') {
if (item.meta.Plugin === undefined) {
Expand Down
2 changes: 2 additions & 0 deletions jdaviz/configs/mosviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ def mos_niriss_parser(app, data_dir, obs_label=""):
spec2d = Spectrum1D(data * u.one, spectral_axis=wav, meta=meta)

spec2d.meta['INSTRUME'] = 'NIRISS'
spec2d.meta['mosviz_row'] = len(spec_labels_2d)

label = f"{filter_name} Source {temp[sci].header['SOURCEID']} spec2d {orientation}" # noqa
ra, dec = pupil_id_dict[filter_name][temp[sci].header["SOURCEID"]]
Expand Down Expand Up @@ -687,6 +688,7 @@ def mos_niriss_parser(app, data_dir, obs_label=""):
for spec in specs:
# Make metadata layout conform with other viz.
spec.meta = standardize_metadata(spec.meta)
spec.meta['mosviz_row'] = len(spec_labels_1d)

if spec.meta['SPORDER'] == 1 and spec.meta['EXTNAME'] == "EXTRACT1D":
label = f"{filter_name} Source {spec.meta['SOURCEID']} spec1d {orientation}"
Expand Down

0 comments on commit 6eca4b1

Please sign in to comment.