private Dictionary <PlanetId, List <IPlanetEvent> > classify(Ephemeris theEphe, PlanetEventFlag category) { List <IPlanetEvent> events = theEphe[Since, Until, category]; if (events != null && events.Count != 0) { Dictionary <PlanetId, List <IPlanetEvent> > result = new Dictionary <PlanetId, List <IPlanetEvent> >(); foreach (IPlanetEvent evt in events) { if (negligiblePlanets != null && (negligiblePlanets.Contains(evt.Who))) { continue; } if (!result.ContainsKey(evt.Who)) { result.Add(evt.Who, new List <IPlanetEvent>()); } result[evt.Who].Add(evt); } return(result); } return(null); }
/// <summary> /// 将指定的Sp3转换成 RINEX V3.0字符串。 /// </summary> /// <param name="file"></param> /// <param name="P_V_ModeFlag"></param> /// <returns></returns> public static string BuidSp3V3String(Sp3File file, string P_V_ModeFlag = "P") { StringBuilder sb = new StringBuilder(); sb.Append(BuildHeaderString(file.Header, P_V_ModeFlag)); //Sp3Section sec = new Sp3Section(); foreach (var item in file.Data.Values) { sb.AppendLine(BuildFirstLineSp3(item)); foreach (var prn in file.Header.PRNs) { Ephemeris sat = new Ephemeris(); if (item.Contains(prn)) { sat = item[prn]; } else { sat.Prn = prn; sat.XYZ = new XYZ(); sat.ClockBias = 0.999999999999; } sb.Append(BuildSp3Record(sat, P_V_ModeFlag)); } //foreach (Sp3Record rec in key.Data.Values) //{ // sb.Append(BuildSp3Record(rec, P_V_ModeFlag)); //} } sb.Append("EOF"); return(sb.ToString()); }
/// <summary> /// 构建历元数据 /// </summary> /// <param name="Sp3Record"></param> /// <param name="P_V_ModeFlag"></param> /// <returns></returns> public static string BuildSp3Record(Ephemeris Sp3Record, string P_V_ModeFlag = "P") { StringBuilder sb = new StringBuilder(); //sb.AppendLine(BuildFirstLineSp3(Sp3Record)); sb.Append("P" + Sp3Record.Prn.ToString()); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XYZ.X / 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XYZ.Y / 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XYZ.Z / 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.ClockBias * 1000000).ToString("0.000000"), 14)); if (Sp3Record.Rms != null) { //sb.Append(StringUtil.FillSpaceLeft(Sp3Record.XyzSdev.X.ToString(), 2)); //sb.Append(StringUtil.FillSpaceLeft(Sp3Record.XyzSdev.Y.ToString(), 2)); //sb.Append(StringUtil.FillSpaceLeft(Sp3Record.XyzSdev.Z.ToString(), 2)); } //if (Sp3Record.ClockSdev!=null) //sb.Append(StringUtil.FillSpaceLeft(Sp3Record.ClockSdev.ToString(), 2)); sb.AppendLine(); if (P_V_ModeFlag == "V") { sb.Append("EP"); sb.AppendLine(); sb.Append("V" + Sp3Record.Prn.ToString()); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XyzDot.X * 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XyzDot.Y * 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.XyzDot.Z * 1000).ToString("0.000000"), 14)); sb.Append(StringUtil.FillSpaceLeft((Sp3Record.ClockDrift * 1e12).ToString("0.000000"), 14)); sb.AppendLine(); sb.Append("EV"); sb.AppendLine(); } return(sb.ToString()); }
//private void getAllEvents() //{ // Occultations = Ephemeris.Geocentric[Since, Until, PlanetEventFlag.EclipseOccultationCategory]; // DirectionChanges = classify(Ephemeris.Geocentric, PlanetEventFlag.DirectionalCategory); // GeocentricSignChanges = classify(Ephemeris.Geocentric, PlanetEventFlag.SignChangedCategory); // HeliocentricSignChanges = classify(Ephemeris.Heliocentric, PlanetEventFlag.SignChangedCategory); // VerticalChanges = classify(Ephemeris.Geocentric, PlanetEventFlag.DirectionalCategory); // GeocentricAspects = summarizedAspect(Ephemeris.Geocentric); // HeliocentricAspects = summarizedAspect(Ephemeris.Heliocentric); //} private SortedDictionary <PlanetPair, List <IPlanetEvent> > summarizedAspect(Ephemeris theEphe) { List <IPlanetEvent> events = theEphe[Since, Until, Concerned]; //events.Sort() if (events != null && events.Count != 0) { SortedDictionary <PlanetPair, List <IPlanetEvent> > result = new SortedDictionary <PlanetPair, List <IPlanetEvent> >(); foreach (ExactAspectEvent aspEvent in events) { if (negligiblePlanets != null && (negligiblePlanets.Contains(aspEvent.Interior) || negligiblePlanets.Contains(aspEvent.Exterior))) { continue; } if (!result.ContainsKey(aspEvent.Pair)) { result.Add(aspEvent.Pair, new List <IPlanetEvent>()); } result[aspEvent.Pair].Add(aspEvent); } return(result); } else { return(null); } }
private void ShowComparing() { //比较 List <ClockLite> compares = new List <ClockLite>(); foreach (var item in Clocks) { Ephemeris eph = Ephemerides.Find(m => m.Time.Equals(item.Time)); if (eph == null) { continue; } ClockLite c = new ClockLite() { Prn = item.Prn == null?SatelliteNumber.Parse(item.Name) : item.Prn, GpsTime = item.Time, Offset = item.ClockBias - eph.ClockBias, Drift = item.ClockDrift - eph.ClockDrift }; c.Distance = c.Offset * GnssConst.LIGHT_SPEED; compares.Add(c); } this.bindingSource_comparing.DataSource = compares; }
public DateEvents(DateTimeOffset date) { try { if (date.TimeOfDay == TimeSpan.Zero && date.Offset == TimeSpan.Zero) { Date = date; } else { Date = new DateTimeOffset(date.UtcDateTime.Date, TimeSpan.Zero); } MatchRules during = new MatchRules(Date, SearchMode.WithinTheDay); Relations = Ephemeris.RelationsWithin(during); Positions = new Dictionary <PlanetId, PlanetEvents>(); for (PlanetId id = PlanetId.SE_SUN; id <= PlanetId.SE_PLUTO; id++) { Positions.Add(id, new PlanetEvents(TheEphemeris, Date, id)); } Positions.Add(PlanetId.SE_NORTHNODE, new PlanetEvents(TheEphemeris, Date, PlanetId.SE_NORTHNODE)); Positions.Add(PlanetId.SE_CHIRON, new PlanetEvents(TheEphemeris, Date, PlanetId.SE_CHIRON)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Message); } }
public Sputnik(int number, DateTime data, string ephemerisInfo) { this.number = number; this.data = data; this.ephemerisInfo = ephemerisInfo; this._ephemeris = new Ephemeris(ephemerisInfo); //CalculatePositionNew(_ephemeris.Toe + 60); }
public static Relation FirstRelationSince(PlanetId SuperiorId, PlanetId InferiorId, Double sinceJulian) { reorder(ref SuperiorId, ref InferiorId); double orbToNext, speed, step = 100.0, time = sinceJulian; Position superiorPos, inferiorPos; int tries = 0; Angle angle; Aspects next = null; do { superiorPos = Ephemeris.Geocentric[time, SuperiorId]; inferiorPos = Ephemeris.Geocentric[time, InferiorId]; angle = inferiorPos.Longitude - superiorPos.Longitude; speed = inferiorPos.LongitudeVelocity - superiorPos.LongitudeVelocity; if (next == null) { next = Aspects.NextAspect(angle, speed > 0); double temp = next.OrbOf(angle); step = -temp / speed; if (time + step < sinceJulian) { next = Aspects.NextAspect(angle, speed < 0); } } orbToNext = next.OrbOf(angle); if (Math.Abs(orbToNext) < Negligible) { return(new Relation(Ephemeris.UtcFromJulianDay(time), superiorPos, inferiorPos)); } step = -orbToNext / speed; if (step > MaxStep) { step = MaxStep; } else if (step < -MaxStep) { step = -MaxStep; } time += step; tries++; } while (tries < maxTry); return(null); }
private void RenderDebugInfo(RenderContext context) { _debugRenderer.Clear(); _debugRenderer.DrawAxes(Pose.Identity, 0.5f, true); //_debugRenderer.DrawTexture(_cloudLayerNode._renderTarget, new Rectangle(1280-512, 0, 512, 512)); #if XBOX _debugRenderer.DrawText(_ephemeris.Time.DateTime.ToString()); #else _debugRenderer.DrawText(_ephemeris.Time.ToString()); #endif _debugRenderer.PointSize = 10; var extraterrestrialSunlight = Ephemeris.ExtraterrestrialSunlight; Vector3F sun; Vector3F ambient; Ephemeris.GetSunlight(_scatteringSky.ObserverAltitude, 2.2f, _scatteringSky.SunDirection, out sun, out ambient); var scatterSun = _scatteringSky.GetSunlight() / _scatteringSky.SunIntensity * extraterrestrialSunlight; var scatterAmbient = _scatteringSky.GetAmbientLight(1024); scatterAmbient = scatterAmbient / _scatteringSky.SunIntensity * extraterrestrialSunlight; var scatterFog = _scatteringSky.GetFogColor(128) / _scatteringSky.SunIntensity * extraterrestrialSunlight; var luminance = Vector3F.Dot(GraphicsHelper.LuminanceWeights, scatterFog); scatterFog = InterpolationHelper.Lerp(scatterFog, new Vector3F(luminance), 0.7f); _debugRenderer.DrawText("Extraterrestrial sun intensity:" + extraterrestrialSunlight.Length); _debugRenderer.DrawText("Spectrum sun intensity:" + sun.Length); _debugRenderer.DrawText("Scatter sun intensity:" + scatterSun.Length); _debugRenderer.DrawText("\nSpectrum ambient intensity:" + ambient.Length); _debugRenderer.DrawText("Scatter ambient intensity:" + scatterAmbient.Length); _debugRenderer.DrawText("\nScatter fog intensity:" + scatterFog.Length); _debugRenderer.DrawPoint(new Vector3F(-0.5f, 0, 0), new Color((Vector3)extraterrestrialSunlight.Normalized), true); sun.TryNormalize(); ambient /= ambient.Length; _debugRenderer.DrawPoint(new Vector3F(0, 0, 0), new Color((Vector3)sun), true); _debugRenderer.DrawPoint(new Vector3F(0, -0.5f, 0), new Color((Vector3)ambient), true); scatterSun.TryNormalize(); scatterAmbient.TryNormalize(); _debugRenderer.DrawPoint(new Vector3F(0.5f, 0, 0), new Color((Vector3)scatterSun), true); _debugRenderer.DrawPoint(new Vector3F(0.5f, -0.5f, 0), new Color((Vector3)scatterAmbient), true); scatterFog.TryNormalize(); _debugRenderer.DrawPoint(new Vector3F(0, 0.5f, 0), new Color((Vector3)scatterFog), true); _debugRenderer.PointSize = 40f; _debugRenderer.Render(context); }
/// <summary> /// GPS SSR信息转换。 message1057 /// </summary> /// <param name="msg"></param> /// <param name="SSRGpsClockCorrectionHeader"></param> /// <returns></returns> public Ephemeris GetSp3Param(Message1057 msg, SSRGpsHeader68 SSRGpsClockCorrectionHeader) { Ephemeris Sp3Record = new Ephemeris(); Sp3Record.Prn = new SatelliteNumber((int)msg.SatelliteID, SatelliteType.G); Sp3Record.Time = new Time(Setting.ReceivingTimeOfNtripData.GpsWeek, SSRGpsClockCorrectionHeader.EpochTime1s); Sp3Record.XYZ = new XYZ(msg.DeltaRadial * RtcmConst.DeltaRadial, msg.DeltaAlongTrack * RtcmConst.DeltaAlongTrack, msg.DeltaCrossTrack * RtcmConst.DeltaCrossTrack); Sp3Record.XyzDot = new XYZ(msg.DotDeltaRadial * RtcmConst.DotDeltaRadial, msg.DotDeltaAlongTrack * RtcmConst.DotDeltaAlongTrack, msg.DotDeltaCrossTrack * RtcmConst.DotDeltaCrossTrack); Sp3Record.Rms = new XYZ(); return(Sp3Record); }
/// <summary> /// GLONASS SSR信息转换。Message1063 /// </summary> /// <param name="msg"></param> /// <param name="SSRGlonassOrbitHeader"></param> /// <returns></returns> public Ephemeris GetSp3Param(Message1063 msg, SSRGlonassHeader65 SSRGlonassOrbitHeader) { Ephemeris Sp3Record = new Ephemeris(); Sp3Record.Prn = new SatelliteNumber((int)msg.SatelliteID, SatelliteType.R); Sp3Record.Time = new Time(DateTime.Parse(Setting.ReceivingTimeOfNtripData.Date.ToString()), SSRGlonassOrbitHeader.EpochTime1s + 1);//是否需要更改,两个系统所采用的时间系统差的存在 Sp3Record.XYZ = new XYZ(msg.DeltaRadial * RtcmConst.DeltaRadial, msg.DeltaAlongTrack * RtcmConst.DeltaAlongTrack, msg.DeltaCrossTrack * RtcmConst.DeltaCrossTrack); Sp3Record.XyzDot = new XYZ(msg.DotDeltaRadial * RtcmConst.DotDeltaRadial, msg.DotDeltaAlongTrack * RtcmConst.DotDeltaAlongTrack, msg.DotDeltaCrossTrack * RtcmConst.DotDeltaCrossTrack); Sp3Record.Rms = new XYZ(); return(Sp3Record); }
private void button_inter_Click(object sender, EventArgs e) { if (sortedRecordsA != null && sortedRecordsA.Count != 0 && sortedRecordsB != null && sortedRecordsB.Count != 0) { double interval = Double.Parse(this.textBox_interval.Text); SatelliteNumber PRN = SatelliteNumber.Parse(this.comboBox_prn.SelectedItem.ToString()); List <Ephemeris> fitedResultA = new List <Ephemeris>(); List <Ephemeris> fitedResultB = new List <Ephemeris>(); Time start = new Time(this.dateTimePicker_from.Value); if (ephemerisA is Geo.Algorithm.IInterpolationCaller) { Geo.Algorithm.IInterpolationCaller a = ephemerisA as Geo.Algorithm.IInterpolationCaller; a.Order = int.Parse(this.textBox_A_count.Text); if (this.radioButton_A_cheb.Checked) { a.InterpolationType = InterpolationType.ChebyshevPolyFit; } else { a.InterpolationType = InterpolationType.LagrangeInterplation; } } if (ephemerisB is Geo.Algorithm.IInterpolationCaller) { Geo.Algorithm.IInterpolationCaller b = ephemerisB as Geo.Algorithm.IInterpolationCaller; b.Order = int.Parse(this.textBox_B_count.Text); if (this.radioButton_B_cheb.Checked) { b.InterpolationType = InterpolationType.ChebyshevPolyFit; } else { b.InterpolationType = InterpolationType.LagrangeInterplation; } } double cacuCount = (this.dateTimePicker_to.Value - this.dateTimePicker_from.Value).TotalSeconds / interval; for (int xi = 0; xi < cacuCount; xi++) { Time gpsTime = start + interval * xi; Ephemeris eA = ephemerisA.Get(PRN, gpsTime); Ephemeris eB = ephemerisB.Get(PRN, gpsTime); fitedResultA.Add(eA); fitedResultB.Add(eB); } this.bindingSource1.DataSource = fitedResultA; this.bindingSource2.DataSource = fitedResultB; this.bindingSource3.DataSource = GetDifferEphemeirs(fitedResultA, fitedResultB); } }
/// <summary> /// GLONASS SSR信息转换。Message1064 /// </summary> /// <param name="msg"></param> /// <param name="SSRGlonassClockCorrectionHeader"></param> /// <returns></returns> public Ephemeris GetSp3Param(Message1066 msg, SSRGlonassHeader65 SSRGlonassClockCorrectionHeader)//, double SSRt,XYZ a,XYZ b) { Ephemeris Sp3Record = new Ephemeris(); Sp3Record.Prn = new SatelliteNumber((int)msg.SatelliteID, SatelliteType.R); Sp3Record.Time = new Time(DateTime.Parse(Setting.ReceivingTimeOfNtripData.Date.ToString()), SSRGlonassClockCorrectionHeader.EpochTime1s + 1); //是否需要更改,两个系统所采用的时间系统差的存在 Sp3Record.ClockBias = msg.DeltaClockC0 * RtcmConst.DeltaClockC0solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockDrift = msg.DeltaClockC1 * RtcmConst.DeltaClockC1solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.DriftRate = msg.DeltaClockC2 * RtcmConst.DeltaClockC2solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockBiasRms = new double(); Sp3Record.Rms = new XYZ(); return(Sp3Record); }
/// <summary> /// SBS SSR信息转换。 /// </summary> /// <param name="msg"></param> /// <param name="SSRSBSClockCorrectionHeader"></param> /// <returns></returns> public Ephemeris GetSp3Param(Message1253 msg, SSRSBSHeader67 SSRSBSClockCorrectionHeader)//, double SSRt,XYZ a,XYZ b) { Ephemeris Sp3Record = new Ephemeris(); Sp3Record.Prn = new SatelliteNumber((int)msg.SatelliteID, SatelliteType.G); Sp3Record.Time = new Time(Setting.ReceivingTimeOfNtripData.GpsWeek, SSRSBSClockCorrectionHeader.EpochTime1s); Sp3Record.ClockBias = msg.DeltaClockC0 * RtcmConst.DeltaClockC0solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockDrift = msg.DeltaClockC1 * RtcmConst.DeltaClockC1solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.DriftRate = msg.DeltaClockC2 * RtcmConst.DeltaClockC2solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockBiasRms = new double(); Sp3Record.Rms = new XYZ(); return(Sp3Record); }
/// <summary> /// GPS SSR信息转换。 message1060 /// </summary> /// <param name="msg"></param> /// <param name="SSRGpsCombinedHeader"></param> /// <returns></returns> public Ephemeris GetSp3Param(Message1060 msg, SSRGpsHeader68 SSRGpsCombinedHeader) { Ephemeris Sp3Record = new Ephemeris(); Sp3Record.Prn = new SatelliteNumber((int)msg.SatelliteID, SatelliteType.G); Sp3Record.Time = new Time(Setting.ReceivingTimeOfNtripData.GpsWeek, SSRGpsCombinedHeader.EpochTime1s); Sp3Record.XYZ = new XYZ(msg.DeltaRadial * RtcmConst.DeltaRadial, msg.DeltaAlongTrack * RtcmConst.DeltaAlongTrack, msg.DeltaCrossTrack * RtcmConst.DeltaCrossTrack); Sp3Record.XyzDot = new XYZ(msg.DotDeltaRadial * RtcmConst.DotDeltaRadial, msg.DotDeltaAlongTrack * RtcmConst.DotDeltaAlongTrack, msg.DotDeltaCrossTrack * RtcmConst.DotDeltaCrossTrack); Sp3Record.ClockBias = msg.DeltaClockC0 * RtcmConst.DeltaClockC0solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockDrift = msg.DeltaClockC1 * RtcmConst.DeltaClockC1solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); Sp3Record.ClockBiasRms = msg.DeltaClockC2 * RtcmConst.DeltaClockC2solution / GnssConst.LIGHT_SPEED; // (3 * 1E8); return(Sp3Record); }
public double DegreeOn(DateTimeOffset time) { if (Owner == PlanetId.Earth_Rotation) { TimeSpan duration = time - Pivot.Time; return(duration.TotalMinutes / 4); } else { Position pos = Ephemeris.PositionOf(time, Owner, Centric); double result = (IsReversed ? 360 - pos.Longitude : pos.Longitude) + Offset + PivotShift; return(result); } }
private static void eclipseTest3() { int year = 1927; DateTimeOffset date = new DateTimeOffset(year, 5, 1, 0, 0, 0, TimeSpan.Zero); List <SeFlg> flags = new List <SeFlg>() { (SeFlg)0, SeFlg.GEOCENTRIC, SeFlg.GEOCENTRIC | SeFlg.SEFLG_TRUEPOS, SeFlg.EQUATORIALBASED, SeFlg.HELIOCENTRIC, SeFlg.HELIOCENTRIC | SeFlg.SEFLG_EQUATORIAL }; Position pos = null; PlanetId star = PlanetId.SE_URANUS; while (true) { Console.WriteLine("On " + date.ToString()); foreach (SeFlg flg in flags) { pos = Ephemeris.PositionOf(date, star, flg); Console.WriteLine("{0}: Long={1}, Lat={2}", flg, pos.Longitude, pos.Latitude); } Console.WriteLine("Input the date: "); string line = Console.ReadLine(); if (!DateTimeOffset.TryParse(line, out date)) { return; } Console.WriteLine("Input the planet: "); PlanetId id = PlanetId.SE_URANUS; line = Console.ReadLine(); if (Planet.TryParseId(line, out id)) { star = id; } } }
private static void eclipseTest() { String y = null; int year = 0; while (true) { Console.WriteLine("Input the year: "); y = Console.ReadLine(); if (!int.TryParse(y, out year)) { return; } Console.WriteLine("Eclipse/Occultations on year {0}:", year); DateTimeOffset start = new DateTimeOffset(year, 1, 1, 0, 0, 0, TimeSpan.Zero); DateTimeOffset end = new DateTimeOffset(year + 1, 1, 1, 0, 0, 0, TimeSpan.Zero); List <IPlanetEvent> lunarEvents = Ephemeris.SolarEclipseDuring(start, end); foreach (IPlanetEvent evt in lunarEvents) { Console.WriteLine(evt.ToString()); } Console.ReadKey(); lunarEvents = Ephemeris.LunarEclipseDuring(start, end); foreach (IPlanetEvent evt in lunarEvents) { Console.WriteLine(evt.ToString()); } Console.ReadKey(); lunarEvents = Ephemeris.OccultationDuring(start, end); StringBuilder sb = new StringBuilder(); foreach (Occultation evt in lunarEvents) { sb.AppendLine(evt.ToString()); } Console.WriteLine(sb.ToString()); } }
public static double MovementOf(PlanetId id, bool isHeliocentric, DateTimeOffset time1, DateTimeOffset time2) { Position pos1, pos2; if (time1 == time2) { return(0); } else if (time1 > time2) { DateTimeOffset tempTime = time1; time1 = time2; time2 = tempTime; } TimeSpan duration = time2 - time1; double period = duration.TotalDays / Planet.OrbitalPeriods[id]; double round = period * 360; if (isHeliocentric) { pos1 = Ephemeris.HeliocentricPositionOf(time1, id); pos2 = Ephemeris.HeliocentricPositionOf(time2, id); double temp = (360 + pos2.Longitude - pos1.Longitude) % 360; return(Math.Round((round - temp) / 360) * 360 + temp); } else { pos1 = Ephemeris.GeocentricPositionOf(time1, id); pos2 = Ephemeris.GeocentricPositionOf(time2, id); double temp = pos2.Longitude - pos1.Longitude; if (temp < 0 && (period > 0.4 || duration.Days > Planet.RetrogradePeriods[id])) { temp += 360; } else if (temp > 300 && period < 0.4) { temp -= 360; } return(Math.Round((round - temp) / 360) * 360 + temp); } }
public static Double DegreeToEquinox(DateTimeOffset time) { DateTimeOffset thisVernal = Ephemeris.VernalEquinoxTimeOf(time.Year); Double yearLength, elapsed; if (time >= thisVernal) { DateTimeOffset end = Ephemeris.VernalEquinoxTimeOf(time.Year + 1); yearLength = (end - thisVernal).TotalDays; elapsed = (time - thisVernal).TotalDays; } else { DateTimeOffset last = Ephemeris.VernalEquinoxTimeOf(time.Year - 1); yearLength = (thisVernal - last).TotalDays; elapsed = (time - last).TotalDays; } return((elapsed * 360 / yearLength).Normalize()); }
private static void MarsTest2(PlanetId id) { Rectascension destination = new Rectascension(346.7); DateTimeOffset since = new DateTimeOffset(1951, 3, 14, 1, 1, 0, TimeSpan.Zero); for (int i = 0; i < 10; i++) { destination = new Rectascension(destination.Degrees + i * 330); DateTimeOffset date = Ephemeris.DateOfPlanetPosition(id, since, destination); double jul_ut = Utilities.ToJulianDay(date); Position actual = Utilities.GeocentricPositionOfJulian(jul_ut, id); double dif = actual.Longitude - destination.Degrees; Console.WriteLine("{0}: {1} on {2}, dif = {3:F4}", date, id, actual.ToString("Astro0", null), dif); since = date + TimeSpan.FromDays(60); } }
private static void ParsePosStd(string firstLine, Ephemeris rec) { //读取精度估值stdv //Columns 62-63 x-sdev (b**n mm) 18 I2 //Column 64 Unused _ blank //Columns 65-66 y-sdev (b**n mm) 18 I2 //Column 67 Unused _ blank //Columns 68-69 z-sdev (b**n mm) 18 I2 //Column 70 Unused _ blank //Columns 71-73 c-sdev (b**n psec) 219 I3 double sdevX = 0.0, sdevY = 0.0, sdevZ = 0.0; string tmp = firstLine.Substring(61, 2); if (tmp != " ") { sdevX = double.Parse(tmp) * 0.001; } //保留为米 tmp = firstLine.Substring(64, 2); if (tmp != " ") { sdevY = double.Parse(tmp) * 0.001; } tmp = firstLine.Substring(67, 2); if (tmp != " ") { sdevZ = double.Parse(tmp) * 0.001; } rec.Rms = new Geo.Coordinates.XYZ(sdevX, sdevY, sdevZ); double sdevClock = 0.0; tmp = firstLine.Substring(70, 3); //保留了皮秒单位,因为10-12次方太小 if (tmp != " ") { sdevClock = double.Parse(tmp); } rec.ClockBiasRms = sdevClock; }
public IEnumerable <string> Get() { //var date = new DateTime(1977, 8, 30, 5, 10, 0, DateTimeKind.Utc); // Martin var date = DateTime.Now.ToUniversalTime(); var ephemeris = new Ephemeris(); var entry = ephemeris.Get(date); var humanDesignGates = new HumanDesignGates(); // var sunGate = humanDesignGates.GetDefinedGate((entry.Sun.AbsolutePosition - 88.0).Truncate(360)); var sunGate = humanDesignGates.GetDefinedGate(entry.Sun.AbsolutePosition); var earthGate = sunGate.GetOppositeGate(); yield return("Sun: " + sunGate); yield return("Earth: " + earthGate); yield return("Moon: " + humanDesignGates.GetDefinedGate(entry.Moon.AbsolutePosition)); yield return("North Node: " + humanDesignGates.GetDefinedGate(entry.TrueNode.AbsolutePosition)); yield return("South Node: " + humanDesignGates.GetDefinedGate((entry.TrueNode.AbsolutePosition + 180.0).Truncate(360))); yield return("Mercury: " + humanDesignGates.GetDefinedGate(entry.Mercury.AbsolutePosition)); yield return("Venus: " + humanDesignGates.GetDefinedGate(entry.Venus.AbsolutePosition)); yield return("Mars: " + humanDesignGates.GetDefinedGate(entry.Mars.AbsolutePosition)); yield return("Jupiter: " + humanDesignGates.GetDefinedGate(entry.Jupiter.AbsolutePosition)); yield return("Saturn: " + humanDesignGates.GetDefinedGate(entry.Saturn.AbsolutePosition)); yield return("Uranus: " + humanDesignGates.GetDefinedGate(entry.Uranus.AbsolutePosition)); yield return("Neptune: " + humanDesignGates.GetDefinedGate(entry.Neptune.AbsolutePosition)); yield return("Pluto: " + humanDesignGates.GetDefinedGate(entry.Pluto.AbsolutePosition)); }
private List <Ephemeris> GetDifferEphemeirs(List <Ephemeris> ephsA, List <Ephemeris> ephsB) { List <Ephemeris> sortedRecordsC = new List <Ephemeris>(); List <Ephemeris> sortedRecords = ephsA.FindAll(m => ephsB.Exists(n => n.Prn.Equals(m.Prn) && n.Time.Equals(m.Time))); foreach (var item in sortedRecords) { Ephemeris epheA = ephsA.Find(n => n.Prn.Equals(item.Prn) && n.Time.Equals(item.Time)); Ephemeris epheB = ephsB.Find(n => n.Prn.Equals(item.Prn) && n.Time.Equals(item.Time)); sortedRecordsC.Add(new Ephemeris() { Prn = item.Prn, Time = item.Time, ClockBias = epheA.ClockBias - epheB.ClockBias, ClockDrift = epheA.ClockDrift - epheB.ClockDrift, RelativeCorrection = epheA.RelativeCorrection - epheB.RelativeCorrection, XYZ = epheA.XYZ - epheB.XYZ, XyzDot = epheA.XyzDot - epheB.XyzDot, }); } return(sortedRecordsC); }
private static void HumanDesignTest() { Console.OutputEncoding = Encoding.UTF8; //var date = new DateTime(1977, 8, 30, 5, 10, 0, DateTimeKind.Utc); // Martin var date = DateTime.Now.ToUniversalTime(); var ephemeris = new Ephemeris(); var entry = ephemeris.Get(date); Console.WriteLine(entry); var humanDesignGates = new HumanDesignGates(); // var sunGate = humanDesignGates.GetDefinedGate((entry.Sun.AbsolutePosition - 88.0).Truncate(360)); var sunGate = humanDesignGates.GetDefinedGate(entry.Sun.AbsolutePosition); var earthGate = sunGate.GetOppositeGate(); Console.WriteLine("Sun: " + sunGate); Console.WriteLine("Earth: " + earthGate); Console.WriteLine("Moon: " + humanDesignGates.GetDefinedGate(entry.Moon.AbsolutePosition)); Console.WriteLine("North Node: " + humanDesignGates.GetDefinedGate(entry.TrueNode.AbsolutePosition)); Console.WriteLine("South Node: " + humanDesignGates.GetDefinedGate((entry.TrueNode.AbsolutePosition + 180.0).Truncate(360))); Console.WriteLine("Mercury: " + humanDesignGates.GetDefinedGate(entry.Mercury.AbsolutePosition)); Console.WriteLine("Venus: " + humanDesignGates.GetDefinedGate(entry.Venus.AbsolutePosition)); Console.WriteLine("Mars: " + humanDesignGates.GetDefinedGate(entry.Mars.AbsolutePosition)); Console.WriteLine("Jupiter: " + humanDesignGates.GetDefinedGate(entry.Jupiter.AbsolutePosition)); Console.WriteLine("Saturn: " + humanDesignGates.GetDefinedGate(entry.Saturn.AbsolutePosition)); Console.WriteLine("Uranus: " + humanDesignGates.GetDefinedGate(entry.Uranus.AbsolutePosition)); Console.WriteLine("Neptune: " + humanDesignGates.GetDefinedGate(entry.Neptune.AbsolutePosition)); Console.WriteLine("Pluto: " + humanDesignGates.GetDefinedGate(entry.Pluto.AbsolutePosition)); Console.WriteLine(); Console.WriteLine("Martin AC: " + humanDesignGates.GetDefinedGate(Zodiac.Virgo.GetStartDegree() + 13)); Console.WriteLine("Louise AC: " + humanDesignGates.GetDefinedGate(Zodiac.Cancer.GetStartDegree() + 28)); Console.WriteLine("David AC: " + humanDesignGates.GetDefinedGate(Zodiac.Gemini.GetStartDegree() + 17)); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} {1} on {2}: translated as {3} on Round {4}, Angle={5}, Radius={6}\r\n", Pivot.Type, Pivot.Price, Pivot.Date.ToString("yyyyMMdd"), Position.IndexValue, Position.Round, Position.Angle, Position.Radius); MatchRules during = new MatchRules(Pivot.Date, Ephemeris.DefaultSearchMode); List <Relation> relations = Ephemeris.RelationsWithin(during); foreach (Relation rel in relations) { if (NeglectMoon && rel.Inferior == PlanetId.SE_MOON || rel.Superior == PlanetId.SE_MOON) { continue; } sb.AppendFormat(", {0}{1}{2}(Orb={3})", Planet.SymbolOf(rel.Superior), rel.Aspect.Symbol, Planet.SymbolOf(rel.Inferior), rel.Orb.ToString("F3")); } return(sb.ToString()); }
private void getOrbits() { List <DateTimeOffset> timeValues = new List <DateTimeOffset>(); DateTimeOffset time = intradaySince; xValues.Clear(); do { timeValues.Add(time); time += SamplingInterval; xValues.Add(time.DateTime.ToOADate()); } while (time <= intradayUntil); orbits.Clear(); List <double> orbit = null; List <double> expanded = null; Position pos = null; foreach (PlanetId id in Ephemeris.Geocentric.Luminaries) { orbit = new List <double>(); expanded = new List <double>(); foreach (DateTimeOffset moment in timeValues) { pos = Ephemeris.GeocentricPositionOf(moment, id); orbit.Add(pos.Longitude); expanded.Add((pos.Longitude % 30) * 12); } orbits.Add(id, orbit); expandedOrbits.Add(id, expanded); } }
private void setDuration(ZedGraphControl zed, DateTimeOffset since, DateTimeOffset until) { double min = zed.GraphPane.XAxis.Scale.Min = since.DateTime.ToOADate(); double max = zed.GraphPane.XAxis.Scale.Max = until.DateTime.ToOADate(); List <SeFlg> centricFlags = new List <SeFlg> { SeFlg.GEOCENTRIC, SeFlg.HELIOCENTRIC }; List <double> xValues = new List <double>(); for (double x = min; x <= max; x++) { xValues.Add(x); } for (int i = zed.GraphPane.CurveList.Count - 1; i >= 0; i--) { CurveItem curve = zed.GraphPane.CurveList[i]; removeCurve(zedLongTerm, curve); } foreach (SeFlg flag in centricFlags) { CentricFlag = flag; #region Get the longitude curves OrbitsDict = CurrentEphemeris.AllOrbitsCollectionDuring(since, until); TheAspectarian = CurrentEphemeris.AspectarianDuring(since, until, defaultAspectImportance); //populateAspectarian(TheAspectarian); //Special treatment of average longDif by replacing them with the smoothed version without gap generated when a planet enters Aries for (int i = CurrentEphemeris.Luminaries.IndexOf(PlanetId.Five_Average); i < CurrentEphemeris.Luminaries.Count; i++) { PlanetId id = CurrentEphemeris.Luminaries[i]; List <double> beforeShift = OrbitsDict[PositionValueIndex.Longitude][id]; List <double> afterShift = Ephemeris.SmoothingOfAverage(beforeShift); OrbitsDict[PositionValueIndex.Longitude].Remove(id); OrbitsDict[PositionValueIndex.Longitude].Add(id, afterShift); } #endregion Curves.Clear(); foreach (KeyValuePair <PlanetId, List <double> > kvp in OrbitsDict[PositionValueIndex.Longitude]) { String name = Planet.Glyphs[kvp.Key].ToString(); Color color = Planet.PlanetsColors.ContainsKey(kvp.Key) ? Planet.PlanetsColors[kvp.Key].First() : Color.Gray; LineItem line = null; List <IPlanetEvent> signChanges = CurrentEphemeris[since, until, PlanetEventFlag.SignChangedCategory, kvp.Key]; if (signChanges != null && signChanges.Count != 0) { List <double> finalYs = new List <double>(kvp.Value); List <double> finalXs = new List <double>(xValues); for (int i = signChanges.Count - 1; i >= 0; i--) { SignEntrance change = signChanges[i] as SignEntrance; double x = (change.When - since).TotalDays; double y = Math.Round(change.Where.Longitude); int insertPos = (int)x + 1; if (y != 0 && y != 360) { finalXs.Insert(insertPos, x + min); finalYs.Insert(insertPos, y); } else { finalXs.Insert(insertPos, x + min); finalXs.Insert(insertPos, x + min); finalYs.Insert(insertPos, change.IsRetrograde ? 360 : 0); finalYs.Insert(insertPos, change.IsRetrograde ? 0 : 360); } } line = new LineItem(name, finalXs.ToArray(), finalYs.ToArray(), color, SymbolType.None); } else { line = new LineItem(name, xValues.ToArray(), kvp.Value.ToArray(), color, SymbolType.None); } Curves.Add(kvp.Key, new Dictionary <int, CurveItem> { { 0, line } }); } getEventCurves(); } }
/// <summary> /// 读取 SP3 /// </summary> /// <param name="header"></param> /// <param name="r"></param> /// <param name="firstLine"></param> /// <param name="satNum">是否读取指定卫星的值</param> /// <param name="availableOnly">是否只返回可用的记录</param> /// <returns></returns> public static Sp3Section ReadSection(Sp3Header header, StreamReader r, string firstLine, SatelliteNumber satNum, bool availableOnly = true) { Sp3Section sec = new Sp3Section(); sec.Time = ParseTime(firstLine); //if (header.OrbitType == SatelliteType.C)//如果是历元,需要转换为北斗时间来计算。 { // time = time + 14; } int satLineCount = 1; for (int i = 0; i < header.NumberOfSatellites * satLineCount; i++) { firstLine = r.ReadLine(); if (firstLine == "EOF") { break; } var firstChar = firstLine.Substring(0, 1); var firstTwoChar = firstLine.Substring(0, 2); //判断是否内容 if (firstTwoChar == RecordHeadSymbol) { return(ReadSection(header, r, firstLine, satNum, availableOnly)); } //解析卫星编号 var prn = SatelliteNumber.Parse(firstLine.Substring(1, 3)); if (satNum != SatelliteNumber.Default && !satNum.Equals(prn)) { continue; } //过滤指定卫星否 if (!sec.Contains(prn)) { sec[prn] = new Ephemeris(prn, sec.Time) { Source = header.SourceName }; } var rec = sec[prn]; if (firstChar == PositionClockSymbol || firstTwoChar == EphemerisPosition) { double clock; var xyz = ParseLine(firstLine, out clock); //单位转换为米 rec.XYZ = xyz * 1000.0; if (clock == 999999.999999) //continue; { clock = GnssConst.MaxClockError; if (availableOnly) { sec.Remove(prn); continue; } } //????????????是否该标记卫星状态糟糕 //崔阳,修改,应直接去除该卫星,不能使用。 rec.ClockBias = clock * 1e-6; if (firstLine.Length > 70) { ParsePosStd(firstLine, rec); } } else if (firstChar == VelocityClockSymbol || firstTwoChar == EphemerisVelocity) { satLineCount = 2; double dclock; var xyz = ParseLine(firstLine, out dclock); rec.XyzDot = xyz * 0.1; rec.ClockDrift = dclock * 1e-10; } } return(sec); }
private void UpdateSky() { // Update ephemeris model. #if XBOX _ephemeris.Time = new DateTimeOffset(_time.Ticks, TimeSpan.Zero); #else _ephemeris.Time = _time; #endif _ephemeris.Update(); // Update rotation of milky way. We also need to add an offset because the // cube map texture is rotated. _milkyWayNode.PoseWorld = new Pose( (Matrix33F)_ephemeris.EquatorialToWorld.Minor * Matrix33F.CreateRotationZ(ConstantsF.PiOver2 + -0.004f) * Matrix33F.CreateRotationX(ConstantsF.PiOver2 + -0.002f)); // Update rotation of stars. _starfieldNode.PoseWorld = new Pose((Matrix33F)_ephemeris.EquatorialToWorld.Minor); // Update direction of sun. SunDirection = (Vector3F)_ephemeris.SunDirectionRefracted; var sunUp = SunDirection.Orthonormal1; _sunNode.LookAt(SunDirection, sunUp); // Update direction of moon. var moonDirection = (Vector3F)_ephemeris.MoonPosition.Normalized; var moonUp = (Vector3F)_ephemeris.EquatorialToWorld.TransformDirection(Vector3D.Up); _moonNode.LookAt(moonDirection, moonUp); // The moon needs to know the sun position and brightness to compute the moon phase. _moonNode.SunDirection = (Vector3F)_ephemeris.SunPosition.Normalized; _moonNode.SunLight = Ephemeris.ExtraterrestrialSunlight * SunlightScale; // The ScatteringSky needs the sun direction and brightness to compute the sky colors. _scatteringSkyNode.SunDirection = SunDirection; _scatteringSkyNode.SunColor = Ephemeris.ExtraterrestrialSunlight * ScatteringSkyLightScale; // Update the light directions. _sunlightNode.LookAt(-SunDirection, sunUp); _moonlightNode.LookAt(-moonDirection, moonUp); // The ScatteringSkyNode can compute the actual sunlight. SunLight = _scatteringSkyNode.GetSunlight(); // Undo the ScatteringSkyLightScale and apply a custom scale for the sunlight. SunLight = SunLight / ScatteringSkyLightScale * SunlightScale; // The ScatteringSkyNode can also compute the ambient light by sampling the // sky hemisphere. AmbientLight = _scatteringSkyNode.GetAmbientLight(256); AmbientLight = AmbientLight / ScatteringSkyLightScale * SunlightScale; // Desaturate the ambient light to avoid very blue shadows. AmbientLight = InterpolationHelper.Lerp( new Vector3F(Vector3F.Dot(AmbientLight, GraphicsHelper.LuminanceWeights)), AmbientLight, 0.5f); // The Ephemeris model can compute the actual moonlight. Vector3F moonlight, moonAmbient; Ephemeris.GetMoonlight( _scatteringSkyNode.ObserverAltitude, 2.2f, _ephemeris.MoonPosition, (float)_ephemeris.MoonPhaseAngle, out moonlight, out moonAmbient); moonlight *= MoonlightScale; moonAmbient *= MoonlightScale; // Scale sun light to 0 at horizon. var directionalLightColor = SunLight; directionalLightColor *= MathHelper.Clamp(SunDirection.Y / 0.1f, 0, 1); var directionalLight = ((DirectionalLight)_sunlightNode.Light); directionalLight.Color = directionalLightColor; ((DirectionalLight)_moonlightNode.Light).Color = moonlight; ((AmbientLight)_ambientLightNode.Light).Color = AmbientLight + moonAmbient + LightPollution; // Use the sunlight color to create a bright sun disk. var sunDiskColor = SunLight; sunDiskColor.TryNormalize(); _sunNode.GlowColor0 = sunDiskColor * Ephemeris.ExtraterrestrialSunlight.Length * SunlightScale * 10; if (_enableClouds) { // Update lighting info of cloud layer nodes. _cloudLayerNode0.SunDirection = SunDirection; _cloudLayerNode0.SunLight = SunLight; _cloudLayerNode0.AmbientLight = AmbientLight; // The second cloud layer uses simple unlit clouds (only ambient lighting). _cloudLayerNode1.SunDirection = SunDirection; _cloudLayerNode1.SunLight = Vector3F.Zero; _cloudLayerNode1.AmbientLight = AmbientLight + SunLight; // Use the cloud map as the texture for the directional light to create cloud shadows. if (EnableCloudShadows) { directionalLight.Texture = _cloudLayerNode0.CloudMap.Texture; } else { directionalLight.Texture = null; } // Compute a texture offset so that the current sun position and the projected cloud // shadows match. // Since sky dome is always centered on the camera, position the sunlight node in // line with the camera. var cameraPosition = _cameraObject.CameraNode.PoseWorld.Position; var upVector = Vector3F.AreNumericallyEqual(SunDirection, Vector3F.UnitZ) ? Vector3F.UnitY : Vector3F.UnitZ; _sunlightNode.LookAt(cameraPosition + SunDirection, cameraPosition, upVector); // Choose a scale for the cloud shadows. directionalLight.TextureScale = new Vector2F(-1000); // Get the scaled texture offset for the sun direction. directionalLight.TextureOffset = _cloudLayerNode0.GetTextureCoordinates(SunDirection) * directionalLight.TextureScale; } // The ScatteringSkyNode can also estimate a fog color by sampling the horizon colors. Vector3F fogColor = _scatteringSkyNode.GetFogColor(256, FogSampleAngle); // Desaturate the fog color. fogColor = InterpolationHelper.Lerp( new Vector3F(Vector3F.Dot(fogColor, GraphicsHelper.LuminanceWeights)), fogColor, FogSaturation); // Find any FogNode in the scene and update its fog color. foreach (var fogNode in ((Scene)_scene).GetSubtree().OfType <FogNode>()) { var fog = fogNode.Fog; fog.Color0 = fog.Color1 = new Vector4F(fogColor, 1); fog.ScatteringSymmetry = FogScatteringSymmetry; } // TODO: If the fog is dense, reduce the direct light and increase the ambient light. }