Skip to content

Commit

Permalink
Deprecate automatic changes to the tile size with HCOMPRESS_1
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Feb 17, 2023
1 parent 6fda4d5 commit 9445c4a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions astropy/io/fits/hdu/compressed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import numpy as np

from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.io.fits import conf
from astropy.io.fits._tiled_compression import compress_hdu, decompress_hdu
from astropy.io.fits.card import Card
Expand Down Expand Up @@ -1103,6 +1104,8 @@ def _update_header_data(

remain = self._image_header["NAXIS1"] % tile_size[0] # 1st dimen

original_tile_size = tile_size[:]

if remain > 0 and remain < 4:
tile_size[0] += 1 # try increasing tile size by 1

Expand All @@ -1125,6 +1128,13 @@ def _update_header_data(
"Last tile along 2nd dimension has less than 4 pixels"
)

if tile_size != original_tile_size:
warnings.warn(f"The data size should be a multiple of the tile "
f"size. The tile size has automatically been changed "
f"from {original_tile_size} to {tile_size}, but in "
f"future this will raise an error and the correct tile "
f"size should be specified directly.", AstropyDeprecationWarning)

# Set up locations for writing the next cards in the header.
last_znaxis = "ZNAXIS"

Expand Down

0 comments on commit 9445c4a

Please sign in to comment.