-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix: SDSS-V SpectrumList format ambiguity, mwmVisit BOSS load fail #1185
Changes from 3 commits
b6851a6
51e8a2e
4bee136
b70c393
62747c4
8df1f77
bafede9
122b368
0c5fe8f
32534a2
ca4d8c3
62152c0
65b5709
9960f98
87fa13f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,9 +183,10 @@ def load_sdss_apStar_1D(file_obj, idx: int = 0, **kwargs): | |
|
||
|
||
@data_loader( | ||
"SDSS-V apStar multi", | ||
"SDSS-V apStar", | ||
identifier=apStar_identify, | ||
dtype=SpectrumList, | ||
force=True, | ||
priority=10, | ||
extensions=["fits"], | ||
) | ||
|
@@ -259,9 +260,10 @@ def load_sdss_apVisit_1D(file_obj, **kwargs): | |
|
||
|
||
@data_loader( | ||
"SDSS-V apVisit multi", | ||
"SDSS-V apVisit", | ||
identifier=apVisit_identify, | ||
dtype=SpectrumList, | ||
force=True, | ||
priority=10, | ||
extensions=["fits"], | ||
) | ||
|
@@ -312,6 +314,7 @@ def load_sdss_apVisit_list(file_obj, **kwargs): | |
|
||
# BOSS REDUX products (specLite, specFull, custom coadd files, etc) | ||
|
||
|
||
@data_loader( | ||
"SDSS-V spec", | ||
identifier=spec_sdss5_identify, | ||
|
@@ -337,6 +340,7 @@ def load_sdss_spec_1D(file_obj, *args, hdu: Optional[int] = None, **kwargs): | |
""" | ||
if hdu is None: | ||
# TODO: how should we handle this -- multiple things in file, but the user cannot choose. | ||
print('HDU not specified. Loading coadd spectrum (HDU1)') | ||
hdu = 1 # defaulting to coadd | ||
# raise ValueError("HDU not specified! Please specify a HDU to load.") | ||
elif hdu in [2, 3, 4]: | ||
|
@@ -347,9 +351,10 @@ def load_sdss_spec_1D(file_obj, *args, hdu: Optional[int] = None, **kwargs): | |
|
||
|
||
@data_loader( | ||
"SDSS-V spec multi", | ||
"SDSS-V spec", | ||
identifier=spec_sdss5_identify, | ||
dtype=SpectrumList, | ||
force=True, | ||
priority=5, | ||
extensions=["fits"], | ||
) | ||
|
@@ -462,14 +467,17 @@ def load_sdss_mwm_1d(file_obj, hdu: Optional[int] = None, **kwargs): | |
for i in range(len(hdulist)): | ||
if hdulist[i].header.get("DATASUM") != "0": | ||
hdu = i | ||
print('HDU not specified. Loading spectrum at (HDU{})'. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just a warning or is specifying an HDU required? For production, we use Jdaviz to load the file, and want by default all data extensions loaded, without having to specify an HDU, which I think will be the most common use case by users as well. Does this result in many constant warning messages printed to the user? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how we want to handle this case generally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I agree that the APOGEE/BOSS extensions should not be loaded into a single Spectrum1D. They should be loaded into a SpectrumList. I think the warning is fine. It's useful for anyone using |
||
format(i)) | ||
rileythai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break | ||
|
||
return _load_mwmVisit_or_mwmStar_hdu(hdulist, hdu, **kwargs) | ||
|
||
|
||
@data_loader( | ||
"SDSS-V mwm multi", | ||
"SDSS-V mwm", | ||
identifier=mwm_identify, | ||
force=True, | ||
dtype=SpectrumList, | ||
priority=20, | ||
extensions=["fits"], | ||
|
@@ -578,23 +586,24 @@ def _load_mwmVisit_or_mwmStar_hdu(hdulist: HDUList, hdu: int, **kwargs): | |
meta["snr"] = np.array(hdulist[hdu].data["snr"]) | ||
|
||
# Add identifiers (obj, telescope, mjd, datatype) | ||
# TODO: need to see what metadata we're interested in for the MWM files. | ||
meta["telescope"] = hdulist[hdu].data["telescope"] | ||
meta["instrument"] = hdulist[hdu].header.get("INSTRMNT") | ||
try: | ||
try: # get obj if exists | ||
meta["obj"] = hdulist[hdu].data["obj"] | ||
except KeyError: | ||
pass | ||
|
||
# choose between mwmVisit/Star via KeyError except | ||
try: | ||
meta["date"] = hdulist[hdu].data["date_obs"] | ||
meta["mjd"] = hdulist[hdu].data["mjd"] | ||
meta['mjd'] = hdulist[hdu].data['mjd'] | ||
meta["datatype"] = "mwmVisit" | ||
except KeyError: | ||
meta["mjd"] = (str(hdulist[hdu].data["min_mjd"][0]) + "->" + | ||
str(hdulist[hdu].data["max_mjd"][0])) | ||
meta["datatype"] = "mwmStar" | ||
finally: | ||
meta["name"] = hdulist[hdu].name | ||
meta["sdss_id"] = hdulist[hdu].data['sdss_id'] | ||
|
||
return Spectrum1D( | ||
spectral_axis=spectral_axis, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the
multi
removed, what is the difference between this data loader and the above data loader at line 318? Same with themwm
data loaders?With this removal, what would be the correct
format
to specify to load all data extensions? Is it now the default? Jdaviz only supports usingformat
during data load to provide hints to the type of filepath.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal with this was to simplify the interface. The difference previously was that
multi
loaded every valid HDU extension, whereas the singleSpectrumList
ones would load just a specified HDU. Since it's aSpectrumList
, I felt the default loader for that type should just load every extension.Across both the
Spectrum1D
andSpectrumList
loaders there should be a single format (SDSS-V [DATATYPE]
), which should be detected automagically and no longer needs to be manually specified onSpectrumList
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue might be mostly in Specviz. I'd like to retain the workflow of passing Specviz a single file and having it load all spectra from all extensions. Specviz uses the following https://github.com/spacetelescope/jdaviz/blob/main/jdaviz/configs/specviz/plugins/parsers.py#L78-L87 to load a specutils object from a file, which first attempts to load a Spectrum1D with a format option, and on fail, tries to load the SpectrumList with a format option.
With the
multi
option, I can explicitly tell Specviz to load using the SpectrumList loader, which will break will this change. Specviz only allows me to pass in aformat
keyword to specutils. Previously usingSDSS-V mwm multi
on themwmStar
files allowed me to load all spectra, since it triggered line 87. With this, it only loads the first spectrum from the first extension found.In my mind, the easiest fix would be to reintroduce the
multi
here, but maybe it's more appropriate to fix Specviz instead. @rosteen since you're a maintainer/dev of bothspecutils
andjdaviz
, do you have thoughts on the best approach, and/or where the fix should go?I am testing with the mwmStar and mwmVisit files for id 61731453, which has spectra in both the BOSS and APOGEE extensions. the mwmStar file has 1 spectrum per extension. The mwmVisit file has 1 spectrum in the BOSS extension, and 3 spectra in the APOGEE extension, loaded as a SpectrumList of 2 Spectrum1D objects, with
flux.shapes
of((4648,), (3, 8575))
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to catch up on this this afternoon, I might have thoughts then.