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); }
private ICollection <AstroEvent> FindSolarEclipses(AstroEventsContext context) { List <AstroEvent> events = new List <AstroEvent>(); int ln = LunarEphem.Lunation(context.From, LunationSystem.Meeus); do { SolarEclipse eclipse = GetNearestSolarEclipse(ln, next: true, saros: false); double jd = eclipse.JulianDayMaximum; if (jd <= context.To) { var pbe = GetBesselianElements(jd); var localCirc = SolarEclipses.LocalCircumstances(pbe, context.GeoLocation); string type = Text.Get($"SolarEclipse.Type.{eclipse.EclipseType}"); string subtype = eclipse.IsNonCentral ? $" {Text.Get("SolarEclipse.Type.NoCentral")}" : ""; string phase = eclipse.EclipseType == SolarEclipseType.Partial ? $" ({Text.Get("SolarEclipse.MaxPhase")} {Formatters.Phase.Format(eclipse.Magnitude)})" : ""; double jdMax = localCirc.MaxMagnitude > 0 ? localCirc.Maximum.JulianDay : jd; string localVisibility = GetLocalVisibilityString(eclipse, localCirc); events.Add(new AstroEvent(jdMax, Text.Get("SolarEclipse.Event", ("type", type), ("subtype", subtype), ("phase", phase), ("localVisibility", localVisibility)), sun, 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); } }
public void LunationNumber() { Assert.AreEqual(1217, LunarEphem.Lunation(new Date(2021, 5, 11).ToJulianEphemerisDay())); Assert.AreEqual(-282, LunarEphem.Lunation(new Date(1900, 2, 17).ToJulianEphemerisDay())); }
/// <summary> /// Calculates nearest solar eclipse (next or previous) for the provided lunation number. /// </summary> /// <param name="lunationNumber">Meeus lunation number of interest.</param> /// <param name="next">Flag indicating searching direction. True means searching next eclipse, false means previous.</param> /// <summary> /// Calculates nearest lunar eclipse (next or previous) for the provided Julian Day. /// </summary> /// <param name="jd">Julian day of interest, the nearest lunar eclipse for that date will be found.</param> /// <param name="next">Flag indicating searching direction. True means searching next eclipse, false means previous.</param> public static LunarEclipse NearestEclipse(double jd, bool next) { int lunationNumber = LunarEphem.Lunation(jd, LunationSystem.Meeus); return(NearestEclipse(lunationNumber, next)); }
/// <summary> /// Gets Brown lunation number /// </summary> private int Lunation(SkyContext c) { double age = c.Get(Age); return(LunarEphem.Lunation(c.JulianDay - age)); }