Package nom.tam.fits.utilities
Class FitsCheckSum
- java.lang.Object
-
- nom.tam.fits.utilities.FitsCheckSum
-
public final class FitsCheckSum extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static int
CHECKSUM_BLOCK_SIZE
private static int
CHECKSUM_HALF_BLOCK_SIZE
private static int
CHECKSUM_STRING_SIZE
private static java.util.logging.Logger
LOG
logger to log to.
-
Constructor Summary
Constructors Modifier Constructor Description private
FitsCheckSum()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
checksum(byte[] data)
Calculate the Seaman-Pence 32-bit 1's complement checksum over the byte stream.static java.lang.String
checksumEnc(long c, boolean compl)
Encode a 32bit integer according to the Seaman-Pence proposal.static void
setChecksum(BasicHDU<?> hdu)
Add or update the CHECKSUM keyword.
-
-
-
Field Detail
-
CHECKSUM_STRING_SIZE
private static final int CHECKSUM_STRING_SIZE
- See Also:
- Constant Field Values
-
LOG
private static final java.util.logging.Logger LOG
logger to log to.
-
CHECKSUM_BLOCK_SIZE
private static final int CHECKSUM_BLOCK_SIZE
- See Also:
- Constant Field Values
-
CHECKSUM_HALF_BLOCK_SIZE
private static final int CHECKSUM_HALF_BLOCK_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
checksum
public static long checksum(byte[] data)
Calculate the Seaman-Pence 32-bit 1's complement checksum over the byte stream. The option to start from an intermediate checksum accumulated over another previous byte stream is not implemented. The implementation accumulates in two 64-bit integer values the two low-order and the two high-order bytes of adjacent 4-byte groups. A carry-over of bits is never done within the main loop (only once at the end at reduction to a 32-bit positive integer) since an overflow of a 64-bit value (signed, with maximum at 2^63-1) by summation of 16-bit values could only occur after adding approximately 140G short values (=2^47) (280GBytes) or more. We assume for now that this routine here is never called to swallow FITS files of that size or larger. by R J MatharChecksum.CHECKSUM
- Parameters:
data
- the byte sequence- Returns:
- the 32bit checksum in the range from 0 to 2^32-1
- Since:
- 2005-10-05
-
checksumEnc
public static java.lang.String checksumEnc(long c, boolean compl)
Encode a 32bit integer according to the Seaman-Pence proposal.- Parameters:
c
- the checksum previously calculatedcompl
- complement the value- Returns:
- the encoded string of 16 bytes.
- See Also:
- heasarc checksum doc
-
setChecksum
public static void setChecksum(BasicHDU<?> hdu) throws FitsException
Add or update the CHECKSUM keyword. by R J Mathar- Parameters:
hdu
- the HDU to be updated.- Throws:
FitsException
- if the operation failed- Since:
- 2005-10-05
-
-