astropy / astropy/specutils

Update WCS in spectral_slab output

Open
#869 0 comments 0 reactions 0 assignees View on GitHub
manipulation
Dominant language
Python
Stars
204
Forks
134
Avg merge
12h 55m
Merged PRs (30d)
1

Description

While spectral slab does output the correct sub-wavelength range as a new Spectrum1D, it does not appear to update the WCS to match. This means going through a lot of trouble to update the wcs manually, like this:
```python
import astropy.wcs as fitswcs
from specutils.manipulation import spectral_slab

my_wcs = fitswcs.WCS(header_cube)
spec1d = Spectrum1D(flux = cube*u.Jy, wcs=my_wcs)
trim=[1.57E-6*u.m, 1.62E-6*u.m]
spec1d_t = spectral_slab(spec1d, trim[0], trim[1])
cube_trimmed = spec1d_t.flux.value

#Adjust wcs to trimmed cube because spectral_slab doesn't
new_wcs = spec1d_t.wcs
new_wcs.wcs.crval[0] = trim[0].value #Change wave crval to match trim region
print(new_wcs)

spec1d_trimmed = Spectrum1D(flux=cube_trimmed * u.Jy, wcs=new_wcs)
```

Contributor guide

Open the contributing guide

Research direction

Start at the spectral_slab entry point and reproduce the supplied Spectrum1D example with the stated wavelength limits. Compare the returned Spectrum1D WCS with the trimmed spectral range; done means the output WCS matches that range without requiring the manual adjustment shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.