private ICollection <AstroEvent> FindLunarEclipses(AstroEventsContext context) { List <AstroEvent> events = new List <AstroEvent>(); int ln = LunarEphem.Lunation(context.From, LunationSystem.Meeus); do { LunarEclipse eclipse = LunarEclipses.NearestEclipse(ln, next: true); double jd = eclipse.JulianDayMaximum; if (jd <= context.To) { double jdMax = jd; string type = Text.Get($"LunarEclipse.Type.{eclipse.EclipseType}"); string phase = Formatters.Phase.Format(eclipse.Magnitude); var elements = GetLunarEclipseElements(jdMax); var local = LunarEclipses.LocalCircumstances(eclipse, elements, context.GeoLocation); string localVisibility = GetLocalVisibilityString(eclipse, local); events.Add(new AstroEvent(jdMax, Text.Get("LunarEclipse.Event", ("type", type), ("phase", phase), ("localVisibility", localVisibility)), moon)); ln = eclipse.MeeusLunationNumber + 1; } else { break; } }while (true); return(events); }
public void FindNearestLunarEclipse() { // ex. 54c { double jd = new Date(1973, 6, 1).ToJulianDay(); LunarEclipse eclipse = LunarEclipses.NearestEclipse(jd, true); var d = new Date(eclipse.JulianDayMaximum, 0); Assert.AreEqual(1973, d.Year); Assert.AreEqual(6, d.Month); Assert.AreEqual(15, (int)d.Day); Assert.AreEqual(20, d.Hour); Assert.AreEqual(50, d.Minute); Assert.AreEqual(LunarEclipseType.Penumbral, eclipse.EclipseType); Assert.AreEqual(0.462, eclipse.Magnitude, 1e-3); } // ex. 54d { double jd = new Date(1997, 7, 1).ToJulianDay(); int ln = LunarEphem.Lunation(jd, LunationSystem.Meeus); LunarEclipse eclipse = LunarEclipses.NearestEclipse(ln, true); var d = new Date(eclipse.JulianDayMaximum, 0); Assert.AreEqual(1997, d.Year); Assert.AreEqual(9, d.Month); Assert.AreEqual(16, (int)d.Day); Assert.AreEqual(18, d.Hour); Assert.AreEqual(47, d.Minute); Assert.AreEqual(LunarEclipseType.Total, eclipse.EclipseType); Assert.AreEqual(1.187, eclipse.Magnitude, 1e-3); } }
/// <inheritdoc /> public LunarEclipse GetNearestLunarEclipse(int ln, bool next, bool saros) { return(LunarEclipses.NearestEclipse(ln + (next ? 1 : -1) * (saros ? 223 : 1), next)); }