Skip to content

Commit

Permalink
Require specification of spectral_axis_index if WCS is 1D and flux is…
Browse files Browse the repository at this point in the history
… multi-D
  • Loading branch information
rosteen committed Jan 3, 2023
1 parent a29f6a6 commit 701b3b7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion specutils/spectra/spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ def __init__(self, flux=None, spectral_axis=None, spectral_axis_index=None,
# order compared to the data array.
self._spectral_axis_index = len(flux.shape)-temp_axes[0]-1
else:
self._spectral_axis_index = 0
if flux is not None and flux.ndim == 1:
self._spectral_axis_index = 0
else:
if self.spectral_axis_index is None:
raise ValueError("WCS is 1D but flux is multi-dimensional. Please"
" specify spectral_axis_index.")

# Attempt to parse the spectral axis. If none is given, try instead to
# parse a given wcs. This is put into a GWCS object to
Expand Down

0 comments on commit 701b3b7

Please sign in to comment.