public double MoonPhase(double JD) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output1 = new SkyPos(); SkyPos Output2 = new SkyPos(); Observer Location = new Observer(); double DeltaT = DeltatCode.DeltaTCalc(JD); CelObject.Name = "Moon"; CelObject.Number = Body.Moon; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2); CelObject.Name = "Sun"; CelObject.Number = Body.Sun; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; int num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1); return(Range((Output2.RA - Output1.RA) * 15.0, -180.0, false, 180.0, true)); }
public double DeltaUT(double JulianDate) { double num = (double)UtcTaiOffset + 4023.0 / 125.0 - DeltatCode.DeltaTCalc(JulianDate); TL.LogMessage("DeltaUT", "Returning: " + Conversions.ToString(num) + " at Julian date: " + Conversions.ToString(JulianDate)); return(num); }
public double MoonIllumination(double JD) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output1 = new SkyPos(); SkyPos Output2 = new SkyPos(); Observer Location = new Observer(); double DeltaT = DeltatCode.DeltaTCalc(JD); CelObject.Name = "Moon"; CelObject.Number = Body.Moon; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output2); CelObject.Name = "Sun"; CelObject.Number = Body.Sun; CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; int num2 = (int)Nov31.Place(JD + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output1); double num3 = Math.Acos(Math.Sin(Output1.Dec * (Math.PI / 180.0)) * Math.Sin(Output2.Dec * (Math.PI / 180.0)) + Math.Cos(Output1.Dec * (Math.PI / 180.0)) * Math.Cos(Output2.Dec * (Math.PI / 180.0)) * Math.Cos((Output1.RA - Output2.RA) * 15.0 * (Math.PI / 180.0))); return((1.0 + Math.Cos(Math.Atan2(Output1.Dis * Math.Sin(num3), Output2.Dis - Output1.Dis * Math.Cos(num3)))) / 2.0); }
public double DeltaT() { double julianDate = Utl.JulianDate; double num = DeltatCode.DeltaTCalc(julianDate); TL.LogMessage("DeltaT", "Returned: " + Conversions.ToString(num) + " at Julian date: " + Conversions.ToString(julianDate)); return(num); }
private void J2000ToTopo() { double DeltaT; double DUT1 = 0; double JDUTCSofa = 0; double aob = 0; double zob = 0; double hob = 0; double dob = 0; double rob = 0; double eo = 0; DateTime JDUTCSofaDateTime; if (double.IsNaN(SiteElevValue)) { throw (new Exceptions.TransformUninitialisedException("Site elevation has not been set")); } if (double.IsNaN(SiteLatValue)) { throw (new Exceptions.TransformUninitialisedException("Site latitude has not been set")); } if (double.IsNaN(SiteLongValue)) { throw (new Exceptions.TransformUninitialisedException("Site longitude has not been set")); } if (double.IsNaN(SiteTempValue)) { throw (new Exceptions.TransformUninitialisedException("Site temperature has not been set")); } JDUTCSofa = GetJDUTCSofa(); DeltaT = System.Convert.ToDouble(DeltatCode.DeltaTCalc(JDUTCSofa)); DUT1 = System.Convert.ToDouble(DeltaUT(JDUTCSofa)); JDUTCSofaDateTime = Julian2DateTime(JDUTCSofa); if (RefracValue) // Include refraction { SOFA.CelestialToObserved(RAJ2000Value * HOURS2RADIANS, DECJ2000Value * DEGREES2RADIANS, 0.0, 0.0, 0.0, 0.0, JDUTCSofa, 0.0, DUT1, SiteLongValue * DEGREES2RADIANS, SiteLatValue * DEGREES2RADIANS, SiteElevValue, 0.0, 0.0, 1000.0, SiteTempValue, 0.8, 0.57, ref aob, ref zob, ref hob, ref dob, ref rob, ref eo); } else // No refraction { SOFA.CelestialToObserved(RAJ2000Value * HOURS2RADIANS, DECJ2000Value * DEGREES2RADIANS, 0.0, 0.0, 0.0, 0.0, JDUTCSofa, 0.0, DUT1, SiteLongValue * DEGREES2RADIANS, SiteLatValue * DEGREES2RADIANS, SiteElevValue, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ref aob, ref zob, ref hob, ref dob, ref rob, ref eo); } RATopoValue = System.Convert.ToDouble(SOFA.Anp(rob - eo) * RADIANS2HOURS); // // Convert CIO RA to equinox of date RA by subtracting the equation of the origins and convert from radians to hours DECTopoValue = dob * RADIANS2DEGREES; // Convert Dec from radians to degrees AzimuthTopoValue = aob * RADIANS2DEGREES; ElevationTopoValue = System.Convert.ToDouble(90.0 - zob * RADIANS2DEGREES); }
private void J2000ToTopo() { if (double.IsNaN(this.SiteElevValue)) { throw new TransformUninitialisedException("Site elevation has not been set"); } if (double.IsNaN(this.SiteLatValue)) { throw new TransformUninitialisedException("Site latitude has not been set"); } if (double.IsNaN(this.SiteLongValue)) { throw new TransformUninitialisedException("Site longitude has not been set"); } if (double.IsNaN(this.SiteTempValue)) { throw new TransformUninitialisedException("Site temperature has not been set"); } this.Sw.Reset(); this.Sw.Start(); double jdutcSofa = this.GetJDUTCSofa(); DeltatCode.DeltaTCalc(jdutcSofa); double dut1 = this.AstroUtl.DeltaUT(jdutcSofa); this.Julian2DateTime(jdutcSofa); this.Sw.Reset(); this.Sw.Start(); double aob = 0; double zob = 0; double hob = 0; double dob = 0; double rob = 0; double eo = 0; if (this.RefracValue) { this.SOFA.CelestialToObserved(this.RAJ2000Value * (Math.PI / 12.0), this.DECJ2000Value * (Math.PI / 180.0), 0.0, 0.0, 0.0, 0.0, jdutcSofa, 0.0, dut1, this.SiteLongValue * (Math.PI / 180.0), this.SiteLatValue * (Math.PI / 180.0), this.SiteElevValue, 0.0, 0.0, 1000.0, this.SiteTempValue, 0.8, 0.57, ref aob, ref zob, ref hob, ref dob, ref rob, ref eo); } else { this.SOFA.CelestialToObserved(this.RAJ2000Value * (Math.PI / 12.0), this.DECJ2000Value * (Math.PI / 180.0), 0.0, 0.0, 0.0, 0.0, jdutcSofa, 0.0, dut1, this.SiteLongValue * (Math.PI / 180.0), this.SiteLatValue * (Math.PI / 180.0), this.SiteElevValue, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ref aob, ref zob, ref hob, ref dob, ref rob, ref eo); } this.RATopoValue = this.SOFA.Anp(rob - eo) * (12.0 / Math.PI); this.DECTopoValue = dob * (180.0 / Math.PI); this.AzimuthTopoValue = aob * (180.0 / Math.PI); this.ElevationTopoValue = 90.0 - zob * (180.0 / Math.PI); this.TL.LogMessage(" J2000 To Topo", " Topocentric RA/DEC (including refraction if specified): " + this.FormatRA(this.RATopoValue) + " " + this.FormatDec(this.DECTopoValue) + " Refraction: " + this.RefracValue.ToString() + ", " + Strings.FormatNumber((object)this.Sw.Elapsed.TotalMilliseconds, 2, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "ms"); this.TL.LogMessage(" J2000 To Topo", " Azimuth/Elevation: " + this.FormatDec(this.AzimuthTopoValue) + " " + this.FormatDec(this.ElevationTopoValue) + ", " + Strings.FormatNumber((object)this.Sw.Elapsed.TotalMilliseconds, 2, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + "ms"); this.TL.LogMessage(" J2000 To Topo", " Completed"); this.TL.BlankLine(); }
public bool SetFromSiteJD(Site site, double ujd, double delta_t) { double tdb = delta_t == 0.0 ? ujd + DeltatCode.DeltaTCalc(ujd) : ujd + delta_t; double tdtjd = 0; double secdiff = 0; NOVAS2.Tdb2Tdt(tdb, ref tdtjd, ref secdiff); double mobl = 0; double tobl = 0; double eq = 0; double dpsi = 0; double deps = 0; NOVAS2.EarthTilt(tdb + secdiff / 86400.0, ref mobl, ref tobl, ref eq, ref dpsi, ref deps); double gst = 0; NOVAS2.SiderealTime(ujd, 0.0, eq, ref gst); this.SetFromSite(site, gst); return(true); }
public double JulianDateUT1(double DeltaUT1) { if (DeltaUT1 <-0.9 | DeltaUT1> 0.9) { throw new InvalidValueException("JulianDateUT1", DeltaUT1.ToString(), "-0.9 to +0.9"); } DateTime utcNow = DateTime.UtcNow; DateTime dateTime; if (DeltaUT1 != 0.0) { TimeSpan timeSpan = TimeSpan.FromSeconds(DeltaUT1); dateTime = utcNow.Add(timeSpan); } else { double num = DeltatCode.DeltaTCalc(Nov31.JulianDate(Convert.ToInt16(utcNow.Year), Convert.ToInt16(utcNow.Month), Convert.ToInt16(utcNow.Day), utcNow.TimeOfDay.TotalHours)); dateTime = utcNow.Add(TimeSpan.FromSeconds((double)UtcTaiOffset + 4023.0 / 125.0)).Subtract(TimeSpan.FromSeconds(num)); } double num1 = Nov31.JulianDate(Convert.ToInt16(dateTime.Year), Convert.ToInt16(dateTime.Month), Convert.ToInt16(dateTime.Day), dateTime.TimeOfDay.TotalHours); TL.LogMessage("JulianDateUT1", "Returning: " + Conversions.ToString(num1) + "at UT1: " + Strings.Format((object)dateTime, "dddd dd MMMM yyyy HH:mm:ss.fff") + ", at UTC: " + Strings.Format((object)utcNow, "dddd dd MMMM yyyy HH:mm:ss.fff")); return(num1); }
public double DeltaUT(double JulianDate) { double DUT1 = 0; DUT1 = System.Convert.ToDouble(GlobalItems.TAI_UTC_OFFSET + GlobalItems.TT_TAI_OFFSET - DeltatCode.DeltaTCalc(JulianDate)); return(DUT1); }
private ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo BodyAltitude(EventType TypeOfEvent, double JD, double Hour, double Latitude, double Longitude) { Object3 CelObject = new Object3(); OnSurface onSurface = new OnSurface(); CatEntry3 catEntry3 = new CatEntry3(); SkyPos Output = new SkyPos(); Observer Location = new Observer(); ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo bodyInfo = new ASCOM.Astrometry.AstroUtils.AstroUtils.BodyInfo(); double JdHigh = JD + Hour / 24.0; double DeltaT = DeltatCode.DeltaTCalc(JD); switch (TypeOfEvent) { case EventType.SunRiseSunset: case EventType.CivilTwilight: case EventType.NauticalTwilight: case EventType.AmateurAstronomicalTwilight: case EventType.AstronomicalTwilight: CelObject.Name = "Sun"; CelObject.Number = Body.Sun; break; case EventType.MoonRiseMoonSet: CelObject.Name = "Moon"; CelObject.Number = Body.Moon; break; case EventType.MercuryRiseSet: CelObject.Name = "Mercury"; CelObject.Number = Body.Mercury; break; case EventType.VenusRiseSet: CelObject.Name = "Venus"; CelObject.Number = Body.Venus; break; case EventType.MarsRiseSet: CelObject.Name = "Mars"; CelObject.Number = Body.Mars; break; case EventType.JupiterRiseSet: CelObject.Name = "Jupiter"; CelObject.Number = Body.Jupiter; break; case EventType.SaturnRiseSet: CelObject.Name = "Saturn"; CelObject.Number = Body.Saturn; break; case EventType.UranusRiseSet: CelObject.Name = "Uranus"; CelObject.Number = Body.Uranus; break; case EventType.NeptuneRiseSet: CelObject.Name = "Neptune"; CelObject.Number = Body.Neptune; break; case EventType.PlutoRiseSet: CelObject.Name = "Pluto"; CelObject.Number = Body.Pluto; break; default: throw new InvalidValueException("TypeOfEvent", TypeOfEvent.ToString(), "Unknown type of event"); } CelObject.Star = catEntry3; CelObject.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; Location.OnSurf = onSurface; Location.Where = ObserverLocation.EarthGeoCenter; int num1 = (int)Nov31.Place(JdHigh + DeltaT * 1.15740740740741E-05, CelObject, Location, DeltaT, CoordSys.EquinoxOfDate, Accuracy.Full, ref Output); bodyInfo.Distance = Output.Dis * 149597870.691; double Gst = 0; Nov31.SiderealTime(JdHigh, 0.0, DeltaT, GstType.GreenwichApparentSiderealTime, ASCOM.Astrometry.Method.EquinoxBased, Accuracy.Full, ref Gst); double num2 = 15.0 * (Range(Gst + Longitude * (1.0 / 15.0), 0.0, true, 24.0, false) - Output.RA); bodyInfo.Altitude = Math.Asin(Math.Sin(Latitude * (Math.PI / 180.0)) * Math.Sin(Output.Dec * (Math.PI / 180.0)) + Math.Cos(Latitude * (Math.PI / 180.0)) * Math.Cos(Output.Dec * (Math.PI / 180.0)) * Math.Cos(num2 * (Math.PI / 180.0))) * (180.0 / Math.PI); switch (TypeOfEvent) { case EventType.MoonRiseMoonSet: bodyInfo.Radius = 1737.0; break; case EventType.MercuryRiseSet: bodyInfo.Radius = 2439.7; break; case EventType.VenusRiseSet: bodyInfo.Radius = 2439.7; break; case EventType.MarsRiseSet: bodyInfo.Radius = 3396.2; break; case EventType.JupiterRiseSet: bodyInfo.Radius = 69911.0; break; case EventType.SaturnRiseSet: bodyInfo.Radius = 6051.8; break; case EventType.UranusRiseSet: bodyInfo.Radius = 24973.0; break; case EventType.NeptuneRiseSet: bodyInfo.Radius = 24767.0; break; case EventType.PlutoRiseSet: bodyInfo.Radius = 1153.0; break; default: bodyInfo.Radius = 696342.0; break; } return(bodyInfo); }
public PositionVector GetTopocentricPosition(double tjd, Site site, bool Refract) { CatEntry star = new CatEntry(); SiteInfo siteInfo = new SiteInfo(); double[] earthvector1 = new double[4]; double[] pos2_1 = new double[4]; double[] vel1 = new double[4]; double[] pos2_2 = new double[4]; double[] earthvector2 = new double[4]; double[] pos1 = new double[4]; double[] pos2_3 = new double[4]; double[] pos2_4 = new double[4]; double[] pos2_5 = new double[4]; double[] pos2_6 = new double[4]; double[] pos2_7 = new double[4]; double[] vel2 = new double[4]; double[] pos2_8 = new double[4]; double[] bary_earthp = new double[4]; double[] bary_earthv = new double[4]; double[] helio_earthp = new double[4]; double[] helio_earthv = new double[4]; double[] pos2 = new double[4]; if (!(this.m_rav & this.m_decv)) { throw new ASCOM.Astrometry.Exceptions.ValueNotSetException("Star.GetTopocentricPosition RA or DEC not available"); } double jd_high = !this.m_bDTValid ? tjd - DeltatCode.DeltaTCalc(tjd) / 86400.0 : tjd - this.m_deltat; try { siteInfo.Latitude = site.Latitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Latitude is not available"); } try { siteInfo.Longitude = site.Longitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Longitude is not available"); } try { siteInfo.Height = site.Height; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Height is not available"); } double tdb = 0; this.hr = NOVAS2.GetEarth(tjd, ref this.m_earth, ref tdb, ref bary_earthp, ref bary_earthv, ref helio_earthp, ref helio_earthv); if ((int)this.hr > 0) { pos2[0] = 0.0; pos2[1] = 0.0; pos2[2] = 0.0; throw new NOVASFunctionException("Star.GetApparentPosition", "get_earth", this.hr); } double mobl = 0; double tobl = 0; double eq = 0; double dpsi = 0; double deps = 0; NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps); double gst = 0; NOVAS2.SiderealTime(jd_high, 0.0, eq, ref gst); NOVAS2.Terra(ref siteInfo, gst, ref pos1, ref vel2); int num1 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos1, ref pos2_3); NOVAS2.Precession(tdb, pos2_3, 2451545.0, ref pos2_1); int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel2, ref pos2_8); NOVAS2.Precession(tdb, pos2_8, 2451545.0, ref pos2_2); int index = 0; do { earthvector1[index] = bary_earthp[index] + pos2_1[index]; vel1[index] = bary_earthv[index] + pos2_2[index]; earthvector2[index] = helio_earthp[index] + pos2_1[index]; checked { ++index; } }while (index <= 2); star.RA = this.m_ra; star.Dec = this.m_dec; star.ProMoRA = this.m_pmra; star.ProMoDec = this.m_pmdec; star.Parallax = this.m_plx; star.RadialVelocity = this.m_rv; NOVAS2.StarVectors(star, ref pos1, ref vel2); NOVAS2.ProperMotion(2451545.0, pos1, vel2, tdb, ref pos2_3); double lighttime = 0; NOVAS2.BaryToGeo(pos2_3, earthvector1, ref pos2_4, ref lighttime); int num3 = (int)NOVAS2.SunField(pos2_4, earthvector2, ref pos2_5); int num4 = (int)NOVAS2.Aberration(pos2_5, vel1, lighttime, ref pos2_6); NOVAS2.Precession(2451545.0, pos2_6, tdb, ref pos2_7); int num5 = (int)NOVAS2.Nutate(tdb, NutationDirection.MeanToTrue, pos2_7, ref pos2); double ra = 0; double dec = 0; int num6 = (int)NOVAS2.Vector2RADec(pos2, ref ra, ref dec); double num7 = Math.Sqrt(Math.Pow(pos2[0], 2.0) + Math.Pow(pos2[1], 2.0) + Math.Pow(pos2[2], 2.0)); RefractionOption ref_option = RefractionOption.NoRefraction; if (Refract) { bool flag = true; try { siteInfo.Temperature = site.Temperature; } catch (Exception ex) { //ProjectData.SetProjectError(ex); flag = false; //ProjectData.ClearProjectError(); } try { siteInfo.Pressure = site.Pressure; } catch (Exception ex) { //ProjectData.SetProjectError(ex); flag = false; //ProjectData.ClearProjectError(); } ref_option = !flag ? RefractionOption.StandardRefraction : RefractionOption.LocationRefraction; } double zd = 0; double az = 0; double rar = 0; double decr = 0; if (this.m_bDTValid) { NOVAS2.Equ2Hor(tjd, this.m_deltat, 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr); } else { NOVAS2.Equ2Hor(tjd, DeltatCode.DeltaTCalc(tjd), 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr); } if (ref_option > RefractionOption.NoRefraction) { NOVAS2.RADec2Vector(rar, decr, num7, ref pos2); } return(new PositionVector(pos2[0], pos2[1], pos2[2], rar, decr, num7, num7 / 173.14463348, az, 90.0 - zd)); }
public PositionVector GetLocalPosition(double tjd, Site site) { CatEntry star = new CatEntry(); PositionVector positionVector = new PositionVector(); SiteInfo locale = new SiteInfo(); double[] pos2_1 = new double[4]; double[] pos2_2 = new double[4]; double[] earthvector1 = new double[4]; double[] vel1 = new double[4]; double[] earthvector2 = new double[4]; double[] numArray = new double[4]; double[] pos = new double[4]; double[] vel2 = new double[4]; double[] pos2_3 = new double[4]; double[] pos2_4 = new double[4]; double[] pos2_5 = new double[4]; double[] pos2_6 = new double[4]; double[] bary_earthp = new double[4]; double[] bary_earthv = new double[4]; double[] helio_earthp = new double[4]; double[] helio_earthv = new double[4]; double[] pos2_7 = new double[4]; if (!(this.m_rav & this.m_decv)) { throw new ASCOM.Astrometry.Exceptions.ValueNotSetException("Star.GetLocalPosition RA or DEC not available"); } double jd_high = !this.m_bDTValid ? tjd - DeltatCode.DeltaTCalc(tjd) / 86400.0 : tjd - this.m_deltat; star.RA = this.m_ra; star.Dec = this.m_dec; star.ProMoRA = this.m_pmra; star.ProMoDec = this.m_pmdec; star.Parallax = this.m_plx; star.RadialVelocity = this.m_rv; try { locale.Latitude = site.Latitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetLocalPosition Site.Latitude is not available"); } try { locale.Longitude = site.Longitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetLocalPosition Site.Longitude is not available"); } try { locale.Height = site.Height; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetLocalPosition Site.Height is not available"); } double tdb = 0; this.hr = NOVAS2.GetEarth(tjd, ref this.m_earth, ref tdb, ref bary_earthp, ref bary_earthv, ref helio_earthp, ref helio_earthv); if ((int)this.hr > 0) { pos2_7[0] = 0.0; pos2_7[1] = 0.0; pos2_7[2] = 0.0; throw new NOVASFunctionException("Star.GetApparentPosition", "get_earth", this.hr); } double mobl = 0; double tobl = 0; double eq = 0; double dpsi = 0; double deps = 0; NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps); double gst = 0; NOVAS2.SiderealTime(jd_high, 0.0, eq, ref gst); NOVAS2.Terra(ref locale, gst, ref pos, ref vel2); int num1 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos, ref pos2_3); NOVAS2.Precession(tdb, pos2_3, 2451545.0, ref pos2_1); int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel2, ref pos2_4); NOVAS2.Precession(tdb, pos2_4, 2451545.0, ref pos2_2); int index = 0; do { earthvector1[index] = bary_earthp[index] + pos2_1[index]; vel1[index] = bary_earthv[index] + pos2_2[index]; earthvector2[index] = helio_earthp[index] + pos2_1[index]; numArray[index] = helio_earthv[index] + pos2_2[index]; checked { ++index; } }while (index <= 2); NOVAS2.StarVectors(star, ref pos, ref vel2); NOVAS2.ProperMotion(2451545.0, pos, vel2, tdb, ref pos2_3); double lighttime = 0; NOVAS2.BaryToGeo(pos2_3, earthvector1, ref pos2_5, ref lighttime); int num3 = (int)NOVAS2.SunField(pos2_5, earthvector2, ref pos2_6); int num4 = (int)NOVAS2.Aberration(pos2_6, vel1, lighttime, ref pos2_7); positionVector.x = pos2_7[0]; positionVector.y = pos2_7[1]; positionVector.z = pos2_7[2]; return(positionVector); }
public double DeltaT(double Tjd) { return(DeltatCode.DeltaTCalc(Tjd)); }
public PositionVector GetTopocentricPosition(double tjd, Site site, bool Refract) { double[] pos1 = new double[4]; double[] pos2_1 = new double[4]; double[] pos2_2 = new double[4]; double[] pos2_3 = new double[4]; double[] pos2_4 = new double[4]; double[] vel1 = new double[4]; double[] pos2_5 = new double[4]; double[] pos2_6 = new double[4]; double[] pos2_7 = new double[4]; double[] earthvector1 = new double[4]; double[] pos2 = new double[4]; double[] vel2 = new double[4]; double[] earthvector2 = new double[4]; double[] peb = new double[4]; double[] veb = new double[4]; double[] pes = new double[4]; double[] ves = new double[4]; Object3 SsBody = new Object3(); OnSurface onSurface = new OnSurface(); if (!this.m_bDTValid) { this.m_deltat = DeltatCode.DeltaTCalc(tjd); } double num1 = tjd - this.m_deltat / 86400.0; SiteInfo siteInfo = new SiteInfo(); try { siteInfo.Latitude = site.Latitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Latitude is not available"); } try { siteInfo.Longitude = site.Longitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Longitude is not available"); } try { siteInfo.Height = site.Height; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Height is not available"); } PositionVector positionVector; if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11)) { onSurface.Height = site.Height; onSurface.Latitude = site.Latitude; onSurface.Longitude = site.Longitude; onSurface.Pressure = site.Pressure; onSurface.Temperature = site.Temperature; SsBody.Number = CommonCode.NumberToBody(this.m_number); SsBody.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; RefractionOption RefOption = !Refract ? RefractionOption.NoRefraction : RefractionOption.LocationRefraction; double Ra = 0; double Dec = 0; double Dis = 0; this.Nov31.TopoPlanet(tjd, SsBody, this.m_deltat, onSurface, Accuracy.Full, ref Ra, ref Dec, ref Dis); double Zd = 0; double Az = 0; double RaR = 0; double DecR = 0; this.Nov31.Equ2Hor(num1, this.m_deltat, Accuracy.Full, 0.0, 0.0, onSurface, Ra, Dec, RefOption, ref Zd, ref Az, ref RaR, ref DecR); this.Nov31.RaDec2Vector(RaR, DecR, Dis, ref pos2); positionVector = new PositionVector(pos2[0], pos2[1], pos2[2], RaR, DecR, Dis, Dis / 173.14463348, Az, 90.0 - Zd); } else { double tdb = 0; EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves); double mobl = 0; double tobl = 0; double eq = 0; double dpsi = 0; double deps = 0; NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps); double gst = 0; NOVAS2.SiderealTime(num1, 0.0, eq, ref gst); NOVAS2.Terra(ref siteInfo, gst, ref pos1, ref vel1); int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos1, ref pos2_1); NOVAS2.Precession(tdb, pos2_1, 2451545.0, ref pos2_6); int num3 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel1, ref pos2_5); NOVAS2.Precession(tdb, pos2_5, 2451545.0, ref pos2_7); short num4 = 0; do { earthvector1[(int)num4] = peb[(int)num4] + pos2_6[(int)num4]; vel2[(int)num4] = veb[(int)num4] + pos2_7[(int)num4]; earthvector2[(int)num4] = pes[(int)num4] + pos2_6[(int)num4]; ++num4; }while ((int)num4 <= 2); EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos1, ref vel1); double lighttime = 0; NOVAS2.BaryToGeo(pos1, earthvector1, ref pos2_1, ref lighttime); double num5 = tdb - lighttime; int num6 = 0; double tjd1; do { tjd1 = num5; EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos1, ref vel1); NOVAS2.BaryToGeo(pos1, earthvector1, ref pos2_1, ref lighttime); num5 = tdb - lighttime; checked { ++num6; } }while (Math.Abs(num5 - tjd1) > 1E-06 & num6 < 100); if (num6 >= 100) { throw new HelperException("Planet:GetTopocentricPoition ephemeris_nov did not converge in 100 iterations"); } int num7 = (int)NOVAS2.SunField(pos2_1, earthvector2, ref pos2_2); int num8 = (int)NOVAS2.Aberration(pos2_2, vel2, lighttime, ref pos2_3); NOVAS2.Precession(2451545.0, pos2_3, tdb, ref pos2_4); int num9 = (int)NOVAS2.Nutate(tdb, NutationDirection.MeanToTrue, pos2_4, ref pos2); double ra = 0; double dec = 0; int num10 = (int)NOVAS2.Vector2RADec(pos2, ref ra, ref dec); double num11 = Math.Sqrt(Math.Pow(pos2[0], 2.0) + Math.Pow(pos2[1], 2.0) + Math.Pow(pos2[2], 2.0)); RefractionOption ref_option = RefractionOption.NoRefraction; if (Refract) { bool flag = true; try { siteInfo.Temperature = site.Temperature; } catch (Exception ex) { //ProjectData.SetProjectError(ex); flag = false; //ProjectData.ClearProjectError(); } try { siteInfo.Pressure = site.Pressure; } catch (Exception ex) { //ProjectData.SetProjectError(ex); flag = false; //ProjectData.ClearProjectError(); } ref_option = !flag ? RefractionOption.StandardRefraction : RefractionOption.LocationRefraction; } double zd = 0; double az = 0; double rar = 0; double decr = 0; if (this.m_bDTValid) { NOVAS2.Equ2Hor(tjd, this.m_deltat, 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr); } else { NOVAS2.Equ2Hor(tjd, DeltatCode.DeltaTCalc(tjd), 0.0, 0.0, ref siteInfo, ra, dec, ref_option, ref zd, ref az, ref rar, ref decr); } if (ref_option != RefractionOption.NoRefraction) { NOVAS2.RADec2Vector(rar, decr, num11, ref pos2); } positionVector = new PositionVector(pos2[0], pos2[1], pos2[2], rar, decr, num11, num11 / 173.14463348, az, 90.0 - zd); } return(positionVector); }
public PositionVector GetLocalPosition(double tjd, Site site) { double[] pos2_1 = new double[4]; double[] pos2_2 = new double[4]; double[] earthvector1 = new double[4]; double[] vel1 = new double[4]; double[] earthvector2 = new double[4]; double[] numArray1 = new double[4]; double[] pos = new double[4]; double[] vel2 = new double[4]; double[] pos2_3 = new double[4]; double[] pos2_4 = new double[4]; double[] pos2_5 = new double[4]; double[] numArray2 = new double[4]; double[] peb = new double[4]; double[] veb = new double[4]; double[] pes = new double[4]; double[] ves = new double[4]; Object3 SsBody = new Object3(); OnSurface onSurface = new OnSurface(); if (!this.m_bDTValid) { this.m_deltat = DeltatCode.DeltaTCalc(tjd); } double num1 = tjd - this.m_deltat / 86400.0; SiteInfo locale = new SiteInfo(); try { locale.Latitude = site.Latitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Latitude is not available"); } try { locale.Longitude = site.Longitude; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Longitude is not available"); } try { locale.Height = site.Height; } catch (Exception ex) { //ProjectData.SetProjectError(ex); throw new ValueNotAvailableException("Star:GetTopocentricPosition Site.Height is not available"); } PositionVector positionVector; if (this.m_type == BodyType.Moon & (this.m_number == 10 | this.m_number == 11)) { onSurface.Height = site.Height; onSurface.Latitude = site.Latitude; onSurface.Longitude = site.Longitude; onSurface.Pressure = site.Pressure; onSurface.Temperature = site.Temperature; SsBody.Number = CommonCode.NumberToBody(this.m_number); SsBody.Type = ASCOM.Astrometry.ObjectType.MajorPlanetSunOrMoon; RefractionOption RefOption = RefractionOption.NoRefraction; double Ra = 0; double Dec = 0; double Dis = 0; this.Nov31.LocalPlanet(tjd, SsBody, this.m_deltat, onSurface, Accuracy.Full, ref Ra, ref Dec, ref Dis); double Zd = 0; double Az = 0; double RaR = 0; double DecR = 0; this.Nov31.Equ2Hor(num1, this.m_deltat, Accuracy.Full, 0.0, 0.0, onSurface, Ra, Dec, RefOption, ref Zd, ref Az, ref RaR, ref DecR); this.Nov31.RaDec2Vector(RaR, DecR, Dis, ref numArray2); positionVector = new PositionVector(numArray2[0], numArray2[1], numArray2[2], RaR, DecR, Dis, Dis / 173.14463348, Az, 90.0 - Zd); } else { double tdb = 0; EphemerisCode.get_earth_nov(ref this.m_earthephobj, tjd, ref tdb, ref peb, ref veb, ref pes, ref ves); double mobl = 0; double tobl = 0; double eq = 0; double dpsi = 0; double deps = 0; NOVAS2.EarthTilt(tdb, ref mobl, ref tobl, ref eq, ref dpsi, ref deps); double gst = 0; NOVAS2.SiderealTime(num1, 0.0, eq, ref gst); NOVAS2.Terra(ref locale, gst, ref pos, ref vel2); int num2 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, pos, ref pos2_3); NOVAS2.Precession(tdb, pos2_3, 2451545.0, ref pos2_1); int num3 = (int)NOVAS2.Nutate(tdb, NutationDirection.TrueToMean, vel2, ref pos2_4); NOVAS2.Precession(tdb, pos2_4, 2451545.0, ref pos2_2); int index = 0; do { earthvector1[index] = peb[index] + pos2_1[index]; vel1[index] = veb[index] + pos2_2[index]; earthvector2[index] = pes[index] + pos2_1[index]; numArray1[index] = ves[index] + pos2_2[index]; checked { ++index; } }while (index <= 2); EphemerisCode.ephemeris_nov(ref this.m_ephobj, tdb, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel2); double lighttime = 0; NOVAS2.BaryToGeo(pos, earthvector1, ref pos2_3, ref lighttime); double num4 = tdb - lighttime; int num5 = 0; double tjd1; do { tjd1 = num4; EphemerisCode.ephemeris_nov(ref this.m_ephobj, tjd1, this.m_type, this.m_number, this.m_name, Origin.Barycentric, ref pos, ref vel2); NOVAS2.BaryToGeo(pos, earthvector1, ref pos2_3, ref lighttime); num4 = tdb - lighttime; checked { ++num5; } }while (Math.Abs(num4 - tjd1) > 1E-06 & num5 < 100); if (num5 >= 100) { throw new HelperException("Planet:GetLocalPoition ephemeris_nov did not converge in 100 iterations"); } int num6 = (int)NOVAS2.SunField(pos2_3, earthvector2, ref pos2_5); int num7 = (int)NOVAS2.Aberration(pos2_5, vel1, lighttime, ref numArray2); positionVector = new PositionVector(); positionVector.x = numArray2[0]; positionVector.y = numArray2[1]; positionVector.z = numArray2[2]; } return(positionVector); }