Class QuantizeOption
java.lang.Object
nom.tam.fits.compression.algorithm.quant.QuantizeOption
- All Implemented Interfaces:
Cloneable, ICompressOption
- Direct Known Subclasses:
HCompressorQuantizeOption, RiceQuantizeCompressOption
Quantization options when they are part of the compression scheme. When compressing tables and images includes
quantization (integer representation of floating point data), users can control how exactly the quantization should
be performed. When reading compressed FITS files, these options will be set automatically based on the header values
recorded in the compressed HDU.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe integer value recommeded by the FITS standard to represent NaN floating-point values in integer compressed data. -
Constructor Summary
ConstructorsConstructorDescriptionQuantizeOption(ICompressOption compressOption) Creates a new set of quantization options, to be used together with the specified compression options. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns an independent copy of this option.getBNull()Returns the integer value that represents missing (null) for integer compressed floating-point data.doubleReturns the quantization level for integer compressed floating-point data.doublegetBZero()Returns the quantization offset for integer compressed floating-point data.nom.tam.fits.compression.provider.param.api.ICompressParameters(for internal use) Returns the parameters that represent the settings for this option in the FITS header or compressed data column.final ICompressOptionReturns the options for the compression algorithm that accompanies quantization.<T> TgetCompressOption(Class<T> clazz) Returns the compression or quantization options, recast for the selected option class.intReturns the maximum integer level in the quantized representation.intReturns the maximum integer level in the quantized representation.doubleReturns the maximum floating-point value in the datadoubleReturns the minimum floating-point value in the datadoubleDeprecated.The FITS standard allows only NaNs to indicate missing / invalid floating-point data.final IntegerDeprecated.usegetBNull()instead (duplicate method).doubleReturns the quantization resolution level used for automatic qunatization.longgetSeed()Gets the random seed value used for ditheringintReturns the tile heightlongReturns the sequential tile index that this option is currently configured for.intReturns the tile widthbooleanChecks whether we force the integer quantized level 0 to correspond to a floating-point level 0.0, when using automatic quantization.final booleanDeprecated.UsegetBNull()instead to see if a custom null-value indicator has been configured.booleanDeprecated.UseisDither2()instead.booleanisDither()Whether dithering is enabledbooleanWhether dithering (when enabled) uses method 2, which treats 0.0 values as special.booleanChecks if this type of compression is inherently lossystatic final booleanisUseFMA()Checks whetherMath.fma(double, double, double)is used for converting quantized integers back to doubles.Sets the integer value that represents missing data (null) for integer compressed floating-point data.setBScale(double value) Sets the quantization level for integer compressed floating-point data.setBZero(double value) Sets the quantization offset for integer compressed floating-point data.setCenterOnZero(boolean value) Enabled or disables keeping `ZZERO` at 0 when using automatic quantization.setCheckNull(boolean value) Deprecated.This feature is set automatically as needed.setCheckZero(boolean value) Deprecated.UsesetDither2(boolean)instead if you want zero values to be special encoded.setDither(boolean value) Enables or disables dithering.setDither2(boolean value) Sets whether dithering is to use method 2, when dithering is enabled.setIntMaxValue(int value) Sets the maximum integer level in the quantized representation.setIntMinValue(int value) Sets the minimum integer level in the quantized representation.setMaxValue(double value) Sets the maximum floating-point value in the datasetMinValue(double value) Sets the minimum floating-point value in the datasetNullValue(double value) Deprecated.The use of null values other thanNaNfor floating-point data types is not standard in FITS.voidsetParameters(nom.tam.fits.compression.provider.param.api.ICompressParameters parameters) (for internal use) Sets the parameters that link the options to how they are recorded in the FITS headers or compressed table columns.setQlevel(double value) Sets the quantization resolution level to use for automatic quantization.setSeed(long value) Sets the seed value for the dither random generatorsetTileHeight(int value) Set the tile height (if the option supports it).setTileIndex(int index) Sets the tile index for which to initialize the random number generator with the given seed (i.e.setTileWidth(int value) Set the tile width (if the option supports it).<T> T(for internal use) Recasts these options for the specific implementation classstatic voiduseFMA(boolean value) Selects whetherMath.fma(double, double, double)should be used when converting quantized integers back to doubles.
-
Field Details
-
RECOMMENDED_NAN_INDICATOR
public static final int RECOMMENDED_NAN_INDICATORThe integer value recommeded by the FITS standard to represent NaN floating-point values in integer compressed data.- See Also:
-
-
Constructor Details
-
QuantizeOption
Creates a new set of quantization options, to be used together with the specified compression options.- Parameters:
compressOption- Compression-specific options to pair with these quantization options, ornull.- Since:
- 1.18
-
-
Method Details
-
copy
Description copied from interface:ICompressOptionReturns an independent copy of this option. Modifications to the original or the copy will not affect the other.- Specified by:
copyin interfaceICompressOption- Returns:
- copy the option (normally the option from with the copy happened is saved as original).
-
getBNull
Returns the integer value that represents missing (null) for integer compressed floating-point data. This funtion was named poorly as it sets theZBLANKvalue in the header or in the equivalently named column.- Returns:
- the integer blanking value (for integer-compressed
NaNs). If the returned value isnull, then the recommended value -2147483647 will be used as needed. - See Also:
-
getBScale
public double getBScale()Returns the quantization level for integer compressed floating-point data. This funtion was named poorly as it sets theZSCALEparameter value in the named column when compressing floating-point data with an algorithm that supports integers only. It has nothing to do with theBSCALEheader value, which indicates the integer representation of floating-point data for the uncompressed data.- Returns:
- the floating-point difference between integer levels in the quantized data.
- See Also:
-
getBZero
public double getBZero()Returns the quantization offset for integer compressed floating-point data. This funtion was named poorly as it sets theZZEROparameter value in the named column when compressing floating-point data with an algorithm that supports integers only. It has nothing to do with theBZEROheader value, which indicates the integer representation of floating-point data for the uncompressed data.- Returns:
- the floating-point value corresponding to the integer level 0.
- See Also:
-
getCompressionParameters
public nom.tam.fits.compression.provider.param.api.ICompressParameters getCompressionParameters()Description copied from interface:ICompressOption(for internal use) Returns the parameters that represent the settings for this option in the FITS header or compressed data column.- Specified by:
getCompressionParametersin interfaceICompressOption- Returns:
- the parameters that must be synchronized with the hdu meta data.
- See Also:
-
getCompressOption
Returns the compression or quantization options, recast for the selected option class.- Type Parameters:
T- the generic type of the compression option- Parameters:
clazz- the option class for the compression algorithm used with the quantization, orQunatizeOption.classfor our own options.- Returns:
- the recast options for the requested class or
nullid we do not have access to options of the requested class. - See Also:
-
getCompressOption
Returns the options for the compression algorithm that accompanies quantization.- Returns:
- the options for the compression algorithm, or
null - See Also:
-
getIntMaxValue
public int getIntMaxValue()Returns the maximum integer level in the quantized representation.- Returns:
- the maximum integer level in the quantized data.
- See Also:
-
getIntMinValue
public int getIntMinValue()Returns the maximum integer level in the quantized representation.- Returns:
- the maximum integer level in the quantized data.
- See Also:
-
getMaxValue
public double getMaxValue()Returns the maximum floating-point value in the data- Returns:
- the maximum floating-point value in the data before quantization.
- See Also:
-
getMinValue
public double getMinValue()Returns the minimum floating-point value in the data- Returns:
- the minimum floating-point value in the data before quantization.
- See Also:
-
getNullValue
Deprecated.The FITS standard allows only NaNs to indicate missing / invalid floating-point data.Returns the floating-point value that indicates missing or invalid data in the image before quantization is applied. Normally, the FITS standard is that NaN values indicatenullvalues in floating-point images. While this class allows using other values also, they are not recommended since they are not supported by FITS in a standard way.- Returns:
- the floating-point value that represents a
nullvalue (missing data) in the image before quantization. - See Also:
-
getNullValueIndicator
Deprecated.usegetBNull()instead (duplicate method). Returns the integer value that representsNaNvalues in integer-compressed floating-point data.- Returns:
- the integer blanking value (
nullvalue). - See Also:
-
getQLevel
public double getQLevel()Returns the quantization resolution level used for automatic qunatization. For Gaussian noise the quantization level is the standard deviation of the noise divided by this Q value. Thus Q values of a few will ensure that quantization retains just about all of the information in the noisy data.- Returns:
- The current Q value, defined as the number of quantized levels per standard deviation (for Gaussian noise).
- See Also:
-
getSeed
public long getSeed()Gets the random seed value used for dithering- Returns:
- the random seed value used for dithering
- See Also:
-
getTileIndex
public long getTileIndex()Returns the sequential tile index that this option is currently configured for.- Returns:
- the sequential tile index that the quantization is configured for
- See Also:
-
getTileHeight
public int getTileHeight()Returns the tile height- Specified by:
getTileHeightin interfaceICompressOption- Returns:
- the tile height in pixels
- See Also:
-
getTileWidth
public int getTileWidth()Returns the tile width- Specified by:
getTileWidthin interfaceICompressOption- Returns:
- the tile width in pixels
- See Also:
-
isCenterOnZero
public boolean isCenterOnZero()Checks whether we force the integer quantized level 0 to correspond to a floating-point level 0.0, when using automatic quantization.- Returns:
trueif we want to keep `ZZERO` at 0.0 when quantizing automatically.- See Also:
-
isCheckNull
Deprecated.UsegetBNull()instead to see if a custom null-value indicator has been configured.Whether the floating-point data may containnullvalues (normally NaNs).- Returns:
true(always since 1.23).- See Also:
-
isCheckZero
Deprecated.UseisDither2()instead. The special treatent of ero values is the distinghuishing feature of theSUBTRACTIVE_DITHER_2method, which is otherwise the same asSUBTRACTIVE_DITHER_1.Whether automatic quantization treats 0.0 as a special value. The special treatment of 0.0 values is the distinguishing feature of dither method 2 over method 1.- Returns:
trueto treat 0.0 (exact) as a special value, orfalseto treat is as any other measured value (recommended).- See Also:
-
isDither
public boolean isDither()Whether dithering is enabled- Returns:
trueif dithering is enabled, or elsefalse- See Also:
-
isDither2
public boolean isDither2()Whether dithering (when enabled) uses method 2, which treats 0.0 values as special.- Returns:
trueif method 2 is used is used for dithering, or elsefalse- See Also:
-
isLossyCompression
public boolean isLossyCompression()Description copied from interface:ICompressOptionChecks if this type of compression is inherently lossy- Specified by:
isLossyCompressionin interfaceICompressOption- Returns:
trueif the compression done with this specified options uses approximations. That means if the reconstruction of the data is excact the return should befalse.
-
setBNull
Sets the integer value that represents missing data (null) for integer compressed floating-point data. This funtion was named poorly as it sets theZBLANKvalue in the header or in the equivalently named column.- Parameters:
blank- the new integer value that denotesNaNwhen floating-point data is compressed with an integer-only algorithm. Setting this option tonullwill set the headerZBLANKvalue, when the data contains NaNs, to -2147483647 (i.e., the value recommended by the FITS standard).- Returns:
- itself
- See Also:
-
setBScale
Sets the quantization level for integer compressed floating-point data. This funtion was named poorly as it sets theZZEROparameter value in the named column when compressing floating-point data with an algorithm that supports integers only. It has nothing to do with theBZEROheader value, which indicates the integer representation of floating-point data for the uncompressed data.- Parameters:
value- the new floating-point difference between integer levels in the quantized data.- Returns:
- itself
- See Also:
-
setBZero
Sets the quantization offset for integer compressed floating-point data. This funtion was named poorly as it sets theZZEROparameter value in the named column when compressing floating-point data with an algorithm that supports integers only. It has nothing to do with theBZEROheader value, which indicates the integer representation of floating-point data for the uncompressed data.- Parameters:
value- the new floating-point value corresponding to the integer level 0.- Returns:
- itself
- See Also:
-
setCenterOnZero
Enabled or disables keeping `ZZERO` at 0 when using automatic quantization.- Parameters:
value-trueto keep `ZZERO` at 0 when quantizing automatically, that is keep the integer quantized level 0 correspond to floating-point level 0.0. Or,falseto let the automatic quantization algorithm determine the optimal quantization offset.- Returns:
- iftself
- See Also:
-
setCheckNull
Deprecated.This feature is set automatically as needed.Obsolete method that used to set whether we should expect the floating-point data to containnullvalues (NaNs).- Parameters:
value- (unused since 1.23)- Returns:
- itself
- See Also:
-
setCheckZero
Deprecated.UsesetDither2(boolean)instead if you want zero values to be special encoded. The representation of true zero values is the unique feature of theSUBTRACTIVE_DITHER_2method that sets it apart fromSUBTRACTIVE_DITHER_1.Sets whether automatic quantization is to treat 0.0 as a special value. This is the same assetDither2(boolean). When enabled and dithering is used, then 0.0 values will be denoted with the special value −2147483647 in the quantized representation.- Parameters:
value- (unused) value whether to treat values around 0.0 as special.- Returns:
- itself
- See Also:
-
setDither
Enables or disables dithering.- Parameters:
value-trueto enable dithering, or elsefalseto disable- Returns:
- itself
- See Also:
-
setDither2
Sets whether dithering is to use method 2, when dithering is enabled. It does not actually enable or disable dithering itself -- for that you must callsetDither(boolean). When dither method 2 is used, then 0.0 values will be denoted with the special value −2147483647 in the quantized representation, whereas dither method 1 treats 0.0 just like any other decomal value.- Parameters:
value-trueto use dither method 2, or elsefalsefor method 1.- Returns:
- itself
- See Also:
-
setIntMaxValue
Sets the maximum integer level in the quantized representation.- Parameters:
value- the new maximum integer level in the quantized data.- Returns:
- itself
- See Also:
-
setIntMinValue
Sets the minimum integer level in the quantized representation.- Parameters:
value- the new minimum integer level in the quantized data.- Returns:
- itself
- See Also:
-
setMaxValue
Sets the maximum floating-point value in the data- Parameters:
value- the maximum floating-point value in the data before quantization.- Returns:
- itself
- See Also:
-
setMinValue
Sets the minimum floating-point value in the data- Parameters:
value- the mininum floating-point value in the data before quantization.- Returns:
- itself
- See Also:
-
setNullValue
Deprecated.The use of null values other thanNaNfor floating-point data types is not standard in FITS. You should therefore avoid using this method, in general.Sets the floating-point value that indicates missing data in the floating point image image before quantization is applied. Normally, the FITS standard is that NaN values indicatenullvalues in floating-point images. While this class allows using other values also, they are not recommended since they are not supported by FITS in a standard way.- Parameters:
value- the new floating-point value that represents anullvalue (missing data) in the image before quantization.- Returns:
- itself
- See Also:
-
setParameters
public void setParameters(nom.tam.fits.compression.provider.param.api.ICompressParameters parameters) Description copied from interface:ICompressOption(for internal use) Sets the parameters that link the options to how they are recorded in the FITS headers or compressed table columns.- Specified by:
setParametersin interfaceICompressOption- Parameters:
parameters- the parameters to synchronized- See Also:
-
setQlevel
Sets the quantization resolution level to use for automatic quantization. For Gaussian noise the quantization level is the standard deviation of the noise divided by this Q value. Thus Q values of a few will ensusre that quantization retains just about all of the information contained in the noisy data.- Parameters:
value- The new Q value, defined as the number of quantized levels per standard deviation (for Gaussian noise).- Returns:
- itself
- See Also:
-
setSeed
Sets the seed value for the dither random generator- Parameters:
value- The seed value, as inZDITHER0, normally a number between 1 and 10000 (inclusive).- Returns:
- itself
- See Also:
-
setTileIndex
Sets the tile index for which to initialize the random number generator with the given seed (i.e.ZDITHER0value).- Parameters:
index- The 0-based tile index- Returns:
- itself
- See Also:
-
setTileHeight
Description copied from interface:ICompressOptionSet the tile height (if the option supports it). If the implementing option class does not have a setting for tile size, it should simply ignore the setting and return normally.- Specified by:
setTileHeightin interfaceICompressOption- Parameters:
value- the new tile height in pixels- Returns:
- itself
- See Also:
-
setTileWidth
Description copied from interface:ICompressOptionSet the tile width (if the option supports it). If the implementing option class does not have a setting for tile size, it should simply ignore the setting and return normally.- Specified by:
setTileWidthin interfaceICompressOption- Parameters:
value- the new tile with in pixels- Returns:
- itself
- See Also:
-
unwrap
Description copied from interface:ICompressOption(for internal use) Recasts these options for the specific implementation class- Specified by:
unwrapin interfaceICompressOption- Type Parameters:
T- these options recast to the designated implementation type.- Parameters:
clazz- the implementation class- Returns:
- the recast version of us or
nullif the recasting is not available for the specified class type.
-
useFMA
public static void useFMA(boolean value) Selects whetherMath.fma(double, double, double)should be used when converting quantized integers back to doubles. Othwerwise normal arithmetic is used, which is the default. CFITSIO and astropy both rely onfma(), which has better precision, but is not supported on some (older) architectures. When hardware support is lacking, you may expect a significant performance hit from the software implementation.- Parameters:
value-trueto usefma(), or elsefalseto use regular arithmetics.- Since:
- 1.23
- See Also:
-
isUseFMA
public static final boolean isUseFMA()Checks whetherMath.fma(double, double, double)is used for converting quantized integers back to doubles.- Returns:
trueif usingfma(), or elsefalseis using regular arithmetics.- Since:
- 1.23
-