Example #1
0
        private void SetKnownAutomaticInstrumentalDelay()
        {
            int integration = (int)nudIntegratedFrames.Value;

            string cameraModel = m_VideoController.AstroVideoCameraModel ?? AstrometryContext.Current.VideoCamera.Model;
            Dictionary <int, float> corrections = InstrumentalDelayConfigManager.GetConfigurationForCamera(cameraModel);

            float corr;

            if (corrections.TryGetValue(integration, out corr))
            {
                if (!float.IsNaN(corr))
                {
                    cbxInstDelayCamera.SelectedIndex = cbxInstDelayCamera.Items.IndexOf(cameraModel);
                    SetKnownManualInstrumentalDelay();
                }
            }
        }
Example #2
0
 private void SetKnownManualInstrumentalDelay()
 {
     if (cbxInstDelayCamera.SelectedIndex > -1)
     {
         if (cbxInstDelayCamera.Text == string.Empty)
         {
             nudInstrDelay.Enabled    = true;
             cbxInstDelayUnit.Enabled = true;
         }
         else
         {
             Dictionary <int, float> delaysConfig = InstrumentalDelayConfigManager.GetConfigurationForCamera(cbxInstDelayCamera.Text);
             if (delaysConfig.ContainsKey((int)nudIntegratedFrames.Value))
             {
                 nudInstrDelay.Value            = -1 * (decimal)delaysConfig[(int)nudIntegratedFrames.Value];
                 cbxInstDelayUnit.SelectedIndex = 1;
             }
             nudInstrDelay.Enabled    = false;
             cbxInstDelayUnit.Enabled = false;
         }
     }
 }
