示例#1
0
        private DateTime? ParseExposureCase1(Header header, out bool isMidPoint, out double? fitsExposure)
        {
            isMidPoint = true;
            fitsExposure = null;

            var timeStampCard = header.FindCard(m_Config.TimeStampHeader);
            var exposureCard = header.FindCard(m_Config.ExposureHeader);
            if (timeStampCard != null && exposureCard != null)
            {
                double parsedExposure;
                if (double.TryParse(exposureCard.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out parsedExposure))
                    fitsExposure = ConvertExposureInSeconds(parsedExposure);

                DateTime parsedTimeStamp;
                if (DateTime.TryParseExact(timeStampCard.Value, m_Config.TimeStampFormat, CultureInfo.InvariantCulture,
                    DateTimeStyles.AssumeUniversal, out parsedTimeStamp))
                {
                    switch (m_Config.TimeStampType)
                    {
                        case TangraConfig.TimeStampType.StartExposure:
                            if (fitsExposure != null)
                            {
                                isMidPoint = true;
                                return parsedTimeStamp.AddSeconds(0.5*parsedExposure);
                            }
                            else
                                return parsedTimeStamp;

                        case TangraConfig.TimeStampType.MidExposure:
                            isMidPoint = true;
                            return parsedTimeStamp;

                        case TangraConfig.TimeStampType.EndExposure:
                            if (fitsExposure != null)
                            {
                                isMidPoint = true;
                                return parsedTimeStamp.AddSeconds(-0.5*parsedExposure);
                            }
                            else
                                return parsedTimeStamp;
                    }
                }
            }

            return null;
        }
示例#2
0
        /// <summary>Create a binary table from given header information.</summary>
        /// <param name="myHeader">header describing what the binary table should look like.</param>
        public BinaryTable(Header myHeader)
        {
            int heapSize = myHeader.GetIntValue("PCOUNT");
            heapOffset = myHeader.GetIntValue("THEAP");

            // .99.1 changes: changed the sequence of code lines.
            int rwsz = myHeader.GetIntValue("NAXIS1");
            nRow = myHeader.GetIntValue("NAXIS2");

            // Subtract out the size of the regular table from
            // the heap offset.

            if (heapOffset > 0)
            {
                heapOffset -= nRow * rwsz;
            }

            if (heapOffset < 0 || heapOffset > heapSize)
            {
                throw new FitsException("Inconsistent THEAP and PCOUNT");
            }

            heap = new FitsHeap(heapSize - heapOffset);
            nCol = myHeader.GetIntValue("TFIELDS");
            rowLen = 0;

            ExtendArrays(nCol);
            for (int col = 0; col < nCol; col += 1)
            {
                rowLen += ProcessCol(myHeader, col);
            }

            // .99.1 changes: Added to replace new value of NAXIS1 keyword.
            HeaderCard card = myHeader.FindCard("NAXIS1");
            card.Value = rowLen.ToString();
            myHeader.UpdateLine("NAXIS1", card);
        }
示例#3
0
        public frmChooseTimeHeaders(Header hdr, string filesHash)
            : this()
        {
            m_FilesHash = filesHash;

            var hasher = new SHA1CryptoServiceProvider();
            hasher.Initialize();
            var orderedCardNames = new List<string>();

            var cursor = hdr.GetCursor();
            while (cursor.MoveNext())
            {
                var card = hdr.FindCard((string)cursor.Key);
                if (card != null)
                {
                    m_AllCards.Add(new HeaderEntry(card));
                }
                orderedCardNames.Add((string) cursor.Key);
            }

            orderedCardNames.Sort();
            byte[] combinedCardNamesBytes = Encoding.UTF8.GetBytes(string.Join("|", orderedCardNames));
            var hash = hasher.ComputeHash(combinedCardNamesBytes, 0, combinedCardNamesBytes.Length);
            m_CardNamesHash = Convert.ToBase64String(hash);

            cbxTimeStamp.Items.AddRange(m_AllCards.ToArray());
            cbxTimeStamp2.Items.AddRange(m_AllCards.ToArray());
            cbxExposure.Items.AddRange(m_AllCards.ToArray());

            cbxExposureUnits.Items.Clear();
            cbxExposureUnits.Items.AddRange(Enum.GetNames(typeof(TangraConfig.ExposureUnit)));

            cbxTimestampType.SelectedIndex = 0;
            cbxExposureUnits.SelectedIndex = 0;

            // End timestamp
            cbxTimestampType2.SelectedIndex = 2;
            cbxTimestampType2.Enabled = false;

            cbxTimeStampFormat.Items.Clear();
            cbxTimeStamp2Format.Items.Clear();
            var formats = new List<object>();
            formats.Add("yyyy-MM-ddTHH:mm:ss.fff");
            formats.Add("dd/MM/yyyy HH:mm:ss.fff");

            if (TangraConfig.Settings.Generic.CustomFITSTimeStampFormats != null)
                formats.AddRange(TangraConfig.Settings.Generic.CustomFITSTimeStampFormats);

            cbxTimeStampFormat.Items.AddRange(formats.ToArray());
            cbxTimeStamp2Format.Items.AddRange(formats.ToArray());
            if (!string.IsNullOrEmpty(TangraConfig.Settings.LastUsed.FitsTimestampFormat))
            {
                int idx = cbxTimeStampFormat.Items.IndexOf(TangraConfig.Settings.LastUsed.FitsTimestampFormat);
                if (idx > -1)
                {
                    cbxTimeStampFormat.SelectedIndex = idx;
                    cbxTimeStamp2Format.SelectedIndex = idx;
                }
            }
            else
            {
                cbxTimeStampFormat.SelectedIndex = 0;
                cbxTimeStamp2Format.SelectedIndex = 0;
            }

            TryIdentifyPreviousConfigApplyingForCurrentFiles();
        }