示例#1
0
        public override void Activate()
        {
            m_VideoController.SetPictureBoxCursor(Cursors.Arrow);

            m_AstrometricState = AstrometricState.EnsureAstrometricState();

            TangraContext.Current.OSDExcludeToolDisabled = true;
            m_VideoController.UpdateViews();
        }
示例#2
0
        public override void MouseMove(Point location)
        {
            IStarMap map = AstrometryContext.Current.StarMap;

            if (map == null)
            {
                return;
            }

            bool nearbyStarFound = false;

            AstrometricState state = AstrometryContext.Current.AstrometricState;

            if (state != null)
            {
                if (state.AstrometricFit != null)
                {
                    for (int radius = 1; radius < 8; radius++)
                    {
                        ImagePixel centroid = map.GetCentroid(location.X, location.Y, radius);
                        if (centroid == null)
                        {
                            continue;
                        }


                        foreach (PlateConstStarPair star in state.AstrometricFit.FitInfo.AllStarPairs)
                        {
                            if (Math.Abs(star.x - centroid.XDouble) < radius &&
                                Math.Abs(star.y - centroid.YDouble) < radius)
                            {
                                m_Object = star;

                                nearbyStarFound = true;
                                break;
                            }
                        }

                        if (nearbyStarFound)
                        {
                            break;
                        }
                    }

                    if (!nearbyStarFound)
                    {
                        m_State = SelectObjectState.NoObject;
                    }
                    else
                    {
                        m_State = SelectObjectState.ObjectLocked;
                    }


                    if (m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready)
                    {
                        double ra, de;
                        state.AstrometricFit.GetRADEFromImageCoords(location.X, location.Y, out ra, out de);

                        string moreInfo = string.Format("RA={0} DE={1}", AstroConvert.ToStringValue(ra / 15, "HHhMMmSS.Ts"), AstroConvert.ToStringValue(de, "+DD°MM'SS\""));
                        m_VideoController.DisplayCursorPositionDetails(location, moreInfo);
                    }
                }
                else
                {
                    StarMapFeature nearbyFeature = map.GetFeatureInRadius(location.X, location.Y, 8);
                    nearbyStarFound = nearbyFeature != null && nearbyFeature.PixelCount > 4;
                }

                m_VideoController.SetPictureBoxCursor(nearbyStarFound ? Cursors.Hand : (state.ManualStarIdentificationMode ? Cursors.Cross : Cursors.Default));
            }
        }
