public void EquatorialToHorizontal() { // Apparent equatorial coordinates of Venus var eq = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''")); // Geographical coordinates of US Naval Observatory at Washington, DC var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''")); // Date of observation var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay(); // Mean sidereal time at Greenwich var theta0 = Date.MeanSiderealTime(jd); Assert.AreEqual(new HMS("8h 34m 57.0896s"), new HMS(theta0)); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Apparent sidereal time at Greenwich theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0)); // Expected local horizontal coordinates of Venus var hor = eq.ToHorizontal(geo, theta0); Assert.AreEqual(15.1249, hor.Altitude, 1e-4); Assert.AreEqual(68.0336, hor.Azimuth, 1e-4); }
/// <inheritdoc/> public ICollection <CrdsGeographical> Search(CrdsGeographical center, float radius) { if (isLoaded) { lock (locker) { return(allLocations.Where(c => c.DistanceTo(center) <= radius).Select(c => { return new CrdsGeographical() { CountryCode = c.Country, Elevation = c.Elevation, Latitude = c.Latitude, Longitude = c.Longitude, LocationName = c.Names.FirstOrDefault(), TimeZoneId = c.TimeZone?.TimeZoneId, UtcOffset = c.TimeZone?.UtcOffset ?? 0 }; }).ToArray()); } } else { return(new CrdsGeographical[0]); } }
public void HorizontalToEquatorial() { // Apparent local horizontal coordinates of Venus var hor = new CrdsHorizontal(68.0337, 15.1249); // Geographical coordinates of US Naval Observatory at Washington, DC var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''")); // Date of observation var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay(); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Apparent sidereal time at Greenwich var theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0)); // Expected apparent equatorial coordinates of Venus var eqExpected = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''")); // Tested value var eqActual = hor.ToEquatorial(geo, theta0); Assert.AreEqual(eqExpected.Alpha, eqActual.Alpha, errorInHMS); Assert.AreEqual(eqExpected.Delta, eqActual.Delta, errorInDMS); }
public ContactsTableItem(string text, double jd, CrdsGeographical g = null) { Point = text; Coordinates = g != null?Format.Geo.Format(g) : null; Time = $"{Format.Time.Format(new Date(jd, 0))} {(!double.IsNaN(jd) ? "UTC" : "")}"; }
/// <inheritdoc/> public void SetLocation(CrdsGeographical geo) { try { lock (locker) { if (telescope != null) { telescope.SiteLongitude = geo.Longitude; telescope.SiteLatitude = geo.Latitude; telescope.SiteElevation = geo.Elevation; } } } catch (Exception ex) { RaiseOnMessageShow("$Ascom.Messages.UnableSetLocation"); Log.Error($"Unable to set telescope observation place: {ex}"); } }
public void ToTopocentric() { // Geocentric coordinates of Mars CrdsEquatorial eq = new CrdsEquatorial(339.530208, -15.771083); // Palomar Observatory coordinates, see example 11.a CrdsGeographical geo = new CrdsGeographical(new HMS("7h 47m 27s").ToDecimalAngle(), new DMS("+33* 21' 22''").ToDecimalAngle(), 1706); // Equatoria horizontal parallax double pi = 23.592 / 3600; // Apparent sidereal time at Greenwich double theta0 = new HMS("1h 40m 45s").ToDecimalAngle(); // Equatorial topocentric coordinates of Mars CrdsEquatorial topo = eq.ToTopocentric(geo, theta0, pi); Assert.AreEqual(new HMS("22h 38m 08.54s").ToDecimalAngle(), topo.Alpha, errorInHMS); Assert.AreEqual(new DMS("-15* 46' 30.04''").ToDecimalAngle(), topo.Delta, errorInDMS); }
public void RiseTransitSet() { // Venus at Boston, 20 March 1988 { CrdsEquatorial[] eq = new CrdsEquatorial[] { new CrdsEquatorial(new HMS("02h 46m 25.086s"), new DMS("+18° 23' 36.14''")), new CrdsEquatorial(new HMS("02h 48m 31.193s"), new DMS("+18° 35' 16.41''")), new CrdsEquatorial(new HMS("02h 50m 37.273s"), new DMS("+18° 46' 50.47''")) }; CrdsGeographical location = new CrdsGeographical(71.0833, 42.3333); var rts = Visibility.RiseTransitSet(eq, location, 177.74208, 0, 0); // 2 minute error const double error = 2.0 / (24 * 60); Assert.AreEqual(new TimeSpan(12, 27, 0).TotalDays, rts.Rise, error); Assert.AreEqual(new TimeSpan(19, 39, 0).TotalDays, rts.Transit, error); Assert.AreEqual(new TimeSpan(02, 50, 0).TotalDays, rts.Set, error); } // Antares at Boston, 20 March 1988 { var eq = new CrdsEquatorial(new HMS("16h 28m 41s"), new DMS("-26° 24' 30''")); CrdsGeographical location = new CrdsGeographical(71.0833, 42.3333); var rts = Visibility.RiseTransitSet(eq, location, 177.74208); // 2 minute error const double error = 2.0 / (24 * 60); Assert.AreEqual(new TimeSpan(05, 07, 0).TotalDays, rts.Rise, error); Assert.AreEqual(new TimeSpan(09, 19, 0).TotalDays, rts.Transit, error); Assert.AreEqual(new TimeSpan(13, 31, 0).TotalDays, rts.Set, error); } }
public void ProjectionTests() { { double d = 15.32558; double mu = 345.88554; CrdsGeographical g = new CrdsGeographical(-26.71875, 44.66865); Vector v = SolarEclipses.ProjectOnFundamentalPlane(g, d, mu); CrdsGeographical g0 = SolarEclipses.ProjectOnEarth(new System.Drawing.PointF((float)v.X, (float)v.Y), d, mu); Assert.AreEqual(g.Latitude, g0.Latitude, 1e-5); Assert.AreEqual(g.Longitude, g0.Longitude, 1e-5); } { double d = -23.25608; double mu = 48.57292; CrdsGeographical g = new CrdsGeographical(97.20703, -28.22697); Vector v = SolarEclipses.ProjectOnFundamentalPlane(g, d, mu); CrdsGeographical g0 = SolarEclipses.ProjectOnEarth(new System.Drawing.PointF((float)v.X, (float)v.Y), d, mu); Assert.AreEqual(g.Latitude, g0.Latitude, 1e-5); Assert.AreEqual(g.Longitude, g0.Longitude, 1e-5); } }
/// <summary> /// Creates new instance of <see cref="LocationVM"/> /// </summary> public LocationVM(ISky sky, ISettings settings) { CrdsEquatorial eqSun = SolarEphem.Ecliptical(sky.Context.JulianDay).ToEquatorial(sky.Context.Epsilon); ObserverLocation = new CrdsGeographical(sky.Context.GeoLocation); SunHourAngle = Coordinates.HourAngle(sky.Context.SiderealTime, 0, eqSun.Alpha); SunDeclination = eqSun.Delta; IsNightMode = settings.Get <ColorSchema>("Schema") == ColorSchema.Red; OkCommand = new Command(Ok); CancelCommand = new Command(Close); EndSearchModeCommand = new Command(EndSearchMode); SelectLocationCommand = new Command(SelectLocation); string line; string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "TimeZones.dat"); using (StreamReader file = new StreamReader(filePath)) { while ((line = file.ReadLine()) != null) { // skip first and empty lines if (line.StartsWith("CountryCode") || string.IsNullOrWhiteSpace(line)) { continue; } string[] chunks = line.Split('\t'); TimeZones.Add(new TimeZoneItem() { TimeZoneId = chunks[1], UtcOffset = double.Parse(chunks[4], CultureInfo.InvariantCulture) }); } file.Close(); } }
public void Separation() { // Example 17.a, AA(II) { var c1 = new CrdsEquatorial(213.9154, 19.1825); var c2 = new CrdsEquatorial(201.2983, -11.1614); Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4); } { var c1 = new CrdsEcliptical(213.9154, 19.1825); var c2 = new CrdsEcliptical(201.2983, -11.1614); Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4); } { var c1 = new CrdsGeographical(213.9154, 19.1825); var c2 = new CrdsGeographical(201.2983, -11.1614); Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4); } { var c1 = new CrdsHorizontal(213.9154, 19.1825); var c2 = new CrdsHorizontal(201.2983, -11.1614); Assert.AreEqual(32.7930, Angle.Separation(c1, c2), 1e-4); } }
public SkyContext(double jd, CrdsGeographical location, bool preferFast) { PreferFastCalculation = preferFast; GeoLocation = location; JulianDay = jd; }
public double DistanceTo(CrdsGeographical g) { return(g.DistanceTo(new CrdsGeographical(Longitude, Latitude))); }
public SkyContext(double jd, CrdsGeographical location) : this(jd, location, false) { }
public void SetLocation(CrdsGeographical geo) { }
public async Task SetDate(Date date, CrdsGeographical geoLocation) { await Task.Run(() => { double jd0 = date.ToJulianEphemerisDay(); daysInMonth = Date.DaysInMonth(date.Year, date.Month); var eL = new PointF[5]; var eB = new PointF[5]; var eR = new PointF[5]; var jL = new PointF[5]; var jB = new PointF[5]; var jR = new PointF[5]; var earth = new CrdsHeliocentrical[5]; var jupiter = new CrdsHeliocentrical[5]; // calculate heliocentrical positions of Earth and Jupiter for 5 instants // and find least squares approximation model of planets position // to quick calculation of Galilean moons postions. for (int i = 0; i < 5; i++) { double jd = jd0 + (i / 4.0) * daysInMonth; earth[i] = PlanetPositions.GetPlanetCoordinates(3, jd); jupiter[i] = PlanetPositions.GetPlanetCoordinates(5, jd); } double[] earthL = earth.Select(x => x.L).ToArray(); double[] earthB = earth.Select(x => x.B).ToArray(); double[] earthR = earth.Select(x => x.R).ToArray(); double[] jupiterL = jupiter.Select(x => x.L).ToArray(); double[] jupiterB = jupiter.Select(x => x.B).ToArray(); double[] jupiterR = jupiter.Select(x => x.R).ToArray(); // it's important to align longitudes (avoid 0 degrees crossing) // before applying least squares method earthL = Angle.Align(earthL); jupiterL = Angle.Align(jupiterL); for (int i = 0; i < 5; i++) { eL[i] = new PointF(i, (float)earthL[i]); eB[i] = new PointF(i, (float)earthB[i]); eR[i] = new PointF(i, (float)earthR[i]); jL[i] = new PointF(i, (float)jupiterL[i]); jB[i] = new PointF(i, (float)jupiterB[i]); jR[i] = new PointF(i, (float)jupiterR[i]); } Begin = jd0; End = jd0 + daysInMonth; GeoLocation = geoLocation; this.eL = LeastSquares.FindCoeffs(eL, 3); this.eB = LeastSquares.FindCoeffs(eB, 3); this.eR = LeastSquares.FindCoeffs(eR, 3); this.jL = LeastSquares.FindCoeffs(jL, 3); this.jB = LeastSquares.FindCoeffs(jB, 3); this.jR = LeastSquares.FindCoeffs(jR, 3); }); }
/// <summary> /// Selects a location from the search results and ends the search mode /// </summary> private void SelectLocation() { _SavedLocation = new CrdsGeographical(ObserverLocation); EndSearchMode(); }
private void DoTest(CrdsGeographical location, OrbitalElements oe, string testData, double errorR, double errorEq) { Regex regex = new Regex("^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+ \\S+ \\S+) (\\S+ \\S+ \\S+)$"); string[] lines = testData.Split('\n'); foreach (string line in lines) { string dataLine = line.Trim(); if (!string.IsNullOrEmpty(dataLine)) { var match = regex.Match(dataLine); double jd = double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture); double X = double.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); double Y = double.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture); double Z = double.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture); string ra = match.Groups[5].Value; string dec = match.Groups[6].Value; var eqTest = new CrdsEquatorial(new HMS(ra), new DMS(dec)); var nutation = Nutation.NutationElements(jd); var aberration = Aberration.AberrationElements(jd); // True obliquity double epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // final difference to stop iteration process, 1 second of time double deltaTau = TimeSpan.FromSeconds(1).TotalDays; // time taken by the light to reach the Earth double tau = 0; // previous value of tau to calculate the difference double tau0 = 1; // Rectangular coordinates of minor body CrdsRectangular r = null; // Rectangular coordinates of the Sun var sun = SunRectangular(jd, epsilon); // Distance to the Earth double Delta = 0; // Iterative process to find rectangular coordinates of minor body while (Math.Abs(tau - tau0) > deltaTau) { // Rectangular coordinates of minor body r = MinorBodyPositions.GetRectangularCoordinates(oe, jd - tau, epsilon); double ksi = sun.X + r.X; double eta = sun.Y + r.Y; double zeta = sun.Z + r.Z; // Distance to the Earth Delta = Math.Sqrt(ksi * ksi + eta * eta + zeta * zeta); tau0 = tau; tau = PlanetPositions.LightTimeEffect(Delta); } // Test heliocentric rectangular coordinates Assert.AreEqual(X, r.X, errorR); Assert.AreEqual(Y, r.Y, errorR); Assert.AreEqual(Z, r.Z, errorR); double x = sun.X + r.X; double y = sun.Y + r.Y; double z = sun.Z + r.Z; double alpha = Angle.ToDegrees(Math.Atan2(y, x)); double delta = Angle.ToDegrees(Math.Asin(z / Delta)); var eq0 = new CrdsEquatorial(alpha, delta); var theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); var parallax = PlanetEphem.Parallax(Delta); var eq = eq0.ToTopocentric(location, theta0, parallax); // Test equatorial coordinates Assert.AreEqual(eqTest.Alpha, eq.Alpha, errorEq / 3600.0); Assert.AreEqual(eqTest.Delta, eq.Delta, errorEq / 3600.0); } } }
public void Noumenia() { // Example are taken from // http://www.makkahcalendar.org/en/islamicCalendarArticle4.php // IX.4 Example of Makkah { // 17 Nov 2009, "best time" is 14:48 UTC double jd = new Date(new DateTime(2009, 11, 17, 14, 48, 0, DateTimeKind.Utc)).ToJulianEphemerisDay(); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Sidereal time at Greenwich double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); // Ecliptical coordinates of the Sun, taken from the example (see ref.) CrdsEcliptical eclSun = new CrdsEcliptical(235.39, 0); // Ecliptical coordinates of the Moon, taken from the example (see ref.) CrdsEcliptical eclMoon = new CrdsEcliptical(245.01, -3.76); // Geograhical coordinates of Makkah CrdsGeographical geo = new CrdsGeographical(-39.82563, 21.42664); double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2539 * 3600, epsilon, siderealTime, geo); Assert.AreEqual(-0.465, q, 0.001); } // IX.5 Example of intermediate horizon 30°W, 30°S at 21:04 { // 17 Nov 2009, 21:04 UTC double jd = new Date(new DateTime(2009, 11, 17, 21, 04, 0, DateTimeKind.Utc)).ToJulianEphemerisDay(); // Nutation elements var nutation = Nutation.NutationElements(jd); // True obliquity var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon); // Sidereal time at Greenwich double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon); // Ecliptical coordinates of the Sun, taken from the example (see ref.) CrdsEcliptical eclSun = new CrdsEcliptical(235.65, 0); // Ecliptical coordinates of the Moon, taken from the example (see ref.) CrdsEcliptical eclMoon = new CrdsEcliptical(248.32, -3.55); // Geograhical coordinates of Makkah CrdsGeographical geo = new CrdsGeographical(30, -30); double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2536 * 3600, epsilon, siderealTime, geo); Assert.AreEqual(0.367, q, 0.001); } }
/// <summary> /// Creates new point with Julian Day value and coordinates /// </summary> /// <param name="jd">Julian Day value</param> /// <param name="c">Coordinates of the point</param> public SolarEclipseMapPoint(double jd, CrdsGeographical c) : base(c) { JulianDay = jd; }