Пример #1
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.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);
        }
        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);
            }
        }
Пример #3
0
        private void frmTangraSettings2_Load(object sender, EventArgs e)
        {
            if (ShowCatalogRequiredHint)
            {
                tvSettings.SelectedNode = tvSettings.Nodes["ndCatalogues"];

                if (TangraConfig.Settings.StarCatalogue.Catalog == TangraConfig.StarCatalog.NotSpecified)
                {
                    MessageBox.Show("Star catalog is required for calibration and astrometry.", "Star Catalog Required", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    m_ucStarCatalogues.cbxCatalogue.Focus();
                }
                else
                {
                    var catalogValidator = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

                    if (!StarCatalogueFacade.VerifyCurrentCatalogue(TangraConfig.Settings.StarCatalogue.Catalog, ref TangraConfig.Settings.StarCatalogue.CatalogLocation))
                    {
                        tvSettings.SelectedNode = tvSettings.Nodes["ndCatalogues"];

                        MessageBox.Show("The current star catalog location is invalid.", "Star Catalog Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_ucStarCatalogues.tbxCatalogueLocation.Focus();
                        m_ucStarCatalogues.tbxCatalogueLocation.SelectAll();

                    }
                }
            }
            else if (ShowLocationRequiredHint)
            {
                MessageBox.Show(
                    this,
                    "Please enter your site location or MPC observatory code",
                    "Information Required", MessageBoxButtons.OK, MessageBoxIcon.Error);

                tvSettings.SelectedNode = tvSettings.Nodes["ndCatalogues"];
            }
            else if (ShowUCAC4RequiredHint)
            {
                tvSettings.SelectedNode = tvSettings.Nodes["ndCatalogues"];

                if (TangraConfig.Settings.StarCatalogue.Catalog != TangraConfig.StarCatalog.UCAC4)
                {
                    MessageBox.Show("Modelling star field video requires UCAC4 to be configured as the star catalogue.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    m_ucStarCatalogues.cbxCatalogue.Focus();
                }
                else
                {
                    var catalogValidator = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);

                    if (!StarCatalogueFacade.VerifyCurrentCatalogue(TangraConfig.Settings.StarCatalogue.Catalog, ref TangraConfig.Settings.StarCatalogue.CatalogLocation))
                    {
                        tvSettings.SelectedNode = tvSettings.Nodes["ndCatalogues"];

                        MessageBox.Show("The current star catalog location is invalid.", "Star Catalog Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_ucStarCatalogues.tbxCatalogueLocation.Focus();
                        m_ucStarCatalogues.tbxCatalogueLocation.SelectAll();

                    }
                }
            }
            else
                tvSettings.SelectedNode = tvSettings.Nodes["ndGeneral"];
        }
Пример #4
0
        private bool EnsureAstrometryConfiguration()
        {
            StarCatalogueFacade facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);
            if (IsAstrometryUnconfigured(facade))
            {
                ShowSettings(true);

                if (IsAstrometryUnconfigured(facade))
                    return false;
            }

            return true;
        }
Пример #5
0
        public bool IsAstrometryUnconfigured(StarCatalogueFacade facade)
        {
            if (TangraConfig.Settings.StarCatalogue.Catalog == TangraConfig.StarCatalog.NotSpecified)
                return true;

            if (!StarCatalogueFacade.VerifyCurrentCatalogue(TangraConfig.Settings.StarCatalogue.Catalog, ref TangraConfig.Settings.StarCatalogue.CatalogLocation))
                return true;

            return false;
        }
Пример #6
0
        private void miStarFieldVideoModelling_Click(object sender, EventArgs e)
        {
            StarCatalogueFacade facade = new StarCatalogueFacade(TangraConfig.Settings.StarCatalogue);
            if (TangraConfig.Settings.StarCatalogue.Catalog != TangraConfig.StarCatalog.UCAC4 || IsAstrometryUnconfigured(facade))
            {
                ShowSettings(false, false, true);

                if (TangraConfig.Settings.StarCatalogue.Catalog != TangraConfig.StarCatalog.UCAC4 || IsAstrometryUnconfigured(facade))
                    return;
            }

            var frm = new frmGenerateStarFieldVideoModel(m_VideoController);
            frm.ShowDialog(this);
        }
Пример #7
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 = TangraConfig.Settings.Astrometry.MPCObservatoryCode;

            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)
                    {
                        m_VideoController.ShowTangraSettingsDialog(false, true);

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

                    Refresh();

                    frmIdentifyObjects frm;

                    if (TangraConfig.Settings.Astrometry.UseMPCCode)
                    {
                        Context.ObsCode = TangraConfig.Settings.Astrometry.MPCObservatoryCode;
                        frm = new frmIdentifyObjects(
                            cbxObject.Text, Context.UtcTime,
                            TangraConfig.Settings.Astrometry.MPCObservatoryCode);
                    }
                    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;
        }
Пример #8
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;
        }