public static DirectTransRotAstrometry FromReflectedObject(object reflObj) { var rv = new DirectTransRotAstrometry(); rv.m_RA0Deg = StarMap.GetPropValue <double>(reflObj, "m_RA0Deg"); rv.m_DE0Deg = StarMap.GetPropValue <double>(reflObj, "m_DE0Deg"); rv.m_EtaDeg = StarMap.GetPropValue <double>(reflObj, "m_EtaDeg"); rv.m_Aspect = StarMap.GetPropValue <double>(reflObj, "m_Aspect"); object image = StarMap.GetPropValue <object>(reflObj, "m_Image"); rv.m_Image = AstroPlate.FromReflectedObject(image); return(rv); }
public static DirectTransRotAstrometry SolveByThreeStars( AstroPlate image, Dictionary<ImagePixel, IStar> userStarIdentification, int tolerance) { double SingularityMinDiffPix = 2.0; List<KeyValuePair<ImagePixel, IStar>> master = userStarIdentification.ToList(); List<KeyValuePair<ImagePixel, IStar>> list = new List<KeyValuePair<ImagePixel, IStar>>(); for (int i = 0; i < 3; i++) { list.Clear(); if (i == 0) { list.Add(master[0]); list.Add(master[1]); list.Add(master[2]); } else if (i == 1) { list.Add(master[2]); list.Add(master[0]); list.Add(master[1]); } else if (i == 2) { list.Add(master[1]); list.Add(master[2]); list.Add(master[0]); } double x1 = list[0].Key.XDouble; double y1 = list[0].Key.YDouble; double ra1 = list[0].Value.RADeg; double de1 = list[0].Value.DEDeg; double x2 = list[1].Key.XDouble; double y2 = list[1].Key.YDouble; double ra2 = list[1].Value.RADeg; double de2 = list[1].Value.DEDeg; double x3 = list[2].Key.XDouble; double y3 = list[2].Key.YDouble; double ra3 = list[2].Value.RADeg; double de3 = list[2].Value.DEDeg; #region Dealing with singularity issues if (Math.Abs(x1 - x2) < SingularityMinDiffPix) { if (x1 < x2) x2 = x1 + SingularityMinDiffPix; else x1 = x2 + SingularityMinDiffPix; } if (Math.Abs(x1 - x3) < SingularityMinDiffPix) { if (x1 < x3) x3 = x1 + SingularityMinDiffPix; else x1 = x3 + SingularityMinDiffPix; } if (Math.Abs(x2 - x3) < SingularityMinDiffPix) { if (x2 < x3) x3 = x2 + SingularityMinDiffPix; else x2 = x3 + SingularityMinDiffPix; } if (Math.Abs(y1 - y2) < SingularityMinDiffPix) { if (y1 < y2) y2 = y1 + SingularityMinDiffPix; else y1 = y2 + SingularityMinDiffPix; } if (Math.Abs(y1 - y3) < SingularityMinDiffPix) { if (y1 < y3) y3 = y1 + SingularityMinDiffPix; else y1 = y3 + SingularityMinDiffPix; } if (Math.Abs(y2 - y3) < SingularityMinDiffPix) { if (y2 < y3) y3 = y2 + SingularityMinDiffPix; else y2 = y3 + SingularityMinDiffPix; } #endregion double YY = 1000.0 * 3600 / (206265 * image.EffectivePixelHeight); double XX = 1000.0 * 3600 / (206265 * image.EffectivePixelWidth); double f_cose = ((y1 - y2) * (ra1 - ra3) - (y1 - y3) * (ra1 - ra2)) / (YY * ((de1 - de2) * (ra1 - ra3) - (de1 - de3) * (ra1 - ra2))); double f_sine = (de1 - de2) * f_cose / (ra1 - ra2) - (y1 - y2) / (YY * (ra1 - ra2)); double eta1rad = Math.Atan(f_sine / f_cose); double eta2rad = Math.PI + eta1rad; double foc_len1 = Math.Abs(f_sine / Math.Sin(eta1rad)); double foc_len2 = Math.Abs(f_sine / Math.Sin(eta2rad)); double aspect1 = (foc_len1 * XX * Math.Cos(eta1rad) * (ra1 - ra2 + (de1 - de2) * Math.Tan(eta1rad))) / (x1 - x2); double DE01 = de1 - Math.Sin(eta1rad) * Math.Cos(eta1rad) * (aspect1 * (x1 - image.CenterXImage) / (foc_len1 * XX * Math.Cos(eta1rad)) + (y1 - image.CenterYImage) / (foc_len1 * YY * Math.Sin(eta1rad))); double RA01 = ra1 - ((de1 - DE01) * Math.Cos(eta1rad) - (y1 - image.CenterYImage) / (foc_len1 * YY)) / Math.Sin(eta1rad); double aspect2 = (foc_len2 * XX * Math.Cos(eta2rad) * (ra1 - ra2 + (de1 - de2) * Math.Tan(eta2rad))) / (x1 - x2); double DE02 = de1 - Math.Sin(eta2rad) * Math.Cos(eta2rad) * (aspect2 * (x1 - image.CenterXImage) / (foc_len2 * XX * Math.Cos(eta2rad)) + (y1 - image.CenterYImage) / (foc_len2 * YY * Math.Sin(eta2rad))); double RA02 = ra1 - ((de1 - DE02) * Math.Cos(eta2rad) - (y1 - image.CenterYImage) / (foc_len2 * YY)) / Math.Sin(eta2rad); AstroPlate plate1 = image.Clone(); plate1.EffectiveFocalLength = foc_len1; DirectTransRotAstrometry solution1 = new DirectTransRotAstrometry(plate1, RA01, DE01, eta1rad * 180.0 / Math.PI, aspect1); AstroPlate plate2 = image.Clone(); plate2.EffectiveFocalLength = foc_len2; DirectTransRotAstrometry solution2 = new DirectTransRotAstrometry(plate2, RA02, DE02, eta2rad * 180.0 / Math.PI, aspect2); double xx1, yy1, xx2, yy2, xx3, yy3; solution1.GetImageCoordsFromRADE(ra1, de1, out xx1, out yy1); solution1.GetImageCoordsFromRADE(ra2, de2, out xx2, out yy2); solution1.GetImageCoordsFromRADE(ra3, de3, out xx3, out yy3); solution1.Residual = Math.Sqrt( (x1 - xx1) * (x1 - xx1) + (y1 - yy1) * (y1 - yy1) + (x2 - xx2) * (x2 - xx2) + (y2 - yy2) * (y2 - yy2) + (x3 - xx3) * (x3 - xx3) + (y3 - yy3) * (y3 - yy3)); solution2.GetImageCoordsFromRADE(ra1, de1, out xx1, out yy1); solution2.GetImageCoordsFromRADE(ra2, de2, out xx2, out yy2); solution2.GetImageCoordsFromRADE(ra3, de3, out xx3, out yy3); solution2.Residual = Math.Sqrt( (x1 - xx1) * (x1 - xx1) + (y1 - yy1) * (y1 - yy1) + (x2 - xx2) * (x2 - xx2) + (y2 - yy2) * (y2 - yy2) + (x3 - xx3) * (x3 - xx3) + (y3 - yy3) * (y3 - yy3)); double maxResidual = CorePyramidConfig.Default.MaxThreeIdentifiedStarsFitResidual; if (tolerance == 1) maxResidual *= 0.75; else if (tolerance == 3) maxResidual *= 2; else if (tolerance == 4) maxResidual *= 3; if (solution1.Residual < solution2.Residual) { if (solution1.Residual < maxResidual && aspect1 > 0) return solution1; } else { if (solution2.Residual < maxResidual && aspect2 > 0) return solution2; } } return null; }
public static DirectTransRotAstrometry FromReflectedObject(object reflObj) { var rv = new DirectTransRotAstrometry(); rv.m_RA0Deg = StarMap.GetPropValue<double>(reflObj, "m_RA0Deg"); rv.m_DE0Deg = StarMap.GetPropValue<double>(reflObj, "m_DE0Deg"); rv.m_EtaDeg = StarMap.GetPropValue<double>(reflObj, "m_EtaDeg"); rv.m_Aspect = StarMap.GetPropValue<double>(reflObj, "m_Aspect"); object image = StarMap.GetPropValue<object>(reflObj, "m_Image"); rv.m_Image = AstroPlate.FromReflectedObject(image); return rv; }
public static DirectTransRotAstrometry SolveByThreeStars( AstroPlate image, Dictionary <ImagePixel, IStar> userStarIdentification, int tolerance) { double SingularityMinDiffPix = 2.0; List <KeyValuePair <ImagePixel, IStar> > master = userStarIdentification.ToList(); List <KeyValuePair <ImagePixel, IStar> > list = new List <KeyValuePair <ImagePixel, IStar> >(); for (int i = 0; i < 3; i++) { list.Clear(); if (i == 0) { list.Add(master[0]); list.Add(master[1]); list.Add(master[2]); } else if (i == 1) { list.Add(master[2]); list.Add(master[0]); list.Add(master[1]); } else if (i == 2) { list.Add(master[1]); list.Add(master[2]); list.Add(master[0]); } double x1 = list[0].Key.XDouble; double y1 = list[0].Key.YDouble; double ra1 = list[0].Value.RADeg; double de1 = list[0].Value.DEDeg; double x2 = list[1].Key.XDouble; double y2 = list[1].Key.YDouble; double ra2 = list[1].Value.RADeg; double de2 = list[1].Value.DEDeg; double x3 = list[2].Key.XDouble; double y3 = list[2].Key.YDouble; double ra3 = list[2].Value.RADeg; double de3 = list[2].Value.DEDeg; #region Dealing with singularity issues if (Math.Abs(x1 - x2) < SingularityMinDiffPix) { if (x1 < x2) { x2 = x1 + SingularityMinDiffPix; } else { x1 = x2 + SingularityMinDiffPix; } } if (Math.Abs(x1 - x3) < SingularityMinDiffPix) { if (x1 < x3) { x3 = x1 + SingularityMinDiffPix; } else { x1 = x3 + SingularityMinDiffPix; } } if (Math.Abs(x2 - x3) < SingularityMinDiffPix) { if (x2 < x3) { x3 = x2 + SingularityMinDiffPix; } else { x2 = x3 + SingularityMinDiffPix; } } if (Math.Abs(y1 - y2) < SingularityMinDiffPix) { if (y1 < y2) { y2 = y1 + SingularityMinDiffPix; } else { y1 = y2 + SingularityMinDiffPix; } } if (Math.Abs(y1 - y3) < SingularityMinDiffPix) { if (y1 < y3) { y3 = y1 + SingularityMinDiffPix; } else { y1 = y3 + SingularityMinDiffPix; } } if (Math.Abs(y2 - y3) < SingularityMinDiffPix) { if (y2 < y3) { y3 = y2 + SingularityMinDiffPix; } else { y2 = y3 + SingularityMinDiffPix; } } #endregion double YY = 1000.0 * 3600 / (206265 * image.EffectivePixelHeight); double XX = 1000.0 * 3600 / (206265 * image.EffectivePixelWidth); double f_cose = ((y1 - y2) * (ra1 - ra3) - (y1 - y3) * (ra1 - ra2)) / (YY * ((de1 - de2) * (ra1 - ra3) - (de1 - de3) * (ra1 - ra2))); double f_sine = (de1 - de2) * f_cose / (ra1 - ra2) - (y1 - y2) / (YY * (ra1 - ra2)); double eta1rad = Math.Atan(f_sine / f_cose); double eta2rad = Math.PI + eta1rad; double foc_len1 = Math.Abs(f_sine / Math.Sin(eta1rad)); double foc_len2 = Math.Abs(f_sine / Math.Sin(eta2rad)); double aspect1 = (foc_len1 * XX * Math.Cos(eta1rad) * (ra1 - ra2 + (de1 - de2) * Math.Tan(eta1rad))) / (x1 - x2); double DE01 = de1 - Math.Sin(eta1rad) * Math.Cos(eta1rad) * (aspect1 * (x1 - image.CenterXImage) / (foc_len1 * XX * Math.Cos(eta1rad)) + (y1 - image.CenterYImage) / (foc_len1 * YY * Math.Sin(eta1rad))); double RA01 = ra1 - ((de1 - DE01) * Math.Cos(eta1rad) - (y1 - image.CenterYImage) / (foc_len1 * YY)) / Math.Sin(eta1rad); double aspect2 = (foc_len2 * XX * Math.Cos(eta2rad) * (ra1 - ra2 + (de1 - de2) * Math.Tan(eta2rad))) / (x1 - x2); double DE02 = de1 - Math.Sin(eta2rad) * Math.Cos(eta2rad) * (aspect2 * (x1 - image.CenterXImage) / (foc_len2 * XX * Math.Cos(eta2rad)) + (y1 - image.CenterYImage) / (foc_len2 * YY * Math.Sin(eta2rad))); double RA02 = ra1 - ((de1 - DE02) * Math.Cos(eta2rad) - (y1 - image.CenterYImage) / (foc_len2 * YY)) / Math.Sin(eta2rad); AstroPlate plate1 = image.Clone(); plate1.EffectiveFocalLength = foc_len1; DirectTransRotAstrometry solution1 = new DirectTransRotAstrometry(plate1, RA01, DE01, eta1rad * 180.0 / Math.PI, aspect1); AstroPlate plate2 = image.Clone(); plate2.EffectiveFocalLength = foc_len2; DirectTransRotAstrometry solution2 = new DirectTransRotAstrometry(plate2, RA02, DE02, eta2rad * 180.0 / Math.PI, aspect2); double xx1, yy1, xx2, yy2, xx3, yy3; solution1.GetImageCoordsFromRADE(ra1, de1, out xx1, out yy1); solution1.GetImageCoordsFromRADE(ra2, de2, out xx2, out yy2); solution1.GetImageCoordsFromRADE(ra3, de3, out xx3, out yy3); solution1.Residual = Math.Sqrt( (x1 - xx1) * (x1 - xx1) + (y1 - yy1) * (y1 - yy1) + (x2 - xx2) * (x2 - xx2) + (y2 - yy2) * (y2 - yy2) + (x3 - xx3) * (x3 - xx3) + (y3 - yy3) * (y3 - yy3)); solution2.GetImageCoordsFromRADE(ra1, de1, out xx1, out yy1); solution2.GetImageCoordsFromRADE(ra2, de2, out xx2, out yy2); solution2.GetImageCoordsFromRADE(ra3, de3, out xx3, out yy3); solution2.Residual = Math.Sqrt( (x1 - xx1) * (x1 - xx1) + (y1 - yy1) * (y1 - yy1) + (x2 - xx2) * (x2 - xx2) + (y2 - yy2) * (y2 - yy2) + (x3 - xx3) * (x3 - xx3) + (y3 - yy3) * (y3 - yy3)); double maxResidual = CorePyramidConfig.Default.MaxThreeIdentifiedStarsFitResidual; if (tolerance == 1) { maxResidual *= 0.75; } else if (tolerance == 3) { maxResidual *= 2; } else if (tolerance == 4) { maxResidual *= 3; } if (solution1.Residual < solution2.Residual) { if (solution1.Residual < maxResidual && aspect1 > 0) { return(solution1); } } else { if (solution2.Residual < maxResidual && aspect2 > 0) { return(solution2); } } } return(null); }
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; }