2 /* Copyright: Thomas McGlynn 1997-1999.
3 * This code may be used for any purpose, non-commercial
4 * or commercial so long as this copyright notice is retained
5 * in the source code or included in or referred to in any
7 * Many thanks to David Glowacki (U. Wisconsin) for substantial
8 * improvements, enhancements and bug fixes.
11 import nom.tam.util.ArrayFuncs;
13 /** Holder for unknown data types. */
14 public class UndefinedHDU
17 /** Build an image HDU using the supplied data.
18 * @param obj the data used to build the image.
19 * @exception FitsException if there was a problem with the data.
21 public UndefinedHDU(Header h, Data d)
22 throws FitsException {
28 /* Check if we can find the length of the data for this
30 * @return <CODE>true</CODE> if this HDU has a valid header.
32 public static boolean isHeader(Header hdr) {
33 if (hdr.getStringValue("XTENSION") != null
34 && hdr.getIntValue("NAXIS", -1) >= 0) {
40 /** Check if we can use the following object as
41 * in an Undefined FITS block. We allow this
42 * so long as computeLSize can get a size. Note
43 * that computeLSize may be wrong!
44 * @param o The Object being tested.
46 public static boolean isData(Object o) {
47 return ArrayFuncs.computeLSize(o) > 0;
50 /** Create a Data object to correspond to the header description.
51 * @return An unfilled Data object which can be used to read
52 * in the data for this HDU.
53 * @exception FitsException if the image extension could not be created.
55 public Data manufactureData()
56 throws FitsException {
57 return manufactureData(myHeader);
60 public static Data manufactureData(Header hdr)
61 throws FitsException {
62 return new UndefinedData(hdr);
65 /** Create a header that describes the given
67 * @param o The image to be described.
68 * @exception FitsException if the object does not contain
71 public static Header manufactureHeader(Data d)
72 throws FitsException {
74 Header h = new Header();
80 /** Encapsulate an object as an ImageHDU. */
81 public static Data encapsulate(Object o) throws FitsException {
82 return new UndefinedData(o);
85 /** Print out some information about this HDU.
89 System.out.println(" Unhandled/Undefined/Unknown Type");
90 System.out.println(" XTENSION=" + myHeader.getStringValue("XTENSION").trim());
91 System.out.println(" Apparent size:" + myData.getTrueSize());