Skip to content

Commit

Permalink
Merge pull request #141 from keflavich/header_NAXIS
Browse files Browse the repository at this point in the history
Include correct NAXIS in header
  • Loading branch information
keflavich committed Sep 8, 2014
2 parents 29f942a + f8b89c6 commit d2ed5cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,10 @@ def header(self):
header = self._header.copy()
header.update(self.wcs.to_header())
header['BUNIT'] = self.unit.to_string(format='fits')
header['NAXIS'] = self._data.ndim
header['NAXIS1'] = self.shape[2]
header['NAXIS2'] = self.shape[1]
header['NAXIS3'] = self.shape[0]
# TODO: incorporate other relevant metadata here
return header

Expand Down
9 changes: 9 additions & 0 deletions spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,15 @@ def test_endians():
assert xbig.dtype.byteorder == '>'
assert xlil.dtype.byteorder == '='

def test_header_naxis():

cube, data = cube_and_raw('advs.fits')

assert cube.header['NAXIS'] == 3 # NOT data.ndim == 4
assert cube.header['NAXIS1'] == data.shape[3]
assert cube.header['NAXIS2'] == data.shape[2]
assert cube.header['NAXIS3'] == data.shape[1]

def test_slicing():

cube, data = cube_and_raw('advs.fits')
Expand Down

0 comments on commit d2ed5cd

Please sign in to comment.