Skip to main content
`Ctrl`+`K`

# HCompress1

class astropy.io.fits.hdu.compressed._codecs.HCompress1(*, scale, smooth, bytepix, nx, ny)

  Bases: `Codec`

  The FITS HCompress compression and decompression algorithm.

  Hcompress is an the image compression package written by Richard L. White for use at the Space Telescope Science Institute. Hcompress was used to compress the STScI Digitized Sky Survey and has also been used to compress the preview images in the Hubble Data Archive.

  The technique gives very good compression for astronomical images and is relatively fast. The calculations are carried out using integer arithmetic and are entirely reversible. Consequently, the program can be used for either lossy or lossless compression, with no special approach needed for the lossless case.

  Parameters:
    scale

      The integer scale parameter determines the amount of compression. Scale = 0 or 1 leads to lossless compression, i.e. the decompressed image has exactly the same pixel values as the original image. If the scale factor is greater than 1 then the compression is lossy: the decompressed image will not be exactly the same as the original

    smooth

      At high compressions factors the decompressed image begins to appear blocky because of the way information is discarded. This blockiness ness is greatly reduced, producing more pleasing images, if the image is smoothed slightly during decompression.

  References

  [1]

  White, R. L. 1992, in Proceedings of the NASA Space and Earth Science Data Compression Workshop, ed. J. C. Tilton, Snowbird, UT; https://archive.org/details/nasa_techdoc_19930016742

  Attributes Summary

  `codec_id` |

  Methods Summary

  `decode`(buf) | Decompress buffer using the HCOMPRESS_1 algorithm.
  `encode`(buf) | Compress the data in the buffer using the HCOMPRESS_1 algorithm.

  Attributes Documentation

  codec_id = 'FITS_HCOMPRESS1'

  Methods Documentation

  decode(buf)

    Decompress buffer using the HCOMPRESS_1 algorithm.

    Parameters:
      buf `bytes` or numpy:array_like

        The buffer to decompress.

    Returns:
      buf `np.ndarray`

        The decompressed buffer.

  encode(buf)

    Compress the data in the buffer using the HCOMPRESS_1 algorithm.

    Parameters:
      buf `bytes` or numpy:array_like

        The buffer to compress.

    Returns:
      `bytes`

        The compressed bytes.