Example #3
0
        internal void StartExport(string fileName, bool fitsCube, Rectangle roi, UsedTimeBase timeBase, bool usesOCR, bool ocrHasDatePart)
        {
            m_FrameWidth     = TangraContext.Current.FrameWidth;
            m_FrameHeight    = TangraContext.Current.FrameHeight;
            m_IsFitsSequence = m_VideoController.IsFitsSequence;

            if (m_VideoController.IsAstroAnalogueVideo)
            {
                m_IntegrationRate = m_VideoController.AstroAnalogueVideoIntegratedAAVFrames;
            }
            else
            {
                m_IntegrationRate = 0;
            }

            m_NativeFormat = m_VideoController.GetVideoFormat(m_VideoController.GetVideoFileFormat());
            m_VideoCamera  = m_VideoController.AstroVideoCameraModel;

            m_RegionOfInterest = roi;
            m_UsesROI          = roi.Width != m_FrameWidth || roi.Height != m_FrameHeight;

            m_ExportAs8BitFloat = false;
            m_NormalValue       = m_VideoController.EffectiveMaxPixelValue;
            m_VideoFormat       = m_VideoController.GetVideoFileFormat();

            if (m_VideoFormat == VideoFileFormat.AAV || m_VideoFormat == VideoFileFormat.AAV2 || m_VideoFormat == VideoFileFormat.AVI)
            {
                if (m_VideoController.VideoBitPix == 8 || m_VideoController.EffectiveMaxPixelValue > 255)
                {
                    // For video from analogue cameras we export as 8-bit floating point numbers
                    m_ExportAs8BitFloat = true;
                }
            }

            m_AdditionalFileHeaders.Clear();
            var fileHeaderProvider = m_VideoController.FramePlayer.Video as IFileHeaderProvider;

            if (fileHeaderProvider != null)
            {
                var AAV_HEADERS = new Dictionary <string, string>
                {
                    { "LATITUDE", "LATITUDE" },
                    { "LONGITUDE", "LONGITUD" },
                    { "OBSERVER", "OBSERVER" },
                    { "TELESCOP", "TELESCOP" },
                    { "OBJECT", "OBJECT" },
                    { "RA_OBJ", "RA_OBJ" },
                    { "DEC_OBJ", "DEC_OBJ" },
                    { "RECORDER-SOFTWARE", "REC-SOFT" },
                    { "RECORDER-SOFTWARE-VERSION", "REC-VER" },
                    { "ADVLIB-VERSION", "ADVLIB" }
                };

                var coppiedFromHeaderDescription = string.Format("Copied from {0} file headers", m_VideoFormat);
                var fileHeaders = fileHeaderProvider.GetFileHeaders();
                fileHeaders
                .Where(kvp => AAV_HEADERS.ContainsKey(kvp.Key))
                .Select(kvp => kvp)
                .ToList()
                .ForEach(kvp => m_AdditionalFileHeaders[AAV_HEADERS[kvp.Key]] = Tuple.Create(kvp.Value, coppiedFromHeaderDescription));

                if (m_VideoFormat == VideoFileFormat.AAV || m_VideoFormat == VideoFileFormat.AAV2)
                {
                    var camera = m_VideoCamera;
                    if (camera.IndexOf(m_NativeFormat, StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        camera = camera.Trim() + string.Format(" ({0})", m_NativeFormat);
                    }
                    var   instumentalDelaySelectedConfig = InstrumentalDelayConfigManager.GetConfigurationForCamera(camera);
                    float instDelay;
                    if (instumentalDelaySelectedConfig.TryGetValue(m_VideoController.AstroAnalogueVideoIntegratedAAVFrames, out instDelay))
                    {
                        m_AdditionalFileHeaders["INSTDELY"] = Tuple.Create(
                            instDelay.ToString(CultureInfo.InvariantCulture),
                            string.Format("Instr. delay in sec. for x{0} frames integration for '{1}' camera. This has not been applied to DATE-OBS", m_VideoController.AstroAnalogueVideoIntegratedAAVFrames, camera));
                    }
                }
            }

            m_FitsCube = fitsCube;
            if (!fitsCube)
            {
                m_FolderName = fileName;

                if (!Directory.Exists(m_FolderName))
                {
                    Directory.CreateDirectory(m_FolderName);
                }
            }

            m_Note = string.Format("Converted from {0} file.", m_VideoController.GetVideoFileFormat());
            if (m_Note.Length > HeaderCard.MAX_VALUE_LENGTH)
            {
                m_Note = m_Note.Substring(0, HeaderCard.MAX_VALUE_LENGTH);
            }

            if (m_UsesROI)
            {
                m_Note += string.Format(" Selected ROI: ({0},{1},{2},{3})", roi.Left, roi.Top, roi.Right, roi.Bottom);
                if (m_Note.Length > HeaderCard.MAX_VALUE_LENGTH)
                {
                    m_Note = m_Note.Substring(0, HeaderCard.MAX_VALUE_LENGTH);
                }
            }

            if (timeBase == UsedTimeBase.UserEnterred)
            {
                m_DateObsComment = "Date and Time are user entered & computed";
            }
            else if (timeBase == UsedTimeBase.EmbeddedTimeStamp)
            {
                if (usesOCR)
                {
                    if (ocrHasDatePart)
                    {
                        m_DateObsComment = "Date and Time are ORC-ed";
                    }
                    else
                    {
                        m_DateObsComment = "Time is ORC-ed, Date is user entered";
                    }
                }
                else if (!m_IsFitsSequence)
                {
                    m_DateObsComment = "Date and Time are saved by recorder";
                }
            }
        }
Example #4
0
        internal frmRunMultiFrameMeasurements(
            VideoController videoController,
            AstrometryController astrometryController,
            AddinsController addinsController,
            VideoAstrometryOperation astrometry,
            MeasurementContext measurementContext,
            FieldSolveContext fieldSolveContext,
            out List <ITangraAddinAction> astrometryAddinActions,
            out List <ITangraAddin> astrometryAddins)
        {
            InitializeComponent();

            pboxAperturePreview.Image = new Bitmap(pboxAperturePreview.Width, pboxAperturePreview.Height, PixelFormat.Format24bppRgb);

            m_VideoController      = videoController;
            m_AddinsController     = addinsController;
            m_AstrometryController = astrometryController;

            m_VideoAstrometry    = astrometry;
            m_MeasurementContext = measurementContext;
            m_FieldSolveContext  = fieldSolveContext;

            SyncTimeStampControlWithExpectedFrameTime();
            nudMinStars.SetNUDValue(TangraConfig.Settings.Astrometry.MinimumNumberOfStars);

            m_MeasurementContext.MaxMeasurements = 200;

            #region Configure the Reduction Settings. The same must be done in the frmConfigureReprocessing and frmSelectReductionType
            // Removes the Background Gradient
            cbxBackgroundMethod.Items.RemoveAt(2);
            #endregion

            SetComboboxIndexFromPhotometryReductionMethod(TangraConfig.Settings.LastUsed.AstrometryPhotometryReductionMethod);
            SetComboboxIndexFromBackgroundMethod(TangraConfig.Settings.LastUsed.AstrometryPhotometryBackgroundMethod);
            cbxFitMagnitudes.Checked = TangraConfig.Settings.LastUsed.AstrometryFitMagnitudes;


            if (TangraConfig.Settings.LastUsed.AstrometryMagFitAperture.HasValue &&
                TangraConfig.Settings.LastUsed.AstrometryMagFitGap.HasValue &&
                TangraConfig.Settings.LastUsed.AstrometryMagFitAnnulus.HasValue)
            {
                nudAperture.ValueChanged -= nudAperture_ValueChanged;
                try
                {
                    nudAperture.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitAperture.Value);
                    nudGap.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitGap.Value);
                    nudAnnulus.SetNUDValue(TangraConfig.Settings.LastUsed.AstrometryMagFitAnnulus.Value);
                }
                finally
                {
                    nudAperture.ValueChanged += nudAperture_ValueChanged;
                }
            }
            else
            {
                ResetAperture();
            }

            cbxOutputMagBand.SelectedIndex = (int)TangraConfig.Settings.Astrometry.DefaultMagOutputBand;

            lblCatBand.Text = string.Format("Magnitude Band for Photometry (from {0})", m_FieldSolveContext.StarCatalogueFacade.CatalogNETCode);
            cbxCatalogPhotometryBand.Items.Clear();
            cbxCatalogPhotometryBand.Items.AddRange(m_FieldSolveContext.StarCatalogueFacade.CatalogMagnitudeBands);
            CatalogMagnitudeBand defaultBand = cbxCatalogPhotometryBand.Items.Cast <CatalogMagnitudeBand>().FirstOrDefault(e => e.Id == TangraConfig.Settings.StarCatalogue.CatalogMagnitudeBandId);
            if (defaultBand != null)
            {
                cbxCatalogPhotometryBand.SelectedItem = defaultBand;
            }
            else
            {
                cbxCatalogPhotometryBand.SelectedIndex = 0;
            }

            cbxExpectedMotion.SelectedIndex = 1;
            cbxSignalType.Visible           = false;
            cbxSignalType.SelectedIndex     = 0;
            cbxFrameTimeType.SelectedIndex  = 0;
            pnlIntegration.Visible          = false;
            cbxInstDelayUnit.SelectedIndex  = 0;

            m_AstrometryAddinActions = m_AddinsController.GetAstrometryActions(out m_AstrometryAddins);

            foreach (ITangraAddinAction action in m_AstrometryAddinActions)
            {
                clbAddinsToRun.Items.Add(new AddinActionEntry(action));
            }
            astrometryAddinActions = m_AstrometryAddinActions;
            astrometryAddins       = m_AstrometryAddins;

            cbxInstDelayCamera.Items.Clear();
            cbxInstDelayCamera.Items.Add(string.Empty);
            cbxInstDelayCamera.Items.AddRange(InstrumentalDelayConfigManager.GetAvailableCameras().ToArray());

            m_Initialised = true;
        }