示例#3
0
        public AstrometricSolutionImpl(LeastSquareFittedAstrometry astrometry, StarMagnitudeFit photometry, AstrometricState state, FieldSolveContext fieldSolveContext, MeasurementContext measurementContext)
        {
            StarCatalog        = fieldSolveContext.StarCatalogueFacade.CatalogNETCode;
            UtcTime            = fieldSolveContext.UtcTime;
            FrameNoOfUtcTime   = fieldSolveContext.FrameNoOfUtcTime;
            AutoLimitMagnitude = (float)fieldSolveContext.AutoLimitMagnitude;

            ResolvedFocalLength = (float)fieldSolveContext.FocalLength;

            if (astrometry != null)
            {
                ResolvedCenterRADeg = (float)astrometry.RA0Deg;
                ResolvedCenterDEDeg = (float)astrometry.DE0Deg;
                StdDevRAArcSec      = (float)astrometry.StdDevRAArcSec;
                StdDevDEArcSec      = (float)astrometry.StdDevDEArcSec;
                ArcSecsInPixel      = 1 / astrometry.GetDistanceInPixels(1);
            }
            else
            {
                ResolvedCenterRADeg = float.NaN;
                ResolvedCenterDEDeg = float.NaN;
                StdDevRAArcSec      = float.NaN;
                StdDevDEArcSec      = float.NaN;
                ArcSecsInPixel      = 0;
            }

            if (state.SelectedObject != null)
            {
                m_UserObject       = new TangraUserObjectImpl();
                m_UserObject.RADeg = (float)state.SelectedObject.RADeg;
                m_UserObject.DEDeg = (float)state.SelectedObject.DEDeg;
                m_UserObject.X     = (float)state.SelectedObject.X0;
                m_UserObject.Y     = (float)state.SelectedObject.Y0;

                if (state.IdentifiedObjects != null &&
                    state.IdentifiedObjects.Count == 1)
                {
                    foreach (IIdentifiedObject idObj in state.IdentifiedObjects)
                    {
                        if (AngleUtility.Elongation(idObj.RAHours * 15.0, idObj.DEDeg, state.SelectedObject.RADeg, state.SelectedObject.DEDeg) * 3600 < 120)
                        {
                            m_UserObject.ResolvedName = idObj.ObjectName;
                            break;
                        }
                    }
                }
            }

            InstrumentalDelay         = measurementContext.InstrumentalDelay;
            InstrumentalDelayUnits    = measurementContext.InstrumentalDelayUnits.ToString();
            FrameTimeType             = measurementContext.FrameTimeType.ToString();
            IntegratedFramesCount     = measurementContext.IntegratedFramesCount;
            IntegratedExposureSeconds = measurementContext.IntegratedExposureSeconds;
            AavIntegration            = measurementContext.AavIntegration;
            AavStackedMode            = measurementContext.AavStackedMode;
            VideoFileFormat           = measurementContext.VideoFileFormat.ToString();
            NativeVideoFormat         = measurementContext.NativeVideoFormat;
            if (!string.IsNullOrEmpty(state.IdentifiedObjectToMeasure))
            {
                ObjectDesignation = MPCObsLine.GetObjectCode(state.IdentifiedObjectToMeasure);
            }
            else if (state.IdentifiedObjects != null && state.IdentifiedObjects.Count == 1)
            {
                ObjectDesignation = MPCObsLine.GetObjectCode(state.IdentifiedObjects[0].ObjectName);
            }

            ObservatoryCode = fieldSolveContext.ObsCode;
            CatalogueCode   = measurementContext.StarCatalogueFacade.CatalogNETCode;

            m_MeasurementsImpl = new List <TangraAstrometricMeasurementImpl>();

            if (state.Measurements != null)
            {
                foreach (var mea in state.Measurements)
                {
                    m_MeasurementsImpl.Add(new TangraAstrometricMeasurementImpl()
                    {
                        DEDeg   = mea.DEDeg,
                        RADeg   = mea.RADeg,
                        FrameNo = mea.FrameNo,
                        SolutionUncertaintyRACosDEArcSec = mea.SolutionUncertaintyRACosDEArcSec,
                        SolutionUncertaintyDEArcSec      = mea.SolutionUncertaintyDEArcSec,
                        FWHMArcSec           = mea.FWHMArcSec,
                        Detection            = mea.Detection,
                        SNR                  = mea.SNR,
                        UncorrectedTimeStamp = mea.FrameTimeStamp,
                        Mag                  = mea.Mag
                    });
                }
            }

            m_MatchedStarImpl = new List <TangraMatchedStarImpl>();

            if (astrometry != null)
            {
                foreach (PlateConstStarPair pair in astrometry.FitInfo.AllStarPairs)
                {
                    if (pair.FitInfo.UsedInSolution)
                    {
                        var star = new TangraMatchedStarImpl()
                        {
                            X      = (float)pair.x,
                            Y      = (float)pair.y,
                            RADeg  = (float)pair.RADeg,
                            DEDeg  = (float)pair.DEDeg,
                            StarNo = pair.StarNo,
                            ExcludedForHighResidual = pair.FitInfo.ExcludedForHighResidual,
                            ResidualRAArcSec        = (float)pair.FitInfo.ResidualRAArcSec,
                            ResidualDEArcSec        = (float)pair.FitInfo.ResidualDEArcSec,
                            DetectionCertainty      = (float)pair.DetectionCertainty,
                            PSFAmplitude            = (int)pair.Intensity,
                            IsSaturated             = pair.IsSaturated,
                            Mag = (float)pair.Mag
                        };

                        TangraCatalogStarImpl catStar = null;

                        IStar catalogStar = fieldSolveContext.CatalogueStars.Find(s => s.StarNo == pair.StarNo);
                        if (catalogStar != null)
                        {
                            if (catalogStar is UCAC4Entry)
                            {
                                catStar = new TangraAPASSStar();
                            }
                            else
                            {
                                catStar = new TangraCatalogStarImpl();
                            }

                            catStar.StarNo = catalogStar.StarNo;
                            catStar.MagR   = (float)catalogStar.MagR;
                            catStar.MagV   = (float)catalogStar.MagV;
                            catStar.MagB   = (float)catalogStar.MagB;
                            catStar.Mag    = (float)catalogStar.Mag;

                            if (catalogStar is UCAC3Entry)
                            {
                                UCAC3Entry ucac3Star = (UCAC3Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac3Star.jmag * 0.001);
                                catStar.MagK       = (float)(ucac3Star.kmag * 0.001);
                                catStar.RAJ2000Deg = (float)ucac3Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac3Star.DECat;
                            }
                            else if (catalogStar is UCAC2Entry)
                            {
                                UCAC2Entry ucac2Star = (UCAC2Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac2Star._2m_J * 0.001);
                                catStar.MagK       = (float)(ucac2Star._2m_Ks * 0.001);
                                catStar.RAJ2000Deg = (float)ucac2Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac2Star.DECat;
                            }
                            else if (catalogStar is NOMADEntry)
                            {
                                NOMADEntry nomadStar = (NOMADEntry)catalogStar;
                                catStar.MagJ       = (float)(nomadStar.m_J * 0.001);
                                catStar.MagK       = (float)(nomadStar.m_K * 0.001);
                                catStar.RAJ2000Deg = (float)nomadStar.RACat;
                                catStar.DEJ2000Deg = (float)nomadStar.DECat;
                            }
                            else if (catalogStar is UCAC4Entry)
                            {
                                UCAC4Entry ucac4Star = (UCAC4Entry)catalogStar;
                                catStar.MagJ       = (float)(ucac4Star.MagJ);
                                catStar.MagK       = (float)(ucac4Star.MagK);
                                catStar.RAJ2000Deg = (float)ucac4Star.RACat;
                                catStar.DEJ2000Deg = (float)ucac4Star.DECat;

                                ((TangraAPASSStar)catStar).B   = (float)ucac4Star.MagB;
                                ((TangraAPASSStar)catStar).V   = (float)ucac4Star.MagV;
                                ((TangraAPASSStar)catStar).g   = (float)ucac4Star.Mag_g;
                                ((TangraAPASSStar)catStar).r   = (float)ucac4Star.Mag_r;
                                ((TangraAPASSStar)catStar).i   = (float)ucac4Star.Mag_i;
                                ((TangraAPASSStar)catStar).e_B = ucac4Star.apase_B * 0.001f;
                                ((TangraAPASSStar)catStar).e_V = ucac4Star.apase_V * 0.001f;
                                ((TangraAPASSStar)catStar).e_g = ucac4Star.apase_g * 0.001f;
                                ((TangraAPASSStar)catStar).e_r = ucac4Star.apase_r * 0.001f;
                                ((TangraAPASSStar)catStar).e_i = ucac4Star.apase_i * 0.001f;
                            }
                        }

                        star.CatalogStar = catStar;

                        if (photometry != null)
                        {
                            IStar photometryStar = photometry.StarNumbers.FirstOrDefault(s => s.StarNo == pair.StarNo);
                            if (photometryStar != null)
                            {
                                int idx = photometry.StarNumbers.IndexOf(photometryStar);
                                star.Intensity               = (float)photometry.Intencities[idx];
                                star.IsSaturated             = photometry.SaturatedFlags[idx];
                                star.MeaSignalMethod         = ConvertSignalMethod(photometry.MeaSignalMethod);
                                star.MeaBackgroundMethod     = ConvertBackgroundMethod(photometry.MeaBackgroundMethod);
                                star.MeaSingleApertureSize   = photometry.MeaSingleAperture;
                                star.MeaBackgroundPixelCount = photometry.MeaBackgroundPixelCount;
                                star.MeaSaturationLevel      = photometry.MeaSaturationLevel;
                            }
                        }

                        m_MatchedStarImpl.Add(star);
                    }
                }
            }
        }
