Exemplo n.º 1
0
        public void GetRADEFromImageCoords(double x, double y, out double RADeg, out double DEDeg)
        {
            double xTang = m_A * x + m_B * y + m_C;
            double yTang = m_D * x + m_E * y + m_F;

            TangentPlane.TangentToCelestial(xTang, yTang, m_RA0Deg, m_DE0Deg, out RADeg, out DEDeg);
        }
Exemplo n.º 2
0
        public void GetRADEFromImageCoords(double x, double y, out double RADeg, out double DE)
        {
            double xTang, yTang;

            m_SolvedConstants.GetTangentCoordsFromImageCoords(x, y, out xTang, out yTang);

            TangentPlane.TangentToCelestial(xTang, yTang, m_RA0Deg, m_DE0Deg, out RADeg, out DE);
        }
Exemplo n.º 3
0
        public void GetImageCoordsFromRADE(double RADeg, double DEDeg, out double x, out double y)
        {
            double xTang, yTang;

            TangentPlane.CelestialToTangent(RADeg, DEDeg, m_RA0Deg, m_DE0Deg, out xTang, out yTang);

            x = m_A1 * xTang + m_B1 * yTang + m_C1;
            y = m_D1 * xTang + m_E1 * yTang + m_F1;
        }
Exemplo n.º 4
0
        public void GetImageCoordsFromRADE(double RADeg, double DE, out double x, out double y)
        {
            double xTang, yTang;

            TangentPlane.CelestialToTangent(RADeg, DE, m_RA0Deg, m_DE0Deg, out xTang, out yTang);


            m_SolvedConstants.GetImageCoordsFromTangentCoords(xTang, yTang, out x, out y);
        }
Exemplo n.º 5
0
        public void GetRADEFromImageCoords(double x, double y, out double RADeg, out double DE)
        {
            double mtxX, mtxY;

            m_Image.ImageCoordsToMatrixCoords(x - m_Image.CenterXImage, y - m_Image.CenterYImage, out mtxX, out mtxY, CoordinateReference.Center);

            double xt = Math.Cos(EtaRadians) * mtxX - Math.Sin(EtaRadians) * mtxY;
            double yt = Math.Sin(EtaRadians) * mtxX + Math.Cos(EtaRadians) * mtxY;

            double tangentalX = xt * cellWidth / (focalLength * 1000.0);
            double tangentalY = yt * cellHeight / (focalLength * 1000.0);

            tangentalY = -tangentalY;

            TangentPlane.TangentToCelestial(tangentalX, tangentalY, m_RA0Deg, this.m_DE0Deg, out RADeg, out DE);
        }
Exemplo n.º 6
0
        public void GetImageCoordsFromRADE(double RADeg, double DE, out double x, out double y)
        {
            double tangentalX, tangentalY;

            TangentPlane.CelestialToTangent(RADeg, DE, this.m_RA0Deg, this.m_DE0Deg, out tangentalX, out tangentalY);

            tangentalY = -tangentalY;

            double plateX = tangentalX * (focalLength * 1000.0 / cellWidth);
            double plateY = tangentalY * (focalLength * 1000.0 / cellHeight);

            double mtxX = Math.Cos(EtaRadians) * plateX + Math.Sin(EtaRadians) * plateY;
            double mtxY = Math.Cos(EtaRadians) * plateY - Math.Sin(EtaRadians) * plateX;


            m_Image.MatrixCoordsToImageCoords(mtxX, mtxY, out x, out y, CoordinateReference.Center);

            x += m_Image.CenterXImage;
            y += m_Image.CenterYImage;
        }
Exemplo n.º 7
0
        private PlateConstStarPair AddStar(double x, double RADeg, double y, double DE, double mag, int intensity, double detectionCertainty, bool isSaturated)
        {
            double xExpected, yExpected;

            TangentPlane.CelestialToTangent(RADeg, DE, m_Tangent_RA0, m_Tangent_DE0, out xExpected, out yExpected);

            PlateConstStarPair pair = new PlateConstStarPair();

            pair.x                  = x;
            pair.y                  = y;
            pair.ExpectedXTang      = xExpected;
            pair.ExpectedYTang      = yExpected;
            pair.Mag                = mag;
            pair.Intensity          = (uint)intensity;
            pair.IsSaturated        = isSaturated;
            pair.DetectionCertainty = detectionCertainty;

            m_Pairs.Add(pair);

            return(pair);
        }
