Exemplo n.º 1
0
 /// <summary>Given a Header return an appropriate datum.</summary>
 internal static Data DataFactory(Header hdr)
 {
     if (ImageHDU.IsHeader(hdr))
     {
         return(ImageHDU.ManufactureData(hdr));
     }
     else if (RandomGroupsHDU.IsHeader(hdr))
     {
         return(RandomGroupsHDU.ManufactureData(hdr));
     }
     else if (useAsciiTables && AsciiTableHDU.IsHeader(hdr))
     {
         return(AsciiTableHDU.ManufactureData(hdr));
     }
     else if (BinaryTableHDU.IsHeader(hdr))
     {
         return(BinaryTableHDU.ManufactureData(hdr));
     }
     else if (UndefinedHDU.IsHeader(hdr))
     {
         return(UndefinedHDU.ManufactureData(hdr));
     }
     else
     {
         throw new FitsException("Unrecognizable header in dataFactory");
     }
 }
Exemplo n.º 2
0
        // change suggested in .99.5 version: Method made public from protected.
        /// <summary>Given an object, create the appropriate FITS header to describe it.</summary>
        /// <param name="o">The object to be described.</param>
        public static BasicHDU HDUFactory(Object o)
        {
            Data   d;
            Header h;

            if (ImageHDU.IsData(o))
            {
                d = ImageHDU.Encapsulate(o);
                h = ImageHDU.ManufactureHeader(d);
            }
            else if (RandomGroupsHDU.IsData(o))
            {
                d = RandomGroupsHDU.Encapsulate(o);
                h = RandomGroupsHDU.ManufactureHeader(d);
            }
            else if (useAsciiTables && AsciiTableHDU.IsData(o))
            {
                d = AsciiTableHDU.Encapsulate(o);
                h = AsciiTableHDU.ManufactureHeader(d);
            }
            else if (BinaryTableHDU.IsData(o))
            {
                d = BinaryTableHDU.Encapsulate(o);
                h = BinaryTableHDU.ManufactureHeader(d);
            }
            else if (UndefinedHDU.IsData(o))
            {
                d = UndefinedHDU.Encapsulate(o);
                h = UndefinedHDU.ManufactureHeader(d);
            }
            else
            {
                Console.WriteLine();
                throw new FitsException("Invalid data presented to HDUFactory");
            }

            return(HDUFactory(h, d));
        }