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); }
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); }
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); }
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); }