Skip to content

Commit

Permalink
Merge pull request #299 from keflavich/huge-file-issue299
Browse files Browse the repository at this point in the history
Cannot allocate memory
  • Loading branch information
keflavich committed May 19, 2016
2 parents c09ac14 + e82b66a commit 2c6575f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions spectral_cube/io/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def is_fits(input, **kwargs):
return False


def read_data_fits(input, hdu=None, **kwargs):
def read_data_fits(input, hdu=None, mode='denywrite', **kwargs):
"""
Read an array and header from an FITS file.
Expand All @@ -58,6 +58,11 @@ def read_data_fits(input, hdu=None, **kwargs):
- :class:`~astropy.io.fits.hdu.hdulist.HDUList`
hdu : int or str, optional
The HDU to read the table from.
mode : str
One of the FITS file reading modes; see `~astropy.io.fits.open`.
``denywrite`` is used by default since this prevents the system from
checking that the entire cube will fit into swap, which can prevent the
file from being opened at all.
"""

beam_table = None
Expand Down Expand Up @@ -100,7 +105,7 @@ def read_data_fits(input, hdu=None, **kwargs):

else:

hdulist = fits_open(input, **kwargs)
hdulist = fits_open(input, mode=mode, **kwargs)

try:
return read_data_fits(hdulist, hdu=hdu)
Expand Down
2 changes: 1 addition & 1 deletion spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def cube_and_raw(filename):

d = fits.getdata(p)

c = SpectralCube.read(p, format='fits')
c = SpectralCube.read(p, format='fits', mode='readonly')
return c, d


Expand Down

0 comments on commit 2c6575f

Please sign in to comment.