Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot allocate memory #299

Merged
merged 2 commits into from
May 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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):
Copy link
Contributor

@e-koch e-koch May 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't mode passed through kwargs from SpectralCube.read to here already? I regularly use mode='denywrite' and haven't run into memory issues when dealing with big cubes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But I think this should be the default, as we don't expect users to be modifying the cube data inplace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. Agreed.

"""
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