Пример #1
0
        internal BinaryTableHdu(HduBase hdu)
            : base(hdu)
        {
            InitializeMembers();

            DetectColumns();
        }
Пример #2
0
        private HduBase ReadNextHdu(HduBase prototype)
        {
            HduBase hdu;

            if (prototype != null)
            {
                hdu = prototype;
                hdu.Fits = this;
            }
            else
            {
                hdu = new HduBase(this);
            }

            hdu.ReadHeader();

            // Dispatch different types of FITS HDUs
            if (prototype != null)
            {
                return hdu;
            }
            else if (hdu.IsSimple)
            {
                return new ImageHdu(hdu);
            }
            else
            {
                switch (hdu.Extension)
                {
                    case Constants.FitsKeywordBinTable:
                        return new BinaryTableHdu(hdu);
                    default:
                        throw new NotImplementedException();
                }
            }
        }
Пример #3
0
 internal ImageHdu(HduBase hdu)
     : base(hdu)
 {
     InitializeMembers();
 }
Пример #4
0
        internal static FitsTableColumn CreateFromHeader(HduBase hdu, int index)
        {
            Card card;

            // Get data type
            if (!hdu.Cards.TryGetValue(Constants.FitsKeywordTForm, index, out card))
            {
                throw new FitsException("Keyword expected but not found:"); // TODO
            }

            var tform = card.GetString();
            var dt = FitsDataType.CreateFromTForm(tform);

            // Create column

            var column = new FitsTableColumn()
            {
                ID = index,
            };

            // Set optional parameters

            // --- Column name
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTType, index, out card))
            {
                column.Name = card.GetString();
            }

            // Unit
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTUnit, index, out card))
            {
                column.Unit = card.GetString();
            }

            // Null value equivalent
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTNull, index, out card))
            {
                column.NullValue = card.GetInt32();
            }

            // Scale
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTScal, index, out card))
            {
                column.Scale = card.GetDouble();
            }

            // Zero offset
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTZero, index, out card))
            {
                column.Zero = card.GetDouble();
            }

            // Format
            if (hdu.Cards.TryGetValue(Constants.FitsKeywordTDisp, index, out card))
            {
                column.Format = card.GetString();
            }

            return column;
        }
Пример #5
0
 internal HduBase(HduBase old)
 {
     CopyMembers(old);
 }
Пример #6
0
        private void CopyMembers(HduBase old)
        {
            this.file = old.file;

            this.headerRead = old.headerRead;
            this.headerPosition = old.headerPosition;
            this.dataPosition = old.dataPosition;

            this.cards = new CardCollection(old.cards);
            //this.columns =

            this.strideBuffer = null;
            this.totalStrides = 0;
            this.strideCounter = 0;
        }