Skip to content

Always open FITS files with memmap=False - #1407

Merged
cdeil merged 1 commit into
gammapy:masterfrom
cdeil:memmap
May 7, 2018
Merged

cdeil merged 1 commit into
gammapy:masterfrom
cdeil:memmap

Conversation

@cdeil

@cdeil cdeil commented May 6, 2018

Copy link
Copy Markdown
Contributor

This PR changes all read methods in Gammapy to use with fits.open(filename, memmap=False).

See discussion in #1055 and astropy/astropy#7440 .

I plan to merge if CI passes.

But comments are still welcome of course. Especially @woodmd or anyone, if you know of cases where memmap=True should definitely be used (e.g. for maps) for performance reasons. My understanding is that the performance difference should be small for most of our use cases, and thus given that memmap=False leads to predictable behaviour of FITS files always being closed at the end of read methods, just putting memmap=False everywhere is somehow the simple & safe default to put for now.

@cdeil cdeil added the astropy label May 6, 2018
@cdeil cdeil added this to the 0.8 milestone May 6, 2018
@cdeil cdeil self-assigned this May 6, 2018
Comment thread gammapy/spectrum/core.py

return spec
with fits.open(str(filename), memmap=False) as hdulist:
return cls.from_hdulist(hdulist, hdu1=hdu1, hdu2=hdu2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@joleroi - Was there a good reason to catch the KeyError and raise a ValueError instead?

My suggestion would be that here in gammapy.spectrum we just let the KeyError appear if users try to access HDUs that aren't there; otherwise we get mixed behaviour / errors from Gammapy read methods.

@cdeil
cdeil merged commit c209481 into gammapy:master May 7, 2018
alexcervino pushed a commit to alexcervino/gammapy that referenced this pull request Jul 4, 2026
Always open FITS files with memmap=False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant