Skip to content

Commit

Permalink
Merge pull request #33 from spacetelescope/memory_bug
Browse files Browse the repository at this point in the history
Changing memmap mode
  • Loading branch information
C. E. Brasseur committed May 20, 2020
2 parents e8c6559 + 0d2bfd8 commit 80f387a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -3,6 +3,7 @@
- Update wcs fitting to match Astropy (and use Astropy when available) [#29]
- Limit the number of pixels used for WCS fitting to 100 [#30]
- Deprecate drop_after and handle inconsistant wcs keywords automatically [#31]
- Change the memmap access mode from ACCESS_COPY to ACCESS_READ to lower memory usage. [#33]


0.5 (2020-01-13)
Expand Down
2 changes: 1 addition & 1 deletion astrocut/cube_cut.py
Expand Up @@ -735,7 +735,7 @@ def cube_cut(self, cube_file, coordinates, cutout_size,
start_time = time()

warnings.filterwarnings("ignore", category=wcs.FITSFixedWarning)
with fits.open(cube_file) as cube:
with fits.open(cube_file, mode='denywrite', memmap=True) as cube:

# Get the info we need from the data table
self._parse_table_info(cube[2].header, cube[2].data, verbose)
Expand Down
4 changes: 2 additions & 2 deletions astrocut/cutouts.py
Expand Up @@ -448,7 +448,7 @@ def fits_cut(input_files, coordinates, cutout_size, correct_wcs=False, drop_afte
print("\n{}".format(in_fle))

warnings.filterwarnings("ignore", category=wcs.FITSFixedWarning)
with fits.open(in_fle) as hdulist:
with fits.open(in_fle, mode='denywrite', memmap=True) as hdulist:
try:
cutout = _hducut(hdulist[0], coordinates, cutout_size,
correct_wcs=correct_wcs, verbose=verbose)
Expand Down Expand Up @@ -677,7 +677,7 @@ def img_cut(input_files, coordinates, cutout_size, stretch='asinh', minmax_perce
for in_fle in input_files:
if verbose:
print("\n{}".format(in_fle))
hdulist = fits.open(in_fle)
hdulist = fits.open(in_fle, mode='denywrite', memmap=True)
cutout = _hducut(hdulist[0], coordinates, cutout_size,
correct_wcs=False, verbose=verbose)
hdulist.close()
Expand Down
6 changes: 3 additions & 3 deletions astrocut/make_cube.py
Expand Up @@ -99,7 +99,7 @@ def make_cube(self, file_list, cube_file="img-cube.fits", sector=None, verbose=T
good_header_ind = None

for i, ffi in enumerate(file_list):
ffi_data = fits.open(ffi)
ffi_data = fits.open(ffi, mode='denywrite', memmap=True)

start_times[i] = ffi_data[1].header.get("TSTART") # TODO: optionally pass this in?

Expand All @@ -124,7 +124,7 @@ def make_cube(self, file_list, cube_file="img-cube.fits", sector=None, verbose=T
if verbose:
print("Using {} to initialize the image header table.".format(os.path.basename(fle)))

ffi_data = fits.open(fle)
ffi_data = fits.open(fle, mode='denywrite', memmap=True)

# The image specific header information will be saved in a table in the second extension
secondary_header = ffi_data[1].header
Expand All @@ -151,7 +151,7 @@ def make_cube(self, file_list, cube_file="img-cube.fits", sector=None, verbose=T
# Loop through files
for i, fle in enumerate(file_list[sorted_indices]):

ffi_data = fits.open(fle)
ffi_data = fits.open(fle, mode='denywrite', memmap=True)

# if the arrays/header aren't initialized do it now
if img_cube is None:
Expand Down

0 comments on commit 80f387a

Please sign in to comment.