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

[BUG] MOSVIZ raises an exception on loading a JWST S2D file. #3300

Open
york-stsci opened this issue Nov 18, 2024 · 2 comments
Open

[BUG] MOSVIZ raises an exception on loading a JWST S2D file. #3300

york-stsci opened this issue Nov 18, 2024 · 2 comments
Labels
bug Something isn't working mosviz

Comments

@york-stsci
Copy link

york-stsci commented Nov 18, 2024

Jdaviz component

Mosviz

Description

If mosvis.load_data() is run with directory=(path to a directory containing a single JWST NIRSpec S2D file), and instrument=nirspec, it crashes in the load_data() function with an error about not being able to find the 1D spectra. In particular, it raises an exception at:

"site-packages/jdaviz/configs/mosviz/plugins/parsers.py" line 131, with the error:
KeyError: 'ComponentID not found or not unique: 1D Spectra'

Tracing the issue, I see that, in the load_data function, in site-packages/jdaviz/configs/mosviz/helper.py lines 333-346, if directory is specified, then Mosviz automatically runs, at line 417, the link_table function, which fails because it tries to link together 2D and 1D spectra, but an S2D file only contains 2D spectra.

Elsewhere in the helper.py file, if only 2D spectra are specified when running load_data, the variable "allow_link_table" is set to False, which would also solve this particular issue.

How to Reproduce

  1. Install Jdaviz 4.0.0 with "pip install jdaviz"
  2. Download the JWST NIRSpec S2D file jw01211013001_08101_00001_nrs2_s2d.fits from MAST, and put it in a directory by itself.
  3. Run python, import Jdaviz, and import Mosviz
  4. Create a Mosviz() object
  5. Run `mosviz.load_data(directory="directory created in step 2", instrument="nirspec")
  6. An error occurs.

Expected behavior

There should not be an exception, and the mosviz object should be able to load the directory. It probably won't be a very satisfying output, because there's no image and no 1D spectra, but it will at least exist, and be possible to display.

Browser

No response

Jupyter

N/A

Software versions

>>> import platform; print(platform.platform())
macOS-14.7.1-arm64-arm-64bit
>>> import sys; print("Python", sys.version)
Python 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:26:25) [Clang 17.0.6 ]
>>> import numpy; print("Numpy", numpy.__version__)
Numpy 1.26.4
>>> import astropy; print("astropy", astropy.__version__)
astropy 6.1.6
>>> import matplotlib; print("matplotlib", matplotlib.__version__)
matplotlib 3.9.2
>>> import scipy; print("scipy", scipy.__version__)
scipy 1.14.1
>>> import skimage; print("scikit-image", skimage.__version__)
scikit-image 0.24.0
>>> import asdf; print("asdf", asdf.__version__)
asdf 3.5.0
>>> import stdatamodels; print("stdatamodels", stdatamodels.__version__)
stdatamodels 2.1.2
>>> import gwcs; print("gwcs", gwcs.__version__)
gwcs 0.21.0
>>> import regions; print("regions", regions.__version__)
regions 0.10
>>> import specutils; print("specutils", specutils.__version__)
specutils 1.19.0
>>> import specreduce; print("specreduce", specreduce.__version__)
specreduce 1.4.1
>>> import photutils; print("photutils", photutils.__version__)
photutils 2.0.2
>>> import astroquery; print("astroquery", astroquery.__version__)
astroquery 0.4.7
>>> import yaml; print("pyyaml", yaml.__version__)
pyyaml 6.0.1
>>> import asteval; print("asteval", asteval.__version__)
asteval 1.0.5
>>> import idna; print("idna", idna.__version__)
idna 3.4
>>> import traitlets; print("traitlets", traitlets.__version__)
traitlets 5.14.3
>>> import bqplot; print("bqplot", bqplot.__version__)
bqplot 0.12.43
>>> import bqplot_image_gl; print("bqplot-image-gl", bqplot_image_gl.__version__)
bqplot-image-gl 1.5.0
>>> import glue; print("glue-core", glue.__version__)
glue-core 1.21.1
>>> import glue_jupyter; print("glue-jupyter", glue_jupyter.__version__)
glue-jupyter 0.23.1
>>> import glue_astronomy; print("glue-astronomy", glue_astronomy.__version__)
glue-astronomy 0.10.0
>>> import echo; print("echo", echo.__version__)
echo 0.9.0
>>> import ipyvue; print("ipyvue", ipyvue.__version__)
ipyvue 1.11.0
>>> import ipyvuetify; print("ipyvuetify", ipyvuetify.__version__)
ipyvuetify 1.10.0
>>> import ipysplitpanes; print("ipysplitpanes", ipysplitpanes.__version__)
ipysplitpanes 0.2.0
>>> import ipygoldenlayout; print("ipygoldenlayout", ipygoldenlayout.__version__)
ipygoldenlayout 0.4.0
>>> import ipypopout; print("ipypopout", ipypopout.__version__)
ipypopout 2.0.0
>>> import jinja2; print("Jinja2", jinja2.__version__)
Jinja2 3.1.2
>>> import solara; print("solara", solara.__version__)
solara 1.40.0
>>> import vispy; print("vispy", vispy.__version__)
vispy 0.14.3
>>> import sidecar; print("sidecar", sidecar.__version__)
sidecar 0.7.0
>>> import jdaviz; print("Jdaviz", jdaviz.__version__)
Jdaviz 4.0.0

🐱

@york-stsci york-stsci added bug Something isn't working needs-triage Issue opened via template and needs triaging labels Nov 18, 2024
@pllim pllim added mosviz and removed needs-triage Issue opened via template and needs triaging labels Nov 25, 2024
@MarianConstantinMarica
Copy link

Can I work on this?

@MarianConstantinMarica
Copy link

MarianConstantinMarica commented Dec 24, 2024

The issue with "allow_link_table" not being set to False occurs because:

  1. When the method is called, only path to directory and instrument are provided, while other parameters remain None.
  2. Since path to directory is not None, the if block at line 334 executes, skipping all linked elif statements.
  3. The skipped elif statements contain the logic to set "allow_link_table" to False, which is why it remains unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mosviz
Projects
None yet
Development

No branches or pull requests

3 participants