-
Notifications
You must be signed in to change notification settings - Fork 9
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
Roundtripping spectra and to what extent we should warn users / expect metadata? #79
Comments
At first glance, it seems like one could simply put a warning in the if file is not None:
# [...]
super().__init__(
spectral_axis=lamb.to(u.Angstrom),
flux=flux,
mask=mask,
wcs=None,
uncertainty=uncertainty,
meta=meta_dict,
**kwargs,
)
else:
super().__init__(*args, **kwargs)
if not ("header" in self.meta.keys()):
log.warn(
"The spectrum metadata appears to be missing. "
"The functionality of muler may be impaired without metadata. "
"See discussion at https://github.com/OttoStruve/muler/issues/79."
) I tried this and it works when I attempt the roundtripping: spec = IGRINSSpectrum(file=full_path)
wavelength = spec.wavelength
flux = spec.flux
roundtrip_spec = IGRINSSpectrum(spectral_axis=wavelength, flux=flux)
The warning message goes away if you put However, it over-produces the warning, for reasons I did not anticipate and that may reveal an overzealous-albeit-harmless copy strategy going on behind the scenes: spec.normalize() # erroneously produces the warning IGRINSSpectrumList operations also produce the warnings (one for each order, ouch). Two takeaways:
|
Hi @gully, |
Recapping what @ericasaw and I just talked about in the hallway, you should have a FITS header in the zeroth index in the Line 107 in 3b6f7cd
Can you verify the The other conceivable hiccup is that some Can you inspect the sequence of operations that led to this warning to see if any math operations may suffer from this metadata amnesia? |
@ericasaw raised the issue of "roundtripping" a spectrum:
This pattern is currently supported in
muler
:but with one huge caveat: not all methods will successfully work after roundtripping.
So the question arises: how much do we want to support spectra created in this slightly non-standard, but still possible manner?
A good example use case is barycentric correction: Imagine you have a "roundtripped" spectrum, and you try to run
barycentric_correct( )
. It will generally not have themeta
normeta['header']
attributes that it needs to determine the BERV. So should we :KeyError
)@ericasaw and I agree that solution 1 is both expedient and useful to the users.
Open questions:
What other methods are expected to fail when using a spectrum that has been generated through round-tripping?
Should we recommend that folks provide a
header=
input when handing in theflux
andwavelength
?The text was updated successfully, but these errors were encountered: