You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 1.18 we have deprecated the [...]HDU.encapsulate(Object) methods, because they were not safe beyond internal use by the library itself. However, some similar methods could be useful for the targeted creation of specific types of HDUs from data, rather than using the automatic HDU wrapping by FitsFactory.makeHDU(). For example, a float[][] array may constitute data for a 2D image, or else it may be a column major table data (for either a BinaryTable or an AsciiTable). Fits.makeHDU() will always wrap that data into an ImageHDU, but sometimes that's not the intended way to represent such an array.
Here are some ideas for new methods:
static <Data-subclass>.from(Object) methods to wrap data into particular Data subclasses, when it can be done in an unambiguous way. (BinaryTable has disambiguated fromRowMajor(Object[][]) and fromColumnMajor(Object[]) methods instead, and AsciiTable should as well...)
Data.toHDU() method to then encapsulate a data object into a corresponding HDU, whose header is populated with the mandatory minimal description of the data automatically.
attipaci
changed the title
Reinstate static [...]HDU.encapsulate() methods with improved implementation
Targeted HDU/Data creation from Java objects
Sep 15, 2023
attipaci
changed the title
Targeted HDU/Data creation from Java objects
Targeted HDU/Data creation from Java data objects
Sep 15, 2023
It turns out that ImageData had no checks for what object it was created with. The constructor worked with no complaints with any Java object. This is clearly not a good idea. We should introduce checking that the object is a proper primitive numerical array (possibly multi-dimensional)...
In 1.18 we have deprecated the
[...]HDU.encapsulate(Object)
methods, because they were not safe beyond internal use by the library itself. However, some similar methods could be useful for the targeted creation of specific types of HDUs from data, rather than using the automatic HDU wrapping byFitsFactory.makeHDU()
. For example, afloat[][]
array may constitute data for a 2D image, or else it may be a column major table data (for either aBinaryTable
or anAsciiTable
).Fits.makeHDU()
will always wrap that data into anImageHDU
, but sometimes that's not the intended way to represent such an array.Here are some ideas for new methods:
<Data-subclass>.from(Object)
methods to wrap data into particularData
subclasses, when it can be done in an unambiguous way. (BinaryTable
has disambiguatedfromRowMajor(Object[][])
andfromColumnMajor(Object[])
methods instead, andAsciiTable
should as well...)Data.toHDU()
method to then encapsulate a data object into a corresponding HDU, whose header is populated with the mandatory minimal description of the data automatically.As such, you could have:
The text was updated successfully, but these errors were encountered: