Open kykyelric opened 1 month ago
Hmm, I haven't run into this, and I was unable to reproduce locally. What happens if you just try from stdatamodels.util import convert_fitsrec_to_array_in_tree
in python? It seems like it might be a problem with your stdatamodels
installation.
Hmm, I haven't run into this, and I was unable to reproduce locally. What happens if you just try
from stdatamodels.util import convert_fitsrec_to_array_in_tree
in python? It seems like it might be a problem with yourstdatamodels
installation.
This imported just fine when I run python in terminal. Strange.
That is odd. I would probably try reinstalling specutils
and see if that fixes the issue - I don't know if there's some way it could have ended up looking for stdatamodels
in the wrong place, but you never know.
Unfortunately that didn't work. I found a way to accomplish what I needed to via a different package than specutils, but I hope this issue can get resolved later.
What is the full traceback leading to that error? That would help track this down if it's something on our end. As-is, without being able to reproduce the error with the package versions you posted, I can't fix it.
ImportError Traceback (most recent call last)
Cell In[77], line 14
10 q3di = q3din(name, 'test', datext=1, varext=2, dqext=3,
11 outdir='F20551-4250/s3d_files/test/',
12 logfile='F20551-4250/s3d_files/test/ch'+str(i+1)+'-fitlog.txt')
13 wav = q3di.load_cube().wave
---> 14 spec1d = Spectrum1D.read(name)
15 #wav = np.array(spec1d.spectral_axis.value)
16 corr_interp = interp1d(corrx, corry)(wav)
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/astropy/nddata/mixins/ndio.py:59, in NDDataRead.__call__(self, *args, **kwargs)
58 def __call__(self, *args, **kwargs):
---> 59 return self.registry.read(self._cls, *args, **kwargs)
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/astropy/io/registry/core.py:218, in UnifiedInputRegistry.read(self, cls, format, cache, *args, **kwargs)
213 format = self._get_valid_format(
214 "read", cls, path, fileobj, args, kwargs
215 )
217 reader = self.get_reader(format, cls)
--> 218 data = reader(*args, **kwargs)
220 if not isinstance(data, cls):
221 # User has read with a subclass where only the parent class is
222 # registered. This returns the parent class, so try coercing
223 # to desired subclass.
224 try:
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/specutils/io/default_loaders/jwst_reader.py:539, in jwst_s3d_single_loader(filename, **kwargs)
521 @data_loader(
522 "JWST s3d", identifier=identify_jwst_s3d_fits, dtype=Spectrum1D,
523 extensions=['fits'], priority=10,
524 )
525 def jwst_s3d_single_loader(filename, **kwargs):
526 """
527 Loader for JWST s3d 3D rectified spectral data in FITS format.
528
(...)
537 The spectrum contained in the file.
538 """
--> 539 spectrum_list = _jwst_s3d_loader(filename, **kwargs)
540 if len(spectrum_list) == 1:
541 return spectrum_list[0]
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/specutils/io/default_loaders/jwst_reader.py:563, in _jwst_s3d_loader(filename, **kwargs)
549 def _jwst_s3d_loader(filename, **kwargs):
550 """
551 Loader for JWST s3d 3D rectified spectral data in FITS format.
552
(...)
561 The spectra contained in the file.
562 """
--> 563 from stdatamodels import asdf_in_fits
565 spectra = []
567 # Get a list of GWCS objects from the slits
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/stdatamodels/__init__.py:1
----> 1 from .model_base import DataModel
2 from . import _version
5 __all__ = ['DataModel', '__version__']
File ~/anaconda3/envs/correct_cube/lib/python3.12/site-packages/stdatamodels/model_base.py:28
26 from . import properties
27 from . import schema as mschema
---> 28 from . import validate
29 from .util import get_envar_as_boolean, remove_none_from_tree
30 from . import s3_utils
ImportError: cannot import name 'convert_fitsrec_to_array_in_tree' from 'stdatamodels.util' (/home/kydan/anaconda3/envs/correct_cube/lib/python3.12/site-packages/stdatamodels/util.py)
Hmm, looks like this could be ASDF-related. Could you tell me what the output of pip list | grep asdf
is for you?
asdf 3.2.0
asdf-astropy 0.5.0
asdf-coordinates-schemas 0.2.0
asdf_standard 1.1.1
asdf_transform_schemas 0.5.0
asdf-unit-schemas 0.1.0
asdf-wcs-schemas 0.3.0
Hm, some of those are out of date compared to what I have. Have you tried installing specutils in a fresh environment to ensure you have up-to-date/compatible package versions? I downgraded my asdf
packages (and gwcs
for compatibility) to what you have there and still couldn't reproduce, so I think new environment is probably the best way to solve this if you haven't tried it already. It seems to be an upstream package thing, not specutils
, but I remain stumped on what package or why.
I am already using an isolated conda environment. I can export an environment file if you'd like to try it?
I am already using an isolated conda environment. I can export an environment file if you'd like to try it?
Sure. I guess my question was more "when was the environment created", in case it's older and something didn't get updated that was needed for compatibility. But yes, the env export or pip list would help.
name: correct_cube channels:
Hi all, I ran into an issue with reading JWST MRS cubes. Is this a known issue or have others run into this problem before?
spec1d = Spectrum1D.read('file_s3d.fits')
ImportError: cannot import name 'convert_fitsrec_to_array_in_tree' from 'stdatamodels.util'
specutils version: 1.15.1.dev6+g28b0cdb stdatamodels version: 1.10.2.dev5+g0326fd4 python version: 3.12.2