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 LunarEclipse() { //Deserialize using (StreamReader streamReader = new StreamReader("CelestialData\\LunarEclipse.txt")) { BinaryFormatter binaryFormatter = new BinaryFormatter(); LunarEclipse ev = (LunarEclipse)binaryFormatter.Deserialize(streamReader.BaseStream); LunarEclipseDetails lE1 = ev.LastEclipse; LunarEclipseDetails nE1 = ev.NextEclipse; LunarEclipseDetails lE2 = data.LunarEclispe.LastEclipse; LunarEclipseDetails nE2 = data.LunarEclispe.NextEclipse; PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties(); foreach (PropertyInfo property in properties) { var l1 = property.GetValue(lE1); var l2 = property.GetValue(lE2); var n1 = property.GetValue(nE1); var n2 = property.GetValue(nE2); Assert.AreEqual(l1.ToString(), l2.ToString(), "Last Eclipse data does not match."); Assert.AreEqual(n1.ToString(), n2.ToString(), "Next Eclipse data does not match."); } } }
public string GetLocalVisibilityString(LunarEclipse eclipse, LunarEclipseLocalCircumstances localCirc) { if (localCirc.Maximum.LunarAltitude > 0) { return(Text.Get("LunarEclipse.LocalVisibility.Visible")); // "visible" } string localVisibility = Text.Get("LunarEclipse.LocalVisibility.Invisible"); // "invisible" if (localCirc.PenumbralBegin.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleBeginPenumbral"); // "visible begin of penumbral phase" } if (localCirc.PartialBegin?.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleBeginPartial"); // "visible begin of partial phase" } if (localCirc.TotalBegin?.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleBeginTotal"); // "visible begin of total phase" } if (localCirc.PenumbralEnd.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleEndPenumbral"); // "visible end of penumbral phase" } if (localCirc.PartialEnd?.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleEndPartial"); // "visible end of partial phase" } if (localCirc.TotalEnd?.LunarAltitude > 0) { localVisibility = Text.Get("LunarEclipse.LocalVisibility.VisibleEndTotal"); // "visible end of total phase" } return(localVisibility); }
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); } }
private static void eclipseTest2() { int year = 1907; DateTimeOffset start = new DateTimeOffset(year, 1, 1, 0, 0, 0, TimeSpan.Zero); DateTimeOffset end = new DateTimeOffset(year, 1, 31, 0, 0, 0, TimeSpan.Zero); List <IPlanetEvent> events = Ephemeris.Geocentric[start, end, PlanetEventFlag.EclipseOccultationCategory]; SolarEclipse eclipse = events[1] as SolarEclipse; Console.WriteLine("{0} happened on {1}, Sun @ {2}", eclipse.ShortDescription, eclipse.When, eclipse.Where); Position venusPos = Ephemeris.Geocentric[eclipse.When, PlanetId.SE_VENUS]; List <IPlanetEvent> transcents = Ephemeris.Geocentric.TranscensionEventOf(PlanetId.SE_VENUS, venusPos.Longitude, eclipse.When.AddDays(1), start.AddYears(1)); Console.WriteLine("Venus @ {0}, and transcension afterwards are:\r\n", venusPos.Longitude); foreach (IPlanetEvent evt in transcents) { Console.WriteLine(evt.ToString()); } transcents = Ephemeris.Geocentric.TranscensionEventOf(PlanetId.SE_VENUS, eclipse.Where.Longitude, eclipse.When.AddDays(1), start.AddYears(1)); Console.WriteLine("Venus transcend Sun position of {0} are:\r\n", eclipse.Where.Longitude); foreach (IPlanetEvent evt in transcents) { Console.WriteLine(evt.ToString()); } LunarEclipse lun = events[3] as LunarEclipse; Console.WriteLine("{0} happened on {1}, Sun @ {2}", lun.ShortDescription, lun.When, lun.Where); venusPos = Ephemeris.Geocentric[lun.When, PlanetId.SE_VENUS]; transcents = Ephemeris.Geocentric.TranscensionEventOf(PlanetId.SE_VENUS, lun.Where.Longitude, eclipse.When.AddDays(1), start.AddYears(1)); foreach (IPlanetEvent evt in transcents) { Console.WriteLine(evt.ToString()); } Console.ReadKey(); }
public bool Check_Lunar_Eclipse() { IFormatter formatter = new BinaryFormatter(); //Deserialize using (StreamReader streamReader = new StreamReader("CelestialData\\LunarEclipse.txt")) { BinaryFormatter binaryFormatter = new BinaryFormatter(); LunarEclipse ev = (LunarEclipse)binaryFormatter.Deserialize(streamReader.BaseStream); LunarEclipseDetails lE1 = ev.LastEclipse; LunarEclipseDetails nE1 = ev.NextEclipse; LunarEclipseDetails lE2 = this.LunarEclispe.LastEclipse; LunarEclipseDetails nE2 = this.LunarEclispe.NextEclipse; PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties(); foreach (PropertyInfo property in properties) { var l1 = property.GetValue(lE1); var l2 = property.GetValue(lE2); var n1 = property.GetValue(nE1); var n2 = property.GetValue(nE2); if (l1.ToString() != l2.ToString()) { return(false); } if (n1.ToString() != n2.ToString()) { return(false); } } } return(true); }
/// <inheritdoc/> public ICollection <LunarEclipseLocalCircumstances> FindLocalCircumstancesForCities(LunarEclipse e, PolynomialLunarEclipseElements be, ICollection <CrdsGeographical> cities, CancellationToken?cancelToken = null, IProgress <double> progress = null) { return(cities .Distinct() .Select(c => LunarEclipses.LocalCircumstances(e, be, c)) .ToArray()); }
private void buttonLunarEclipse_Click(object sender, EventArgs e) { LunarEclipse lunEclipse = Utilities.LunarEclipseAround(start, isBackward); MessageBox.Show(lunEclipse.ToString()); }