Exemplo n.º 8
0
        public ThreeStarFit(
            AstroPlate image,
            StarPair pair1,
            StarPair pair2,
            StarPair pair3)
        {
            m_Image = image;

            // X1 = a*x1 + b*y1 + c
            // Y1 = d*x1 + e*y1 + f
            // X2 = a*x2 + b*y2 + c
            // Y2 = d*x2 + e*y2 + f
            // X3 = a*x3 + b*y3 + c
            // Y3 = d*x3 + e*y3 + f

            // NOTE: First do a SimpleRaDec fit to get the RA0/DE0

            double DX12 = pair1.RADeg - pair2.RADeg;
            double DX23 = pair2.RADeg - pair3.RADeg;
            double DY12 = pair1.DEDeg - pair2.DEDeg;
            double DY23 = pair2.DEDeg - pair3.DEDeg;
            double dx12 = pair1.XImage - pair2.XImage;
            double dx23 = pair2.XImage - pair3.XImage;
            double dy12 = pair1.YImage - pair2.YImage;
            double dy23 = pair2.YImage - pair3.YImage;

            // Singularity
            if (DX12 * DX23 * DY12 * DY23 * dx12 * dx23 * dy12 * dy23 == 0)
            {
                m_IsSingularity = true;
                return;
            }

            m_A = (DX12 * dy23 - DX23 * dy12) / (dx12 * dy23 - dx23 * dy12);
            m_B = (DX12 - m_A * dx12) / dy12;
            m_C = pair1.RADeg - m_A * pair1.XImage - m_B * pair1.YImage;
            m_D = (DY12 * dy23 - DY23 * dy12) / (dx12 * dy23 - dx23 * dy12);
            m_E = (DY12 - m_D * dx12) / dy12;
            m_F = pair1.DEDeg - m_D * pair1.XImage - m_E * pair1.YImage;

            m_RA0Deg = m_A * m_Image.CenterXImage + m_B * m_Image.CenterYImage + m_C;
            m_DE0Deg = m_D * m_Image.CenterXImage + m_E * m_Image.CenterYImage + m_F;

            // NOTE: Then do the Tangental solution

            TangentPlane.CelestialToTangent(pair1.RADeg, pair1.DEDeg, m_RA0Deg, m_DE0Deg, out pair1.XTangent, out pair1.YTangent);
            TangentPlane.CelestialToTangent(pair2.RADeg, pair2.DEDeg, m_RA0Deg, m_DE0Deg, out pair2.XTangent, out pair2.YTangent);
            TangentPlane.CelestialToTangent(pair3.RADeg, pair3.DEDeg, m_RA0Deg, m_DE0Deg, out pair3.XTangent, out pair3.YTangent);

            DX12 = pair1.XTangent - pair2.XTangent;
            DX23 = pair2.XTangent - pair3.XTangent;
            DY12 = pair1.YTangent - pair2.YTangent;
            DY23 = pair2.YTangent - pair3.YTangent;

            m_A = (DX12 * dy23 - DX23 * dy12) / (dx12 * dy23 - dx23 * dy12);
            m_B = (DX12 - m_A * dx12) / dy12;
            m_C = pair1.XTangent - m_A * pair1.XImage - m_B * pair1.YImage;
            m_D = (DY12 * dy23 - DY23 * dy12) / (dx12 * dy23 - dx23 * dy12);
            m_E = (DY12 - m_D * dx12) / dy12;
            m_F = pair1.YTangent - m_D * pair1.XImage - m_E * pair1.YImage;

            m_A1 = m_E / (m_E * m_A - m_B * m_D);
            m_B1 = -m_B / (m_E * m_A - m_B * m_D);
            m_C1 = (m_B * m_F - m_C * m_E) / (m_E * m_A - m_B * m_D);
            m_D1 = m_D / (m_B * m_D - m_A * m_E);
            m_E1 = -m_A / (m_B * m_D - m_A * m_E);
            m_F1 = (m_A * m_F - m_C * m_D) / (m_B * m_D - m_A * m_E);

            m_IsSolved = true;
        }
