Exemple #1
0
        private void CompleteActivation()
        {
            m_VideoController.SetPictureBoxCursor(CustomCursors.PanCursor);

            m_FieldSolveContext = AstrometryContext.Current.FieldSolveContext;

            m_Image = m_AstrometryController.GetCurrentAstroPlate();
            m_Image.EffectiveFocalLength = m_FieldSolveContext.FocalLength;

            m_RADegCenter = m_FieldSolveContext.RADeg;
            m_DEDegCenter = m_FieldSolveContext.DEDeg;

            StarCatalogueFacade facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

            m_CatalogueStars = facade.GetStarsInRegion(
                m_FieldSolveContext.RADeg, m_FieldSolveContext.DEDeg,
                2.5 * m_Image.GetMaxFOVInArcSec() / 3600.0, m_FieldSolveContext.LimitMagn, (float)m_FieldSolveContext.Epoch);

            m_Eta            = GetUserCameraConfigParam("rotation", 0.0);
            m_FLength        = m_FieldSolveContext.FocalLength;
            m_Aspect         = GetUserCameraConfigParam("aspect", 1.0);
            m_LimitMag       = (int)Math.Round(m_FieldSolveContext.LimitMagn);
            m_ShowLabels     = GetUserCameraConfigParam("labels", 0) == 1;
            m_Grid           = GetUserCameraConfigParam("grid", 0) == 1;
            m_ShowMagnitudes = GetUserCameraConfigParam("magnitudes", 0) == 1;

            UpdateControls();

            InitStarMap();

            m_SolvedPlate = new DirectTransRotAstrometry(m_Image, m_FieldSolveContext.RADeg, m_FieldSolveContext.DEDeg, m_Eta, m_Aspect);

            m_CalibrationContext                   = new CalibrationContext();
            m_CalibrationContext.StarMap           = AstrometryContext.Current.StarMap;
            m_CalibrationContext.PreliminaryFit    = m_SolvedPlate;
            m_FieldSolveContext.CatalogueStars     = m_CatalogueStars;
            m_CalibrationContext.FieldSolveContext = m_FieldSolveContext;
            m_CalibrationContext.PlateConfig       = m_Image;

            TangraConfig.AstrometrySettings calibrationSettings = TangraConfig.Settings.Astrometry.Clone();
            calibrationSettings.MaxResidualInPixels = CorePyramidConfig.Default.CalibrationMaxResidualInPixels;
            calibrationSettings.PyramidDistanceToleranceInPixels = CorePyramidConfig.Default.CalibrationPyramidDistanceToleranceInPixels;
            calibrationSettings.MinimumNumberOfStars             = CorePyramidConfig.Default.CalibrationNumberOfStars;
            m_PlateCalibrator = new PlateCalibration(m_CalibrationContext, calibrationSettings, m_AstrometryController);

            UpdateToolControlDisplay();
            m_PlatesolveController.SetupControls();
            m_SolveState = -1;
            DrawCatalogStarsFit();

            m_State = FittingsState.Activated;
        }
Exemple #2
0
        public void PlateSolve(PlateSolveTesterConfig config)
        {
            var pixelMap = new Pixelmap(config.Width, config.Height, config.BitPix, config.Pixels, null, null);
            var image    = new AstroImage(pixelMap);

            StarMap starMap = new StarMap(
                TangraConfig.Settings.Astrometry.PyramidRemoveNonStellarObject,
                TangraConfig.Settings.Astrometry.MinReferenceStarFWHM,
                TangraConfig.Settings.Astrometry.MaxReferenceStarFWHM,
                TangraConfig.Settings.Astrometry.MaximumPSFElongation,
                TangraConfig.Settings.Astrometry.LimitReferenceStarDetection);

            Rectangle excludeRect = new Rectangle(config.OSDRectToExclude.X, config.OSDRectToExclude.Y, config.OSDRectToExclude.Width, config.OSDRectToExclude.Height);
            Rectangle includeRect = new Rectangle(config.RectToInclude.X, config.RectToInclude.Y, config.RectToInclude.Width, config.RectToInclude.Height);

            starMap.FindBestMap(
                StarMapInternalConfig.Default,
                image,
                excludeRect,
                includeRect,
                config.LimitByInclusion);

            var facade         = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);
            var catalogueStars = facade.GetStarsInRegion(
                config.RADeg,
                config.DEDeg,
                (config.ErrFoVs + 1.0) * config.PlateConfig.GetMaxFOVInArcSec() / 3600.0,
                config.LimitMagn,
                config.Epoch);

            var distBasedMatcher = new DistanceBasedAstrometrySolver(
                new MockedOperationNotifier(),
                config.PlateConfig,
                TangraConfig.Settings.Astrometry,
                catalogueStars,
                config.RADeg,
                config.DEDeg,
                config.DetermineAutoLimitMagnitude);

            distBasedMatcher.SetMinMaxMagOfStarsForAstrometry(config.PyramidMinMag, config.LimitMagn);
            distBasedMatcher.SetMinMaxMagOfStarsForPyramidAlignment(config.PyramidMinMag, config.PyramidMaxMag);

            distBasedMatcher.InitNewMatch(starMap, PyramidMatchType.PlateSolve, null);


            distBasedMatcher.InitNewFrame(starMap);

            distBasedMatcher.SetManuallyIdentifiedHints(new Dictionary <PSFFit, IStar>());

            LeastSquareFittedAstrometry astrometricFit;
            PerformMatchResult          result = distBasedMatcher.PerformMatch(out astrometricFit);
        }