示例#4
0
        public override void MouseClick(ObjectClickEventArgs e)
        {
            if (e.MouseEventArgs.Button == MouseButtons.Right && m_AstrometricState.ManualStarIdentificationMode)
            {
                m_AstrometryController.SetManuallyIdentifyStarState(false);
            }

            if (e.Pixel != null)
            {
                if ((m_AstrometricState.MeasuringState == AstrometryInFramesState.Ready || m_AstrometricState.MatchResult != PerformMatchResult.FitSucceessfull) &&
                    m_AstrometricState.ManualStarIdentificationMode &&
                    AstrometryContext.Current.FieldSolveContext.CatalogueStars != null &&
                    AstrometryContext.Current.FieldSolveContext.CatalogueStars.Count > 3)
                {
                    var          frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(AstrometryContext.Current.FieldSolveContext.CatalogueStars, m_AstrometricState.ManuallyIdentifiedStars, false);
                    DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                    if (res == DialogResult.Abort)
                    {
                        m_AstrometricState.ManuallyIdentifiedStars.Clear();
                        m_AstrometryController.SetManuallyIdentifyStarState(false);
                    }
                    else if (res == DialogResult.OK && frmIdentifyCalibrationStar.SelectedStar != null)
                    {
                        var frmQuestion = new frmIdentifiedStarAction(m_AstrometricState);
                        if (m_VideoController.ShowDialog(frmQuestion) == DialogResult.OK)
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_AstrometryController.TriggerPlateReSolve();
                            m_AstrometryController.SetManuallyIdentifyStarState(false);
                        }
                        else
                        {
                            m_AstrometricState.ManuallyIdentifiedStars.Add(e.Gausian, frmIdentifyCalibrationStar.SelectedStar);
                            m_VideoController.RedrawCurrentFrame(false, true, false);
                        }
                    }
                }
                else if (m_AstrometricState.MeasuringState != AstrometryInFramesState.RunningMeasurements)
                {
                    AstrometricState astrometryTracker = AstrometryContext.Current.AstrometricState;
                    if (astrometryTracker != null &&
                        astrometryTracker.AstrometricFit != null)
                    {
                        var objInfo = new SelectedObject()
                        {
                            X0 = e.Pixel.XDouble, Y0 = e.Pixel.YDouble
                        };
                        astrometryTracker.AstrometricFit.GetRADEFromImageCoords(e.Pixel.XDouble, e.Pixel.YDouble, out objInfo.RADeg, out objInfo.DEDeg);
                        objInfo.FittedStar = astrometryTracker.AstrometricFit.FitInfo.GetFittedStar(e.Pixel);
                        objInfo.Solution   = astrometryTracker.AstrometricFit;
                        objInfo.Pixel      = e.Pixel;
                        objInfo.Gaussian   = e.Gausian;
                        if (m_AstrometricState.IdentifiedObjects != null)
                        {
                            objInfo.IdentifiedObject = m_AstrometricState.GetIdentifiedObjectAt(objInfo.RADeg, objInfo.DEDeg);
                        }
                        else
                        {
                            objInfo.IdentifiedObject = null;
                        }


                        // We don't want to reload the current frame as this will result in trying another Astrometric Fit
                        // So we send a message to the Astrometry component about the newly selected object
                        m_AstrometryController.NewObjectSelected(objInfo);

                        m_SelectedObject = objInfo;
                        m_VideoController.RedrawCurrentFrame(false, true, false);
                    }
                }
            }
        }
 public frmIdentifiedStarAction(AstrometricState state)
     : this()
 {
     m_State = state;
     rbAttemptPlateSolve.Checked = m_State.ManuallyIdentifiedStars.Count >= 3;
 }