Exemplo n.º 9
0
        private bool LeastSquareSolve(double ra0Deg, double de0Deg, int minNumberOfStars)
        {
            int[] NUM_CONSTANTS = new int[] { 3, 6, 10 };

            SafeMatrix A = new SafeMatrix(m_StarPairs.Count, NUM_CONSTANTS[(int)m_FitOrder]);
            SafeMatrix X = new SafeMatrix(m_StarPairs.Count, 1);
            SafeMatrix Y = new SafeMatrix(m_StarPairs.Count, 1);

            SafeMatrix AReverse = new SafeMatrix(m_StarPairs.Count, NUM_CONSTANTS[(int)m_FitOrder]);
            SafeMatrix XReverse = new SafeMatrix(m_StarPairs.Count, 1);
            SafeMatrix YReverse = new SafeMatrix(m_StarPairs.Count, 1);

            int numStars = 0;

            for (int i = 0; i < m_StarPairs.Count; i++)
            {
                m_StarPairs[i].FitInfo.UsedInSolution = false;

                if (m_StarPairs[i].FitInfo.ExcludedForHighResidual)
                {
                    continue;
                }

                numStars++;
                m_StarPairs[i].FitInfo.UsedInSolution = true;

                ConfigureObservation(A, AReverse, i);

                X[i, 0]        = m_StarPairs[i].ExpectedXTang;
                Y[i, 0]        = m_StarPairs[i].ExpectedYTang;
                XReverse[i, 0] = m_StarPairs[i].x;
                YReverse[i, 0] = m_StarPairs[i].y;
            }

            // Insufficient stars to solve the plate
            if (numStars < minNumberOfStars)
            {
                if (TangraConfig.Settings.TraceLevels.PlateSolving.TraceVerbose())
                {
                    Debug.WriteLine(string.Format("Insufficient number of stars to do a fit. At least {0} stars requested.", minNumberOfStars));
                }

                return(false);
            }

            SafeMatrix a_T    = A.Transpose();
            SafeMatrix aa     = a_T * A;
            SafeMatrix aa_inv = aa.Inverse();
            SafeMatrix bx     = (aa_inv * a_T) * X;
            SafeMatrix by     = (aa_inv * a_T) * Y;

            if (ReadSolvedConstants(bx, by))
            {
                a_T    = AReverse.Transpose();
                aa     = a_T * AReverse;
                aa_inv = aa.Inverse();
                bx     = (aa_inv * a_T) * XReverse;
                by     = (aa_inv * a_T) * YReverse;

                ReadSolvedReversedConstants(bx, by);
            }

            double residualSum         = 0;
            double residualSumArcSecRA = 0;
            double residualSumArcSecDE = 0;
            int    numResiduals        = 0;

            var absResRAArcSec = new List <double>();
            var absResDEArcSec = new List <double>();

            for (int i = 0; i < m_StarPairs.Count; i++)
            {
                double computedXTang, computedYTang;
                GetTangentCoordsFromImageCoords(m_StarPairs[i].x, m_StarPairs[i].y, out computedXTang, out computedYTang);

                m_StarPairs[i].FitInfo.ResidualXTang = m_StarPairs[i].ExpectedXTang - computedXTang;
                m_StarPairs[i].FitInfo.ResidualYTang = m_StarPairs[i].ExpectedYTang - computedYTang;

                double raComp, deComp;
                TangentPlane.TangentToCelestial(computedXTang, computedYTang, ra0Deg, de0Deg, out raComp, out deComp);

                m_StarPairs[i].FitInfo.ResidualRAArcSec = 3600.0 * AngleUtility.Elongation(m_StarPairs[i].RADeg, 0, raComp, 0);
                m_StarPairs[i].FitInfo.ResidualDEArcSec = 3600.0 * AngleUtility.Elongation(0, m_StarPairs[i].DEDeg, 0, deComp);

                if (!m_StarPairs[i].FitInfo.UsedInSolution)
                {
                    continue;
                }
                numResiduals++;
                residualSum         += Math.Abs(m_StarPairs[i].FitInfo.ResidualXTang * m_StarPairs[i].FitInfo.ResidualYTang);
                residualSumArcSecRA += m_StarPairs[i].FitInfo.ResidualRAArcSec * m_StarPairs[i].FitInfo.ResidualRAArcSec;
                residualSumArcSecDE += m_StarPairs[i].FitInfo.ResidualDEArcSec * m_StarPairs[i].FitInfo.ResidualDEArcSec;
                absResRAArcSec.Add(Math.Abs(m_StarPairs[i].FitInfo.ResidualRAArcSec));
                absResDEArcSec.Add(Math.Abs(m_StarPairs[i].FitInfo.ResidualDEArcSec));
            }

            Variance         = residualSum / (numResiduals - 1);
            VarianceArcSecRA = residualSumArcSecRA / (numResiduals - 1);
            VarianceArcSecDE = residualSumArcSecDE / (numResiduals - 1);

            // Uncertainty based on Astrometrica's formula of median residual devided by SQRT(num stars)
            UncertaintyArcSecRA = absResRAArcSec.Median() / Math.Sqrt(numResiduals);
            UncertaintyArcSecDE = absResDEArcSec.Median() / Math.Sqrt(numResiduals);


            return(true);
        }