Skip to content

Commit

Permalink
link to latest demo L1 file
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Jul 1, 2024
1 parent eb44515 commit fd66649
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ Cubeviz
- Add Spectral Extraction plugin for Cubeviz, which converts spectral cubes
to 1D spectra with propagated uncertainties [#2039]

- Support for loading Roman WFI Level 1 (ramp) files [#2376]

Imviz
^^^^^

Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _parse_spectrum1d(app, file_obj, data_label=None, spectrum_viewer_reference_
def _parse_ndarray(app, file_obj, data_label=None, data_type=None,
flux_viewer_reference_name=None,
uncert_viewer_reference_name=None,
meta=None):
meta={}):
if data_label is None:
data_label = app.return_data_label(file_obj)

Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/cubeviz/plugins/slice/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _watch_viewer(self, viewer, watch=True):
# conversion can be done efficiently
self._update_data(viewer_data[0].spectral_axis)

Check warning on line 173 in jdaviz/configs/cubeviz/plugins/slice/slice.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/slice/slice.py#L173

Added line #L173 was not covered by tests
else:
sample_index = np.arange(1, 1 + viewer_data[0].shape[-1]) * u.one
sample_index = np.arange(viewer_data[0].shape[-1]) * u.one
self._update_data(sample_index)

Check warning on line 176 in jdaviz/configs/cubeviz/plugins/slice/slice.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/slice/slice.py#L175-L176

Added lines #L175 - L176 were not covered by tests

if viewer not in self._indicator_viewers:
Expand All @@ -196,7 +196,7 @@ def _update_reference_data(self, reference_data):
return # pragma: no cover

if reference_data.meta.get(cubeviz_ramp_meta_flag, False):
sample_index = np.arange(1, 1 + reference_data['flux'].shape[-1]) * u.one
sample_index = np.arange(reference_data['flux'].shape[-1]) * u.one
self._update_data(sample_index)

Check warning on line 200 in jdaviz/configs/cubeviz/plugins/slice/slice.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/slice/slice.py#L198-L200

Added lines #L198 - L200 were not covered by tests
else:
self._update_data(reference_data.get_object(cls=Spectrum1D).spectral_axis)

Check warning on line 202 in jdaviz/configs/cubeviz/plugins/slice/slice.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/slice/slice.py#L202

Added line #L202 was not covered by tests
Expand Down
34 changes: 15 additions & 19 deletions jdaviz/configs/specviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,33 +602,29 @@ def set_plot_axes(self):
# default to Flux Density for flux density or uncaught types
flux_unit_type = "Flux density"

# Set x axes labels for the spectrum viewer
x_disp_unit = self.state.x_display_unit

is_ramp = (
self.state.reference_data and
self.state.reference_data.meta.get(cubeviz_ramp_meta_flag, False)
)

if not is_ramp:
flux_unit_type = "Flux density"
x_unit = u.Unit(x_disp_unit) if x_disp_unit else u.dimensionless_unscaled
if x_unit.is_equivalent(u.m):
spectral_axis_unit_type = "Wavelength"
elif x_unit.is_equivalent(u.Hz):
spectral_axis_unit_type = "Frequency"
elif x_unit.is_equivalent(u.pixel):
spectral_axis_unit_type = "Pixel"
else:
spectral_axis_unit_type = str(x_unit.physical_type).title()
x_disp_unit = f'[{self.state.x_display_unit}]'
else:
flux_unit_type = "Counts"
# Set x axes labels for the spectrum viewer
x_disp_unit = self.state.x_display_unit
x_unit = u.Unit(x_disp_unit) if x_disp_unit else u.dimensionless_unscaled

if is_ramp:
spectral_axis_unit_type = "Sample"
x_disp_unit = self.state.x_display_unit = ''
self.state.x_display_unit = ''

Check warning on line 616 in jdaviz/configs/specviz/plugins/viewers.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/specviz/plugins/viewers.py#L615-L616

Added lines #L615 - L616 were not covered by tests
elif x_unit.is_equivalent(u.m):
spectral_axis_unit_type = "Wavelength"
elif x_unit.is_equivalent(u.Hz):
spectral_axis_unit_type = "Frequency"
elif x_unit.is_equivalent(u.pixel):
spectral_axis_unit_type = "Pixel"
else:
spectral_axis_unit_type = str(x_unit.physical_type).title()

with self.figure.hold_sync():
self.figure.axes[0].label = f"{spectral_axis_unit_type} {x_disp_unit}"
self.figure.axes[0].label = f"{spectral_axis_unit_type} [{self.state.x_display_unit}]"
self.figure.axes[1].label = f"{flux_unit_type} [{self.state.y_display_unit}]"

# Make it so axis labels are not covering tick numbers.
Expand Down
90 changes: 90 additions & 0 deletions notebooks/concepts/cubeviz-roman-ramp.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "b3e22694-d8ee-4c14-8931-8f8db1d7485d",
"metadata": {
"tags": []
},
"source": [
"## PoC: Visualize a Roman L1 ramp file in Cubeviz\n",
"\n",
"First download a synthetic Roman L1 file:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e80524dd-bcc5-4312-879a-33780e297006",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"from urllib.request import urlretrieve\n",
"\n",
"from jdaviz import Cubeviz\n",
"\n",
"force_download = False\n",
"\n",
"url_L1 = \"https://stsci.box.com/shared/static/80vahj27t3y02itfohc22p999snkcocw.asdf\"\n",
"local_path = \"L1.asdf\"\n",
"\n",
"if not os.path.exists(local_path) or force_download:\n",
" urlretrieve(url_L1, local_path)"
]
},
{
"cell_type": "markdown",
"id": "0f94fbf1-6f4c-4118-917d-de824af57fe6",
"metadata": {},
"source": [
"Open the ramp in Cubeviz:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "863ce611-bf38-4a97-bd1d-c0ff79d36073",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"cubeviz = Cubeviz()\n",
"cubeviz.load_data(local_path, data_label='Roman L1')\n",
"cubeviz.show(height=1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4312b177-e0d5-45da-95ba-81c910ffff4f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit fd66649

Please sign in to comment.