Class RandomGroupsHDU
- All Implemented Interfaces:
FitsElement
BinaryTableHDU
offers a much more flexible and capable way for storing an ensemble of parameters, arrays, and
more.
Note that the internal storage of random groups is a Object[ngroups][2]
array. The first element of each
group (row) is a 1D array of parameter data of a numerical primitive type (e.g. short[]
,
double[]
). The second element in each group (row) is an image of the same element type as the
parameters. When analyzing group data structure only the first group is examined, but for a valid FITS file all
groups must have the same structure.
As of version 1.19, we provide support for accessing parameters by names including building up higher-precision
values by combining multiple related parameter conversion recipes through scalings and offsets, as described in the
FITS standard (e.g. combining 3 or 4 related byte
parameter values to obtain a full-precision 32-bit
float
parameter value when BITPIX
is 8).
- See Also:
-
Field Summary
Fields inherited from class nom.tam.fits.BasicHDU
BITPIX_BYTE, BITPIX_DOUBLE, BITPIX_FLOAT, BITPIX_INT, BITPIX_LONG, BITPIX_SHORT
-
Constructor Summary
ConstructorDescriptionRandomGroupsHDU
(Header header, RandomGroupsData data) Deprecated.(for internal use) Its visibility should be reduced to package level in the future. -
Method Summary
Modifier and TypeMethodDescriptionstatic RandomGroupsHDU
createFrom
(Object[][] data) Creates a random groups HDU from anObject[nGroups][2]
array.static RandomGroupsData
Deprecated.(for internal use) Will reduce visibility in the futurelong
Returns the integer value that signifies blank (missing ornull
) data in an integer image.double
Returns the floating-point increment between adjacent integer values in the image.getBUnit()
Returns the name of the physical unit in which image data are represented.double
getBZero()
Returns the floating-point value that corresponds to an 0 integer value in the image.int
Returns the number of data objects (of identical shape and size) that are group together in this HDUs data segment.double
getParameter
(String name, int group) Returns the value for a given group parameter.int
Returns the number of parameter bytes (per data group) accompanying each data object in the group.Returns a list of parameter names bundled along the images in each group, as extracted from the PTYPE_n_ header entries.void
info
(PrintStream stream) Print out some information about this HDU.static boolean
Deprecated.(for internal use) Will reduce visibility in the futureboolean
isHeader()
Check that this HDU has a valid header.static boolean
Deprecated.(for internal use) Will reduce visibility in the futurestatic RandomGroupsData
manufactureData
(Header header) Deprecated.(for internal use) Will reduce visibility in the futurevoid
write
(ArrayDataOutput stream) Writes the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.Methods inherited from class nom.tam.fits.BasicHDU
addValue, addValue, addValue, addValue, addValue, addValue, addValue, addValue, calcChecksum, card, getAuthor, getAxes, getBitpix, getBitPix, getCreationDate, getData, getDummyHDU, getEpoch, getEquinox, getFileOffset, getHeader, getInstrument, getKernel, getMaximumValue, getMinimumValue, getObject, getObservationDate, getObserver, getOrigin, getReference, getSize, getStoredChecksum, getStoredDatasum, getTelescope, getTrimmedString, getTrimmedString, read, reset, rewrite, rewriteable, setChecksum, verifyDataIntegrity, verifyIntegrity
-
Constructor Details
-
RandomGroupsHDU
Deprecated.(for internal use) Its visibility should be reduced to package level in the future.Create an HDU from the given header and data.- Parameters:
header
- header to usedata
- data to use
-
-
Method Details
-
encapsulate
Deprecated.(for internal use) Will reduce visibility in the future- Parameters:
o
- the array of object to create the random groups- Returns:
- a random groups data structure from an array of objects representing the data.
- Throws:
FitsException
- if the data could not be created.
-
isData
Deprecated.(for internal use) Will reduce visibility in the futureCheck if this data is compatible with Random Groups structure. Must be anObject[nGroups][2]
structure with both elements of each group having the same base type and the first element being a simple primitive array. We do not check anything but the first row.- Parameters:
potentialData
- data to check- Returns:
- is this data compatible with Random Groups structure
-
isHeader
Deprecated.(for internal use) Will reduce visibility in the future- Parameters:
hdr
- The header to be tested.- Returns:
- Is this a random groups header?
-
manufactureData
Deprecated.(for internal use) Will reduce visibility in the futurePrepares a data object into which the actual data can be read from an input subsequently or at a later time.- Parameters:
header
- The FITS header that describes the data- Returns:
- A data object that support reading content from a stream.
- Throws:
FitsException
- if the data could not be prepared to prescriotion.
-
createFrom
Creates a random groups HDU from anObject[nGroups][2]
array. Prior to 1.18, we usedFits.makeHDU(Object)
to create random groups HDUs automatically from matching data. However, FITS recommends using binary tables instead of random groups in general, and this type of HDU is included in the standard only to support reading some older radio data. Hence, as of 1.18Fits.makeHDU(Object)
will never return random groups HDUs any longer, and will instead create binary (or ASCII) table HDUs instead. If the need arises to create new random group HDUs programatically, beyond reading of older files, then this method can take its place.- Parameters:
data
- The random groups table. The second dimension must be 2. The first element in each group (row) must be a 1D numerical primitive array, while the second element may be a multi-dimensional image of the same element type. All rows must consists of arrays of the same primitive numerical types and sized, e.g.{ float[5], float[7][2] }
or{ short[3], short[2][2][4] }
.- Returns:
- a new random groups HDU, which encapsulated the supploed data table.
- Throws:
FitsException
- if the seconds dimension of the array is not 2.- Since:
- 1.18
- See Also:
-
info
Description copied from class:BasicHDU
Print out some information about this HDU.- Specified by:
info
in classBasicHDU<RandomGroupsData>
- Parameters:
stream
- the printstream to write the info on
-
getParameterCount
public int getParameterCount()Returns the number of parameter bytes (per data group) accompanying each data object in the group.- Overrides:
getParameterCount
in classBasicHDU<RandomGroupsData>
- Returns:
- the number of bytes used for arbitrary extra parameters accompanying each data object in the group.
- See Also:
-
getGroupCount
public int getGroupCount()Returns the number of data objects (of identical shape and size) that are group together in this HDUs data segment.- Overrides:
getGroupCount
in classBasicHDU<RandomGroupsData>
- Returns:
- the number of data objects (of identical shape and size) that are grouped together in the data segment.
- See Also:
-
isHeader
public boolean isHeader()Check that this HDU has a valid header.- Returns:
true
if this HDU has a valid header.
-
getBUnit
Returns the name of the physical unit in which image data are represented.- Overrides:
getBUnit
in classBasicHDU<RandomGroupsData>
- Returns:
- the standard name of the physical unit in which the image is expressed, e.g.
"Jy beam^{-1}"
.
-
getBlankValue
Returns the integer value that signifies blank (missing ornull
) data in an integer image.- Overrides:
getBlankValue
in classBasicHDU<RandomGroupsData>
- Returns:
- the integer value used for identifying blank / missing data in integer images.
- Throws:
FitsException
- if the header does not specify a blanking value or if it is not appropriate for the type of imge (that is not an integer type image)
-
getBScale
public double getBScale()Returns the floating-point increment between adjacent integer values in the image. Strictly speaking, only integer-type images should define a quantization scaling, but there is no harm in having this value in floating-point images also -- which may be interpreted as a hint for quantization, perhaps.- Overrides:
getBScale
in classBasicHDU<RandomGroupsData>
- Returns:
- the floating-point quantum that corresponds to the increment of 1 in the integer data representation.
- See Also:
-
getBZero
public double getBZero()Returns the floating-point value that corresponds to an 0 integer value in the image. Strictly speaking, only integer-type images should define a quantization scaling, but there is no harm in having this value in floating-point images also -- which may be interpreted as a hint for quantization, perhaps.- Overrides:
getBZero
in classBasicHDU<RandomGroupsData>
- Returns:
- the floating point value that correspond to the integer 0 in the image data.
- See Also:
-
write
Description copied from interface:FitsElement
Writes the contents of the element to a data sink, adding padding as necessary if the element (such as a header or data segment) is expected to complete the FITS block of 2880 bytes.- Specified by:
write
in interfaceFitsElement
- Overrides:
write
in classBasicHDU<RandomGroupsData>
- Parameters:
stream
- The data sink.- Throws:
FitsException
- if the write was unsuccessful.
-
getParameterNames
Returns a list of parameter names bundled along the images in each group, as extracted from the PTYPE_n_ header entries.- Returns:
- A set containing the parameter names contained in this HDU
- Since:
- 1.19
- See Also:
-
getParameter
public double getParameter(String name, int group) throws ArrayIndexOutOfBoundsException, FitsException Returns the value for a given group parameter.- Parameters:
name
- the parameter namegroup
- the zero-based group index- Returns:
- the stored parameter value in the specified group, or
Double.NaN
if the there is no such group. - Throws:
ArrayIndexOutOfBoundsException
- if the group index is out of bounds.FitsException
- if the deferred parameter data cannot be accessed- Since:
- 1.19
- See Also:
-