public TangentalNormalizedDirectionAstrometry(TangentalTransRotAstrometry baseAstrometry) { m_Astrometry = baseAstrometry; double fovDeg = baseAstrometry.Image.GetMaxFOVInArcSec() / 3600; double raFrom = baseAstrometry.m_RA0Deg - fovDeg / 2.0; double raTo = baseAstrometry.m_RA0Deg + fovDeg / 2.0; double deFrom = baseAstrometry.m_DE0Deg - fovDeg / 2.0; double deTo = baseAstrometry.m_DE0Deg + fovDeg / 2.0; double x1, y1, x2, y2; baseAstrometry.GetImageCoordsFromRADE(raFrom, deFrom, out x1, out y1); baseAstrometry.GetImageCoordsFromRADE(raTo, deTo, out x2, out y2); m_ReverseX = x1 > x2; m_ReverseY = y1 > y2; }
public void Initialize(List <ulong> alwaysIncludeStars) { if (DebugResolvedStarsWithAppliedExclusions != null) { List <ulong> debugStarIds = DebugResolvedStarsWithAppliedExclusions.Values.ToList(); List <IStar> missingstars = m_Stars.Where(s => !debugStarIds.Contains(s.StarNo)).ToList(); Trace.Assert(missingstars.Count == 0, string.Format("There are {0} of the debug stars not found among the initial pyramid stars", missingstars.Count)); } if (alwaysIncludeStars != null && alwaysIncludeStars.Count > 0) { foreach (var starNo in alwaysIncludeStars.ToArray()) { if (m_Stars.FirstOrDefault(s => s.StarNo == starNo) == null) { Trace.WriteLine(string.Format("Cannot locate always include star {0}. Removing ...", starNo)); alwaysIncludeStars.Remove(starNo); } } } double minDE = double.MaxValue; double maxDE = double.MinValue; double minRA = double.MaxValue; double maxRA = double.MinValue; for (int i = 0; i < m_Stars.Count; i++) { IStar star = m_Stars[i]; if (star.RADeg > maxRA) { maxRA = star.RADeg; } if (star.RADeg < minRA) { minRA = star.RADeg; } if (star.DEDeg > maxDE) { maxDE = star.DEDeg; } if (star.DEDeg < minDE) { minDE = star.DEDeg; } } TangentalTransRotAstrometry astrometryBase = new TangentalTransRotAstrometry(m_Image, m_RA0Deg, m_DE0Deg, 0); TangentalNormalizedDirectionAstrometry astrometry = new TangentalNormalizedDirectionAstrometry(astrometryBase); DensityArea middleArea = new DensityArea(astrometry, MAX_STARS_IN_AREA, m_RA0Deg - m_XAreaSideDeg / 2, m_RA0Deg + m_XAreaSideDeg / 2, m_DE0Deg - m_YAreaSideDeg / 2, m_DE0Deg + m_YAreaSideDeg / 2); middleArea.DebugResolvedStarsWithAppliedExclusions = DebugResolvedStarsWithAppliedExclusions; double xSidePlatePix = Math.Abs(middleArea.XTo - middleArea.XFrom); double ySidePlatePix = Math.Abs(middleArea.YTo - middleArea.YFrom); double raInterval = astrometryBase.GetDistanceInArcSec(middleArea.XFrom, middleArea.YMiddle, middleArea.XTo, middleArea.YMiddle) / 3600.0; double deInterval = astrometryBase.GetDistanceInArcSec(middleArea.XMiddle, middleArea.YFrom, middleArea.XMiddle, middleArea.YTo) / 3600.0; List <DensityArea> areasToCheckFurther = new List <DensityArea>(); areasToCheckFurther.Add(middleArea); Areas.Add(middleArea); do { DensityArea[] areasToCheckNow = areasToCheckFurther.ToArray(); areasToCheckFurther.Clear(); foreach (DensityArea area in areasToCheckNow) { List <DensityArea> potentiallyNewAreas = GetSurroundingAreas(area, astrometry, xSidePlatePix, ySidePlatePix); foreach (DensityArea par in potentiallyNewAreas) { bool areadyAdded = Areas.Exists(a => a.ContainsPoint(par.XMiddle, par.YMiddle)); if (!areadyAdded) { if (par.RAFrom + raInterval < minRA || par.RATo - raInterval > maxRA || par.DEFrom + deInterval < minDE || par.DETo - deInterval > maxDE) { // Area not in the coordinates of interest } else { areasToCheckFurther.Add(par); Areas.Add(par); } } } } }while (areasToCheckFurther.Count > 0); m_Stars.Sort((s1, s2) => s1.Mag.CompareTo(s2.Mag)); var aiss = (alwaysIncludeStars != null && alwaysIncludeStars.Count > 0) ? m_Stars.Where(s => alwaysIncludeStars.Contains(s.StarNo)).ToArray() : new IStar[0]; Areas.ForEach(a => { foreach (var star in m_Stars) { a.CheckAndAddStar(star); if (a.IncludedStarNos.Count >= MAX_STARS_IN_AREA) { break; } } foreach (var ais in aiss) { if (a.CheckAndAddStar(ais)) { if (!a.IncludedStarNos.Contains(ais.StarNo)) { a.IncludedStarNos.Add(ais.StarNo); } } } }); }
public void Initialize(List<ulong> alwaysIncludeStars) { if (DebugResolvedStarsWithAppliedExclusions != null) { List<ulong> debugStarIds = DebugResolvedStarsWithAppliedExclusions.Values.ToList(); List<IStar> missingstars = m_Stars.Where(s => !debugStarIds.Contains(s.StarNo)).ToList(); Trace.Assert(missingstars.Count == 0, string.Format("There are {0} of the debug stars not found among the initial pyramid stars", missingstars.Count)); } double minDE = double.MaxValue; double maxDE = double.MinValue; double minRA = double.MaxValue; double maxRA = double.MinValue; double averageRA = 0; double averageDE = 0; for (int i = 0; i < m_Stars.Count; i++) { IStar star = m_Stars[i]; if (star.RADeg > maxRA) maxRA = star.RADeg; if (star.RADeg < minRA) minRA = star.RADeg; if (star.DEDeg > maxDE) maxDE = star.DEDeg; if (star.DEDeg < minDE) minDE = star.DEDeg; averageDE += star.DEDeg; averageRA += star.RADeg; } averageDE /= m_Stars.Count; averageRA /= m_Stars.Count; m_RA0Deg = averageRA; m_DE0Deg = averageDE; TangentalTransRotAstrometry astrometryBase = new TangentalTransRotAstrometry(m_Image, averageRA, averageDE, 0); TangentalNormalizedDirectionAstrometry astrometry = new TangentalNormalizedDirectionAstrometry(astrometryBase); DensityArea middleArea = new DensityArea(astrometry, MAX_STARS_IN_AREA, averageRA - m_XAreaSideDeg / 2, averageRA + m_XAreaSideDeg / 2, averageDE - m_YAreaSideDeg / 2, averageDE + m_YAreaSideDeg / 2, alwaysIncludeStars); middleArea.DebugResolvedStarsWithAppliedExclusions = DebugResolvedStarsWithAppliedExclusions; double xSidePlatePix = Math.Abs(middleArea.XTo - middleArea.XFrom); double ySidePlatePix = Math.Abs(middleArea.YTo - middleArea.YFrom); double raInterval = astrometryBase.GetDistanceInArcSec(middleArea.XFrom, middleArea.YMiddle, middleArea.XTo, middleArea.YMiddle) / 3600.0; double deInterval = astrometryBase.GetDistanceInArcSec(middleArea.XMiddle, middleArea.YFrom, middleArea.XMiddle, middleArea.YTo) / 3600.0; List<DensityArea> areasToCheckFurther = new List<DensityArea>(); areasToCheckFurther.Add(middleArea); Areas.Add(middleArea); do { DensityArea[] areasToCheckNow = areasToCheckFurther.ToArray(); areasToCheckFurther.Clear(); foreach (DensityArea area in areasToCheckNow) { List<DensityArea> potentiallyNewAreas = GetSurroundingAreas(area, astrometry, xSidePlatePix, ySidePlatePix, alwaysIncludeStars); foreach(DensityArea par in potentiallyNewAreas) { bool areadyAdded = Areas.Exists(a => a.ContainsPoint(par.XMiddle, par.YMiddle)); if (!areadyAdded) { if (par.RAFrom + raInterval < minRA || par.RATo - raInterval > maxRA || par.DEFrom + deInterval < minDE || par.DETo - deInterval > maxDE) { // Area not in the coordinates of interest } else { areasToCheckFurther.Add(par); Areas.Add(par); } } } } } while (areasToCheckFurther.Count > 0); m_Stars.Sort((s1, s2) => s1.Mag.CompareTo(s2.Mag)); int maxStars = MAX_STARS_IN_AREA + (alwaysIncludeStars != null ? alwaysIncludeStars.Count : 0); Areas.ForEach(a => { foreach (var star in m_Stars) { a.CheckAndAddStar(star); if (a.IncludedStarNos.Count >= maxStars) break; } }); }