示例#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.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);
        }
示例#2
0
        public LeastSquareFittedAstrometry SolvePlateConstantsPhase4(double pyramidLimitMag)
        {
            double ra0deg, de0Deg;

            m_SolvedPlate.GetRADEFromImageCoords(m_SolvedPlate.Image.CenterXImage, m_SolvedPlate.Image.CenterYImage, out ra0deg, out de0Deg);

            FocalLengthFit distFit = m_ConstantsSolver.ComputeFocalLengthFit();

            m_Context.PlateConfig.EffectiveFocalLength = m_Context.FieldSolveContext.FocalLength;
            distFit.GetFocalParameters(m_Context.PlateConfig.EffectiveFocalLength, out m_Context.PlateConfig.EffectivePixelWidth, out m_Context.PlateConfig.EffectivePixelHeight);

            DistanceBasedAstrometrySolver distMatch = new DistanceBasedAstrometrySolver(
                m_AstrometryController,
                m_Context.PlateConfig,
                m_AstrometrySettings,
                m_Context.FieldSolveContext.CatalogueStars,
                m_Context.FieldSolveContext.RADeg,
                m_Context.FieldSolveContext.DEDeg,
                m_Context.FieldSolveContext.DetermineAutoLimitMagnitude);

            distMatch.SetMinMaxMagOfStarsForAstrometry(CorePyramidConfig.Default.DefaultMinAstrometryMagnitude, 18);

            distMatch.SetMinMaxMagOfStarsForPyramidAlignment(CorePyramidConfig.Default.DefaultMinPyramidMagnitude, pyramidLimitMag);
            Trace.WriteLine(string.Format("Stars for alignment in range: {0:0.0} - {1:0.0} mag", CorePyramidConfig.Default.DefaultMinPyramidMagnitude, pyramidLimitMag));

            Dictionary <PSFFit, IStar> manualStars = null;
            var threeStarFit = m_Context.PreliminaryFit as ThreeStarAstrometry;

            if (threeStarFit != null)
            {
                manualStars = new Dictionary <PSFFit, IStar>();
                foreach (var kvp in threeStarFit.UserStars)
                {
                    PSFFit psfFit;
                    m_Context.StarMap.GetPSFFit(kvp.Key.X, kvp.Key.Y, PSFFittingMethod.NonLinearFit, out psfFit);
                    if (psfFit != null && psfFit.IsSolved)
                    {
                        manualStars.Add(psfFit, kvp.Value);
                    }
                }
            }

            distMatch.InitNewMatch(m_Context.StarMap, PyramidMatchType.PlateSolve, manualStars);

#if ASTROMETRY_DEBUG
            Dictionary <int, ulong> debugInfo = new Dictionary <int, ulong>();

            var starList = m_Context.SecondAstrometricFit.FitInfo.AllStarPairs
                           .Where(p => !p.FitInfo.ExcludedForHighResidual);

            foreach (var x in starList)
            {
                if (!debugInfo.ContainsKey(x.FeatureId))
                {
                    debugInfo.Add(x.FeatureId, x.StarNo);
                }
            }

            foreach (var f in m_Context.StarMap.Features)
            {
                Trace.WriteLine(string.Format("{0} - {1}", f.FeatureId, debugInfo.ContainsKey(f.FeatureId) ? "INCLUDED" : "MISSING"));
            }

            distMatch.SetDebugData(new DistanceBasedAstrometrySolver.PyramidDebugContext()
            {
                ResolvedStars       = debugInfo,
                ResolvedFocalLength = m_Context.SecondAstrometricFit.FitInfo.FittedFocalLength
            });
#endif

            LeastSquareFittedAstrometry fit         = null;
            LeastSquareFittedAstrometry improvedFit = null;
            PlateConstantsSolver        solver;
            distMatch.PerformMatch(out fit, out improvedFit, out solver);

            m_Context.DistanceBasedFit         = fit;
            m_Context.ImprovedDistanceBasedFit = improvedFit;

            if (fit != null)
            {
                m_Context.PlateConstants = new TangraConfig.PersistedPlateConstants
                {
                    EffectiveFocalLength = m_Context.PlateConfig.EffectiveFocalLength,
                    EffectivePixelWidth  = m_Context.PlateConfig.EffectivePixelWidth,
                    EffectivePixelHeight = m_Context.PlateConfig.EffectivePixelHeight
                };

                m_Context.ConstantsSolver = solver;

                if (improvedFit != null)
                {
                    foreach (var pair in improvedFit.FitInfo.AllStarPairs)
                    {
                        if (pair.FitInfo.ExcludedForHighResidual)
                        {
                            continue;
                        }

                        Trace.WriteLine(string.Format("{6}; {0}; {1}; {2}; {3}; ({4}\", {5}\")",
                                                      pair.RADeg, pair.DEDeg, pair.x.ToString("0.00"), pair.y.ToString("0.00"),
                                                      pair.FitInfo.ResidualRAArcSec.ToString("0.00"), pair.FitInfo.ResidualDEArcSec.ToString("0.00"),
                                                      pair.StarNo));

                        double x, y;
                        improvedFit.GetImageCoordsFromRADE(pair.RADeg, pair.DEDeg, out x, out y);
                        double dist = improvedFit.GetDistanceInArcSec(x, y, pair.x, pair.y);
                    }
                }
            }
            else
            {
                m_Context.PlateConstants = null;
            }

            return(fit);
        }