Exemple #3
0
        private void GenerateSimulatedVideo(object state)
        {
            InvokeUpdateUI(2, 0, true);

            try
            {
                ModelConfig modelConfig = (ModelConfig)state;

                modelConfig.MaxPixelValue = modelConfig.IsAAVFile ? (uint)modelConfig.Integration * 255 : 255;

                double dxRad  = modelConfig.FrameWidth * modelConfig.PlatePixWidth / (modelConfig.PlateFocLength * 1000.0);
                double dyRad  = modelConfig.FrameHeight * modelConfig.PlatePixHeight / (modelConfig.PlateFocLength * 1000.0);
                double fovDeg = AngleUtility.Elongation(0, 0, dxRad * 180 / Math.PI, dyRad * 180 / Math.PI);

                var          catFac = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);
                List <IStar> stars  = catFac.GetStarsInRegion(m_RA * 15, m_DE, 2 * fovDeg, modelConfig.LimitStarMag, 2000);

                if (modelConfig.IsAAVFile)
                {
                    GenerateAAVVideo(modelConfig, stars);
                }
                else
                {
                    GenerateAVIVideo(modelConfig, stars);
                }

                if (modelConfig.DarkFrameMean > 0 && cbxPhotometricFilter != null)
                {
                    // Save the dark frame
                    float[,] averagedFrame = new float[modelConfig.FrameWidth, modelConfig.FrameHeight];
                    for (int x = 0; x < modelConfig.FrameWidth; x++)
                    {
                        for (int y = 0; y < modelConfig.FrameHeight; y++)
                        {
                            averagedFrame[x, y] = m_SimulatedDarkFrame[x, y];
                        }
                    }

                    InvokeSaveDarkFrame(modelConfig, averagedFrame);
                }
            }
            finally
            {
                InvokeUpdateUI(2, 100, false);
            }
        }
Exemple #4
0
        private bool CheckInputAndLoadStars()
        {
            if (!TangraContext.Current.HasImageLoaded)
            {
                MessageBox.Show(this, "There is no loaded frame/image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            m_RAHours = double.NaN;
            m_DEDeg   = double.NaN;

            Context.ObsCode = tbxObsCode.Text;

            if (rbKnownCenter.Checked)
            {
                try
                {
                    m_RAHours = AstroConvert.ToRightAcsension(cbxRA.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid RA value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxRA.Focus();
                    cbxRA.Select();
                    return(false);
                }

                try
                {
                    m_DEDeg = AstroConvert.ToDeclination(cbxDE.Text);
                }
                catch
                {
                    MessageBox.Show(this, "Enter a valid DE value", "Validation Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    cbxDE.Focus();
                    cbxDE.Select();
                    return(false);
                }

                cbxRA.Persist();
                cbxDE.Persist();
            }
            else if (rbKnownObject.Checked)
            {
                // Connect to MPC to find the object coordinates
                MPEph2.MPEphEntry position = null;
                Cursor  = Cursors.WaitCursor;
                Enabled = false;
                try
                {
                    if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD && string.IsNullOrEmpty(tbxObsCode.Text))
                    {
                        m_VideoController.ShowTangraSettingsDialog(false, true);

                        if (!TangraConfig.Settings.HasSiteCoordinatesOrCOD)
                        {
                            return(false);
                        }
                    }


                    Refresh();

                    frmIdentifyObjects frm;

                    if (TangraConfig.Settings.Astrometry.UseMPCCode || !string.IsNullOrEmpty(tbxObsCode.Text))
                    {
                        Context.ObsCode = tbxObsCode.Text;
                        frm             = new frmIdentifyObjects(cbxObject.Text, Context.UtcTime, Context.ObsCode);
                    }
                    else
                    {
                        frm = new frmIdentifyObjects(
                            cbxObject.Text, Context.UtcTime,
                            TangraConfig.Settings.Generic.Longitude,
                            TangraConfig.Settings.Generic.Latitude);
                    }


                    if (m_VideoController.ShowDialog(frm) == DialogResult.OK)
                    {
                        position = frm.Position;
                    }
                }
                finally
                {
                    Enabled = true;
                    Cursor  = Cursors.Default;
                }

                if (position == null)
                {
                    MessageBox.Show(
                        this,
                        string.Format(string.Format("Could not retrieve the position of '{0}' from MPC. Is your internet connection active? Is the designation correct?", cbxObject.Text)),
                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    cbxObject.Focus();
                    cbxObject.Select();
                    return(false);
                }
                else
                {
                    m_RAHours = position.RAHours;
                    m_DEDeg   = position.DEDeg;

                    cbxObject.Persist();

                    Context.FoundObject = position;
                }
            }

            Context.RADeg   = m_RAHours * 15;
            Context.DEDeg   = m_DEDeg;
            Context.ErrFoVs = (double)nudError.Value;

            Context.Method = RecognitionMethod.KnownCenter;

            Context.LimitMagn = (double)nudFaintestMag.Value;

            float epoch = Context.UtcTime.Year + Context.UtcTime.DayOfYear / 365.25f;


            if (TangraConfig.Settings.TraceLevels.PlateSolving.TraceInfo())
            {
                Trace.WriteLine(string.Format("Loading stars in region ({0}, {1})",
                                              AstroConvert.ToStringValue(Context.RADeg / 15, "REC"),
                                              AstroConvert.ToStringValue(Context.DEDeg, "DEC")));
            }

            var facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

            m_CatalogueStars = facade.GetStarsInRegion(
                Context.RADeg,
                Context.DEDeg,
                (Context.ErrFoVs + 1.0) * m_Image.GetMaxFOVInArcSec() / 3600.0,
                Context.LimitMagn,
                epoch);

            Context.CatalogueStars      = m_CatalogueStars;
            Context.StarCatalogueFacade = facade;

            Context.DetermineAutoLimitMagnitude = rbAutomaticLimitMagnitude.Checked;
            Context.AutoLimitMagnitude          = double.NaN;

            return(true);
        }