Skip to content
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

Better menu selection labels for spectral lines in line analysis plugin #2816

Merged
merged 7 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Specviz2d
Other Changes and Additions
---------------------------

- Line menu in Redshift from Centroid section of Line Analysis now shows values in current units. [#2816]

3.9.1 (unreleased)
==================

Expand All @@ -81,7 +83,7 @@ Cubeviz

Imviz
^^^^^
- Fix bugs where API created footprints did not overlay and only last
- Fix bugs where API created footprints did not overlay and only last
footprint displayed if added before linking. [#2790, #2797]

- Improved behavior when orientations are created or selected without having data loaded in the viewer. [#2789]
Expand Down
13 changes: 10 additions & 3 deletions jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class LineAnalysis(PluginTemplateMixin, DatasetSelectMixin, SpectralSubsetSelect
results_computing = Bool(False).tag(sync=True)
results = List().tag(sync=True)
results_centroid = Float().tag(sync=True) # stored in AA units
line_items = List([]).tag(sync=True)
line_menu_items = List([{}]).tag(sync=True)
sync_identify = Bool(True).tag(sync=True)
sync_identify_icon_enabled = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select.svg'), 'svg+xml')).tag(sync=True) # noqa
sync_identify_icon_disabled = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select_disabled.svg'), 'svg+xml')).tag(sync=True) # noqa
Expand Down Expand Up @@ -173,6 +173,11 @@ def user_api(self):
return PluginUserApi(self, expose=('dataset', 'spatial_subset', 'spectral_subset',
'continuum', 'width', 'continuum_width', 'get_results'))

@property
def line_items(self):
# Return list of only the table indices ("name_rest" in line table) from line_menu_items
return [item["value"] for item in self.line_menu_items]

def _on_viewer_data_changed(self, msg):
viewer_id = self.app._viewer_item_by_reference(
self._default_spectrum_viewer_reference_name
Expand Down Expand Up @@ -242,14 +247,16 @@ def get_results(self):

if not self.spectral_subset_valid:
valid, spec_range, subset_range = self._check_dataset_spectral_subset_valid(return_ranges=True) # noqa
raise ValueError(f"spectral subset '{self.spectral_subset.selected}' {subset_range} is outside data range of '{self.dataset.selected}' {spec_range}") # noqa
raise ValueError(f"spectral subset '{self.spectral_subset.selected}' {subset_range}"
f" is outside data range of '{self.dataset.selected}' {spec_range}")

self._calculate_statistics()
return self.results

def _on_plotted_lines_changed(self, msg):
self.line_marks = msg.marks
self.line_items = msg.names_rest
self.line_menu_items = [{"title": f"{mark.name} {mark.rest_value} {mark.xunit}", "value": name_rest} # noqa
for mark, name_rest in zip(msg.marks, msg.names_rest)]
if self.selected_line not in self.line_items:
# default to identified line if available
self.selected_line = self.identified_line
Expand Down
24 changes: 13 additions & 11 deletions jdaviz/configs/specviz/plugins/line_analysis/line_analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
hint="Select which region's collapsed spectrum to analyze."
/>

<plugin-subset-select
<plugin-subset-select
:items="spectral_subset_items"
:selected.sync="spectral_subset_selected"
:show_if_single_entry="true"
Expand All @@ -50,13 +50,13 @@
<j-plugin-section-header>Continuum</j-plugin-section-header>
<v-row>
<j-docs-link>
{{continuum_subset_selected=='Surrounding' && spectral_subset_selected=='Entire Spectrum' ? "Since using the entire spectrum, the end points will be used to fit a linear continuum." : "Choose a region to fit a linear line as the underlying continuum."}}
{{continuum_subset_selected=='Surrounding' && spectral_subset_selected=='Entire Spectrum' ? "Since using the entire spectrum, the end points will be used to fit a linear continuum." : "Choose a region to fit a linear line as the underlying continuum."}}
{{continuum_subset_selected=='Surrounding' && spectral_subset_selected!='Entire Spectrum' ? "Choose a width in number of data points to consider on each side of the line region defined above." : null}}
When this plugin is opened, a visual indicator will show on the spectrum plot showing the continuum fitted as a thick line, and interpolated into the line region as a thin line.
</j-docs-link>
</v-row>

<plugin-subset-select
<plugin-subset-select
:items="continuum_subset_items"
:selected.sync="continuum_subset_selected"
:show_if_single_entry="true"
Expand Down Expand Up @@ -96,17 +96,17 @@
<v-col cols=6><U>Function</U></v-col>
<v-col cols=6><U>Result</U></v-col>
</v-row>
<v-row
<v-row
v-for="item in results"
:key="item.function">
<v-col cols=6>
{{ item.function }}
<j-tooltip :tooltipcontent="'specutils '+item.function+' documentation'">
<a v-bind:href="'https://specutils.readthedocs.io/en/stable/api/specutils.analysis.'+item.function.toLowerCase().replaceAll(' ', '_')+'.html'"
target="__blank"
<a v-bind:href="'https://specutils.readthedocs.io/en/stable/api/specutils.analysis.'+item.function.toLowerCase().replaceAll(' ', '_')+'.html'"
target="__blank"
style="color: #A75000">
<v-icon x-small color="#A75000">mdi-open-in-new</v-icon>
</a>
</a>
</j-tooltip>
</v-col>
<v-col cols=6>
Expand All @@ -123,7 +123,7 @@
</div>
<div v-if="results_computing"
class="text-center"
style="grid-area: 1/1;
style="grid-area: 1/1;
z-index:2;
margin-left: -24px;
margin-right: -24px;
Expand Down Expand Up @@ -154,7 +154,9 @@
<v-select
:menu-props="{ left: true }"
attach
:items="line_items"
:items="line_menu_items"
item-text="title"
item-value="value"
v-model="selected_line"
label="Line"
hint="Select reference line."
Expand All @@ -177,7 +179,7 @@

<v-row justify="end">
<j-tooltip tipid='plugin-line-analysis-assign'>
<v-btn
<v-btn
color="accent"
style="padding-left: 8px; padding-right: 8px;"
text
Expand All @@ -188,6 +190,6 @@
</j-tooltip>
</v-row>
</div>
</div>
</div>
</j-tray-plugin>
</template>
Loading