Allow spectralcoord to be less restrictive in its metadata for spectrumcollection
- Dominant language
- Python
- Stars
- 204
- Forks
- 134
- Avg merge
- 12h 55m
- Merged PRs (30d)
- 1
Description
This is a follow-on from #619. As visible in the diff tied to the discussion thread https://github.com/astropy/specutils/pull/619#discussion_r399368534, right now the `SpectrumCollection` initializer has the restriction that if you combine together multiple spectra with `SpectralCoord`'s that don't have identical `redshift`/`observer`/`target`, it fails. This is problematic for a few reasons:
1. It's plausible a user just doesn't want to deal with many `SpectralCoord` and therefore wants to add the metadata manually, but it's annoying to have to do that for *every* sub-spectrum they're putting into a collection. So the natural fix to me would be to allow the first spectrum to have `redshift`/`observer`/`target` and all the others have `None`, and in that case you just use the first one.
2. #634 highlights some use cases where the `SpectralCoord` can be multi-dimensional. In that case, they might not be equal but rather should be combined into one "big" `SpectralCoord` with the appropriate broadcasting (although the logic for that might end up so complicated it's better to make the user do it? Would need to make a few test cases and try it out to see how complex the code gets, I think.)
3. `observer` and `target` are Astropy coordinate objects, and coordinate objects have a pretty strict interpretation of "equality" - basically the same as `is`. In the case of `SpectrumCollection`, it's not implausible that a user is creating several `target` objects that point to the same *place*, but aren't necessarily identical objects. I.e., the user might create spectral coords like:
```
sc1 = SpectralCoord([1,2, ...]*u.um, target=ICRS(12*u.deg, 13*u.deg))
sc2 = SpectralCoord([3,4, ...]*u.um, target=ICRS(12*u.deg, 13*u.deg))
```
and then *think* that this could be combinable in a `SpectrumCollection` because they're the same target. But they are not "the same" in that they are two different objects, so it would fail.
The above cases might best be treated as three separate PRs now that I look at it, although maybe they're mixed together enough they should be just one?
Contributor guide
Research direction
Start with the SpectrumCollection initializer and the SpectralCoord metadata handling described here, then read the discussion linked from #619 and the use cases in #634. Determine which combinations of redshift, observer, target, and multidimensional coordinates should be supported, and add tests covering the agreed behavior before considering the work done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100