diff --git a/spectral_cube/io/fits.py b/spectral_cube/io/fits.py index e3701b69f..94263d171 100644 --- a/spectral_cube/io/fits.py +++ b/spectral_cube/io/fits.py @@ -96,7 +96,7 @@ def read_data_fits(input, hdu=None, **kwargs): return array_hdu.data, array_hdu.header -def load_fits_cube(input, hdu=0, meta={}): +def load_fits_cube(input, hdu=0, meta={}, **kwargs): """ Read in a cube from a FITS file using astropy. @@ -110,7 +110,7 @@ def load_fits_cube(input, hdu=0, meta={}): Metadata (can be inherited from other readers, for example) """ - data, header = read_data_fits(input, hdu=hdu) + data, header = read_data_fits(input, hdu=hdu, **kwargs) if 'BUNIT' in header: meta['BUNIT'] = header['BUNIT'] diff --git a/spectral_cube/masks.py b/spectral_cube/masks.py index d32d7fa51..dba6712b1 100644 --- a/spectral_cube/masks.py +++ b/spectral_cube/masks.py @@ -188,7 +188,8 @@ def __invert__(self): return InvertedMask(self) def __getitem__(self): - raise NotImplementedError("Slicing not supported by mask class {0}".format(self.__class__.__name__)) + raise NotImplementedError("Slicing not supported by mask class {0}" + .format(self.__class__.__name__)) def quicklook(self, view, wcs=None, filename=None, use_aplpy=True): ''' diff --git a/spectral_cube/spectral_cube.py b/spectral_cube/spectral_cube.py index ca8f0cad4..0bf7b8468 100644 --- a/spectral_cube/spectral_cube.py +++ b/spectral_cube/spectral_cube.py @@ -242,6 +242,11 @@ def size(self): """ Number of elements in the cube """ return self._data.size + @property + def base(self): + """ The data type 'base' of the cube - useful for, e.g., joblib """ + return self._data.base + def __len__(self): return self.shape[0] @@ -943,7 +948,7 @@ def __getitem__(self, view): newwcs = self._wcs.sub([a for a in (1,2,3) if a not in [x+1 for x in intslices]]) - return OneDSpectrum(value=self.filled_data[view], + return OneDSpectrum(value=self._data[view], wcs=newwcs, copy=False, unit=self.unit, diff --git a/spectral_cube/tests/test_spectral_cube.py b/spectral_cube/tests/test_spectral_cube.py index d2954301d..8c4af4da4 100644 --- a/spectral_cube/tests/test_spectral_cube.py +++ b/spectral_cube/tests/test_spectral_cube.py @@ -2,6 +2,7 @@ import operator import itertools import warnings +import mmap # needed to test for warnings later warnings.simplefilter('always', UserWarning) @@ -601,6 +602,21 @@ def test_read_write_rountrip(tmpdir): # maximized assert cube._wcs.to_header_string() == cube2._wcs.to_header_string() +@pytest.mark.parametrize(('memmap', 'base'), + ((True, mmap.mmap), + (False, None))) +def test_read_memmap(memmap, base): + cube = SpectralCube.read(path('adv.fits'), memmap=memmap) + + bb = cube.base + while hasattr(bb, 'base'): + bb = bb.base + + if base is None: + assert bb is None + else: + assert isinstance(bb, base) + def _dummy_cube(): data = np.array([[[0, 1, 2, 3, 4]]])