public static IAgCrdnVector GetVectorBetweenObjects(IAgStkObject parentObject, IAgStkObject fromObject, IAgStkObject toObject, string vectorName = "", bool addDisplay = false) { IAgCrdnVectorFactory vectorFactory = parentObject.Vgt.Vectors.Factory; string newVectorName; if (String.IsNullOrEmpty(vectorName)) { newVectorName = "To_" + toObject.InstanceName; } else { newVectorName = vectorName; } IAgCrdnVectorDisplacement displacementVector; if (fromObject.Vgt.Vectors.Contains(newVectorName)) { displacementVector = fromObject.Vgt.Vectors[newVectorName] as IAgCrdnVectorDisplacement; } else { displacementVector = vectorFactory.CreateDisplacementVector(newVectorName, fromObject.Vgt.Points["Center"], toObject.Vgt.Points["Center"]); } if (addDisplay) { StkAssistant.DisplayVector((displacementVector as IAgCrdn).Name, parentObject, System.Drawing.Color.Yellow); } return(displacementVector as IAgCrdnVector); }
public static PointPairList CdmPlottableList(string parameterName, params CdmConjunction[] conjunctions) { List <KeyValuePair <string, double> > stuff = new List <KeyValuePair <string, double> >(); foreach (CdmConjunction cdm in conjunctions) { switch (parameterName) { case "Miss Distance": stuff.Add(new KeyValuePair <string, double>(cdm.CreationDate, cdm.MissDistance)); break; case "TCA": stuff.Add(new KeyValuePair <string, double>(cdm.CreationDate, StkAssistant.ParseISOYMD(cdm.TCA).ToOADate())); break; case "Probability": stuff.Add(new KeyValuePair <string, double>(cdm.CreationDate, cdm.Probability)); break; case "Sigma Dilution": stuff.Add(new KeyValuePair <string, double>(cdm.CreationDate, cdm.SigmaDilution)); break; } } stuff = stuff.OrderBy(pair => StkAssistant.ParseISOYMD(pair.Key).ToOADate()).ToList(); PointPairList cdmEvolve = ZedGraphAssistant.ArrayToPlottableList(stuff.Select(kvp => kvp.Key).ToArray(), stuff.Select(kvp => kvp.Value).ToArray()); return(cdmEvolve); }
private void SetSatVizOptions(string tempName, string colorConnectString) { #region Viz string command, cmdResult; command = String.Format("Graphics */Satellite/{0} SetColor {1}", tempName, colorConnectString); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("Graphics */Satellite/{0} Basic Orbit On", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("Graphics */Satellite/{0} Basic LineWidth 2", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} Model Show Off", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} Point Show On Size 6", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} ModelDetail Off", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} Pass3D OrbitLead OnePass", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} Pass3D OrbitTrail OnePass", tempName); StkAssistant.TryConnect(command, out cmdResult); if (isGeoRegime) { command = String.Format("VO */Satellite/{0} OrbitSystem Modify System \"FixedByWindow\" Color Default Show On", tempName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} OrbitSystem Modify System \"InertialByWindow\" Show Off", tempName); StkAssistant.TryConnect(command, out cmdResult); } #endregion Viz }
private static string AverageTime(params string[] timesISOYMD) { DateTime[] dateTimes = timesISOYMD.Select(t => StkAssistant.ParseISOYMD(t)).ToArray(); DateTime avgTime = AverageTime(dateTimes); string isoYMD = avgTime.Year.ToString() + "-" + avgTime.Month.ToString("D2") + "-" + avgTime.Day.ToString("D2") + "T" + avgTime.ToLongTimeString(); return(isoYMD); }
private static bool WithinTimeframe(string timeISOYMD, string windowCenterISOYMD, double secondsFromCenter) { DateTime time = StkAssistant.ParseISOYMD(timeISOYMD); DateTime windowCenter = StkAssistant.ParseISOYMD(timeISOYMD); bool value = WithinTimeframe(time, windowCenter, secondsFromCenter); return(value); }
public static PointPairList ArrayToPlottableList(string[] times, double[] values) { if (times.Length != values.Length) { return(null); } PointPairList points = new PointPairList(times.Select(t => StkAssistant.ParseISOYMD(t).ToOADate()).ToArray(), values); return(points); }
public static GraphPane NewBlankGraph(string startISOYMD, string stopISOYMD, string title) { GraphPane plot = new GraphPane(new RectangleF(0, 0, 1920, 1080), title, "Date/Time (UTC)", "Distance (m)"); plot.Title.FontSpec.Family = "Verdana"; plot.Title.FontSpec.Size = 12; // Set up x axis plot.XAxis.Type = AxisType.Date; plot.XAxis.Scale.Format = "MMM d\nHH:mm"; plot.XAxis.Scale.MajorUnit = DateUnit.Day; plot.XAxis.Scale.MinorUnit = DateUnit.Hour; plot.XAxis.Scale.MinorStep = 1; if (!string.IsNullOrEmpty(startISOYMD) && !string.IsNullOrEmpty(stopISOYMD)) { DateTime startDate = StkAssistant.ParseISOYMD(startISOYMD); DateTime endDate = StkAssistant.ParseISOYMD(stopISOYMD); plot.XAxis.Scale.Min = startDate.ToOADate(); plot.XAxis.Scale.Max = endDate.ToOADate(); } else { plot.XAxis.Scale.MinAuto = true; plot.XAxis.Scale.MaxAuto = true; } plot.XAxis.Title.FontSpec.Family = "Verdana"; plot.XAxis.Title.FontSpec.Size = 10; plot.XAxis.Scale.FontSpec.Family = "Verdana"; plot.XAxis.Scale.FontSpec.Size = 6; plot.XAxis.Scale.FontSpec.Angle = 0; plot.XAxis.MajorGrid.IsVisible = true; // Set up y axis plot.YAxis.Type = AxisType.Linear; //if (geoRegime) // plot.YAxis.Scale.Format = "N0"; //else // plot.YAxis.Scale.Format = "N1"; plot.YAxis.Scale.Mag = 0; plot.YAxis.Scale.MinAuto = true; //plot.YAxis.Scale.Min = 0; plot.YAxis.Scale.MaxAuto = true; plot.YAxis.Title.FontSpec.Family = "Verdana"; plot.YAxis.Title.FontSpec.Size = 10; plot.YAxis.Scale.FontSpec.Family = "Verdana"; plot.YAxis.Scale.FontSpec.Size = 6; plot.YAxis.Scale.Align = AlignP.Inside; plot.YAxis.MajorGrid.IsVisible = true; // Generate and position legend plot.Legend.Position = LegendPos.BottomCenter; plot.Legend.FontSpec.Family = "Verdana"; plot.Legend.FontSpec.Size = 7; return(plot); }
public static object[] GetTimeOfMinAndValue(IAgCrdnVector vector) { IAgStkObject parentObject = StkAssistant.Root.GetObjectFromPath("*/" + (vector as IAgCrdn).QualifiedPath.Split(' ')[0]); //Create new scalar to monitor Vector Magnitude value string newVgtBaseName = (vector as IAgCrdn).Name; string scalarVectorMagName = StkAssistant.GetUniqueAWBName(newVgtBaseName, parentObject, AgECrdnKind.eCrdnKindCalcScalar); IAgCrdnCalcScalar vectorMagnitudeScalar = parentObject.Vgt.CalcScalars.Factory.Create( scalarVectorMagName, "temp", AgECrdnCalcScalarType.eCrdnCalcScalarTypeVectorMagnitude); (vectorMagnitudeScalar as IAgCrdnCalcScalarVectorMagnitude).InputVector = vector; IAgCrdnCalcScalar minRange = (vectorMagnitudeScalar as IAgCrdn).EmbeddedComponents[(vectorMagnitudeScalar as IAgCrdn).Name + ".Min"] as IAgCrdnCalcScalar; IAgCrdnEvent timeOfMinRange = (vectorMagnitudeScalar as IAgCrdn).EmbeddedComponents[(vectorMagnitudeScalar as IAgCrdn).Name + ".TimeOfMin"] as IAgCrdnEvent; string tca = timeOfMinRange.FindOccurrence().Epoch.ToString(); double minRangeValue = minRange.Evaluate(tca).Value; return(new object[] { tca, minRangeValue }); }
public static GraphPane CreateGraph(string title, string tcaISOYMD, Graphics g, PointPairList[] points, string[] pointListNames, TextObj[] comments, bool isDashedLine = false) { ColorCounter = -1; GraphPane graph; if (!string.IsNullOrEmpty(tcaISOYMD)) { IAgDate tca = StkAssistant.Root.ConversionUtility.NewDate("ISO-YMD", tcaISOYMD); graph = NewBlankGraph(tca.Subtract("day", 1).Format("ISO-YMD"), tca.Add("day", 1).Format("ISO-YMD"), title); } else { graph = NewBlankGraph(null, null, title); } graph.Legend.IsVisible = true; graph.Legend.Draw(g, graph, .75f); foreach (TextObj comment in comments) { graph.GraphObjList.Add(comment); } for (int i = 0; i < points.Length; i++) { LineItem newCurve = new LineItem(pointListNames[i], points[i], NextColor, isDashedLine ? NextSymbol : SymbolType.None, isDashedLine ? 2.0f : 5.0f); newCurve.Line.Style = isDashedLine ? System.Drawing.Drawing2D.DashStyle.Dash : System.Drawing.Drawing2D.DashStyle.Solid; graph.CurveList.Add(newCurve); } graph.AxisChange(g); if (!string.IsNullOrEmpty(tcaISOYMD)) { PointPairList tcaLine = new PointPairList(); tcaLine.Add(StkAssistant.ParseISOYMD(tcaISOYMD).ToOADate(), graph.YAxis.Scale.Min); tcaLine.Add(StkAssistant.ParseISOYMD(tcaISOYMD).ToOADate(), graph.YAxis.Scale.Max); graph.AddCurve("", tcaLine, Color.Black); } //graph.GetImage().Save(path, ImageFormat.Png); return(graph); }
public GraphPane GraphCdmVsTle(Graphics g) { try { if (StkTleSatellitePath == null) { CreateTleSatellite(); } if (StkTleSatellitePath != null) { TextObj stktcaComment = ZedGraphAssistant.CreateGraphLabel("Time of Min Range: " + StkCdmTleTimeOfMinRange, .01f, .01f, Color.Black); TextObj stkmissComment = ZedGraphAssistant.CreateGraphLabel("Minimum Range: " + StkCdmTleMinimumRange.ToString(), .01f, .05f, Color.Black); TextObj tcaComment = ZedGraphAssistant.CreateGraphLabel("TCA : " + this.EpochISOYMD, 1f, .01f, AlignH.Right, AlignV.Top, Color.Black); TextObj tcaRangeComment = ZedGraphAssistant.CreateGraphLabel("Range at TCA : " + StkCdmTleDiffAtCdmTca.ToString(), 1f, .05f, AlignH.Right, AlignV.Top, Color.Black); TextObj[] comments = new TextObj[] { stktcaComment, stkmissComment, tcaComment, tcaRangeComment }; StateCompare.RICResults ricOverTime = StateCompare.GetRICDifferenceOverTime(this.StkCdmSatellitePath, this.StkTleSatellitePath, this.EpochISOYMD); PointPairList pplR = ZedGraphAssistant.ArrayToPlottableList(ricOverTime.Times, ricOverTime.R); PointPairList pplI = ZedGraphAssistant.ArrayToPlottableList(ricOverTime.Times, ricOverTime.I); PointPairList pplC = ZedGraphAssistant.ArrayToPlottableList(ricOverTime.Times, ricOverTime.C); PointPairList pplRange = ZedGraphAssistant.ArrayToPlottableList(ricOverTime.Times, ricOverTime.Range); PointPairList pplTimeOfMinRange = new PointPairList(); pplTimeOfMinRange.Add(StkAssistant.ParseISOYMD(StkCdmTleTimeOfMinRange).ToOADate(), -5 * StkCdmTleMinimumRange); pplTimeOfMinRange.Add(StkAssistant.ParseISOYMD(StkCdmTleTimeOfMinRange).ToOADate(), 5 * StkCdmTleMinimumRange); PointPairList[] ppl = new PointPairList[] { pplR, pplI, pplC, pplRange, pplTimeOfMinRange }; string[] pplNames = new string[] { "Radial", "In-Track", "Cross-Track", "Range", "" }; return(ZedGraphAssistant.CreateGraph("Comparison: " + SatName + " CDM to TLE", this.EpochISOYMD, g, ppl, pplNames, comments)); } return(null); } catch { return(null); } }
public static IAgCrdnAngle CreateAngleBetweenVectors(IAgCrdnVector fromVector, IAgCrdnVector toVector, IAgStkObject parentObject, string name = "", bool addDisplay = false) { IAgCrdnAngleFactory angleFactory = parentObject.Vgt.Angles.Factory; string newAngleName; if (!String.IsNullOrEmpty(name)) { newAngleName = name; } else { newAngleName = "From_" + (fromVector as IAgCrdn).Name + "_To_" + (toVector as IAgCrdn).Name; } IAgCrdnAngleBetweenVectors angle; if (parentObject.Vgt.Angles.Contains(newAngleName)) { angle = parentObject.Vgt.Angles[newAngleName] as IAgCrdnAngleBetweenVectors; } else { angle = angleFactory.Create(newAngleName, newAngleName, AgECrdnAngleType.eCrdnAngleTypeBetweenVectors) as IAgCrdnAngleBetweenVectors; angle.FromVector.SetVector(fromVector); angle.ToVector.SetVector(toVector); } if (addDisplay) { StkAssistant.DisplayAngle(newAngleName, parentObject, System.Drawing.Color.Yellow); } return(angle as IAgCrdnAngle); }
public bool CreateEphSatellite(string ephemerisPath = null) { if (!string.IsNullOrEmpty(ephemerisPath) && File.Exists(ephemerisPath)) { EphemerisFile = ephemerisPath; } else if (!string.IsNullOrEmpty(EphemerisFile) && File.Exists(EphemerisFile)) { ephemerisPath = EphemerisFile; } else { return(false); } string cmdResult; string command = "BatchGraphics * On"; StkAssistant.TryConnect(command, out cmdResult); bool satCreated = false; try { string color; string tempName; if (isPrimary) { tempName = "ephPrimary_" + SafeSatName; color = "#00FF00"; } else { tempName = "ephSecondary_" + SafeSatName; color = "#FF9900"; } if (!string.IsNullOrEmpty(ephemerisPath) && File.Exists(ephemerisPath)) { if (!StkAssistant.Root.CurrentScenario.Children.Contains(AgESTKObjectType.eSatellite, tempName)) { StkAssistant.Root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, tempName); } command = String.Format("SetState */Satellite/{0} FromFile \"{1}\"", tempName, ephemerisPath); satCreated = StkAssistant.TryConnect(command, out cmdResult); } if (satCreated) { _stkEphObjName = tempName; SetSatVizOptions(tempName, color); } } finally { command = "BatchGraphics * Off"; StkAssistant.TryConnect(command, out cmdResult); } return(satCreated); }
public bool CreateTleSatellite(string tlePath = null) { string cmdResult; string command = "BatchGraphics * On"; StkAssistant.TryConnect(command, out cmdResult); bool satCreated = false; try { string color; string tempName; if (isPrimary) { tempName = "tlePrimary_" + SafeSatName; color = "#00FF00"; } else { tempName = "tleSecondary_" + SafeSatName; color = "#FF9900"; } if (!StkAssistant.Root.CurrentScenario.Children.Contains(AgESTKObjectType.eSatellite, tempName)) { StkAssistant.Root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, tempName); } //If a file is provided, pull from it if (!string.IsNullOrEmpty(tlePath) && File.Exists(tlePath)) { command = String.Format("SetState */Satellite/{0} SGP4 UseScenarioInterval 60.0 {1} TLESource Automatic Source File \"{2}\" UseTLE All SwitchMethod Midpoint UseCatalogModel", tempName, SSC.ToString(), tlePath); satCreated = StkAssistant.TryConnect(command, out cmdResult); } //If not created yet, try to get from the AGI server if (!satCreated) { command = String.Format("SetState */Satellite/{0} SGP4 UseScenarioInterval 60.0 {1} TLESource Automatic Source AGIServer UseTLE All SwitchMethod Midpoint UseCatalogModel", tempName, SSC.ToString()); satCreated = StkAssistant.TryConnect(command, out cmdResult); } //If not created yet, try to get from the local default file if (!satCreated) { command = String.Format("SetState */Satellite/{0} SGP4 UseScenarioInterval 60.0 {1} TLESource Automatic Source DefaultFile UseTLE All SwitchMethod Midpoint UseCatalogModel", tempName, SSC.ToString()); satCreated = StkAssistant.TryConnect(command, out cmdResult); } if (satCreated) { _stkTleObjName = tempName; SetSatVizOptions(tempName, color); } } finally { command = "BatchGraphics * Off"; StkAssistant.TryConnect(command, out cmdResult); } return(satCreated); }
public bool CreateCdmSatellite(bool zoomTo = false) { string cmdResult; string command = "BatchGraphics * On"; StkAssistant.TryConnect(command, out cmdResult); try { #region New Satellite string color; string zonal = ""; string tesseral = ""; if (isPrimary) { _stkCdmSatelliteName = "cdmPrimary_" + SafeSatName; color = "#00FF00"; } else { _stkCdmSatelliteName = "cdmSecondary_" + SafeSatName; color = "#FF9900"; } string position = String.Format("{0} {1} {2}", XPos, YPos, ZPos); // m double posMag = VecMagS(position); string velocity = String.Format("{0} {1} {2}", XVel, YVel, ZVel); // m/s if (posMag < 1) { return(false); } if (!StkAssistant.Root.CurrentScenario.Children.Contains(AgESTKObjectType.eSatellite, StkCdmSatelliteName)) { StkAssistant.Root.CurrentScenario.Children.New(AgESTKObjectType.eSatellite, StkCdmSatelliteName); } string stkReferenceFrame = "Fixed"; switch (this.ReferenceFrame) { case "ITRF": stkReferenceFrame = "Fixed"; break; case "ICRF": case "GCRF": stkReferenceFrame = "ICRF"; break; case "EME2000": stkReferenceFrame = "J2000"; break; case "MeanOfDate": stkReferenceFrame = "MeanOfDate"; break; case "MeanOfEpoch": stkReferenceFrame = "MeanOfEpoch"; break; case "TrueOfDate": stkReferenceFrame = "TrueOfDate"; break; case "TrueOfEpoch": stkReferenceFrame = "TrueOfEpoch"; break; case "B1950": stkReferenceFrame = "B1950"; break; case "TEMEOfDate": stkReferenceFrame = "TEMEOfDate"; break; case "TEMEOfEpoch": stkReferenceFrame = "TEMEOfEpoch"; break; case "AlignmentAtEpoch": stkReferenceFrame = "AlignmentAtEpoch"; break; } command = String.Format("SetStateIgnoreCB */Satellite/{0} Cartesian HPOP \"{1}\" \"{2}\" 10 {3} \"{4}\" {5} {6}", StkCdmSatelliteName, (StkAssistant.Root.CurrentScenario as IAgScenario).StartTime, (StkAssistant.Root.CurrentScenario as IAgScenario).StopTime, stkReferenceFrame, EpochISOYMD, position, velocity); if (!StkAssistant.TryConnect(command, out cmdResult)) { return(false); // object with no state } #endregion New Satellite SetSatVizOptions(StkCdmSatelliteName, color); #region Force Model if (!string.IsNullOrEmpty(GeopotentialModel)) { // Set geopotential: EGM-96, ... Regex regex = new Regex(@"(EGM-96):\s+(\d+)D\s+(\d+)O"); Match match = regex.Match(GeopotentialModel); if (match.Success) { if (match.Groups[1].Value != "EGM-96") { //outputToDebugLog("WARNING: " + match.Groups[1].Value + " gravitational model"); //warning = true; } zonal = match.Groups[2].Value; tesseral = match.Groups[3].Value; command = String.Format("HPOP */Satellite/{0} Force Gravity \"{1}STKData\\CentralBodies\\Earth\\WGS84_EGM96.grv\" {2} {3}", StkCdmSatelliteName, StkAssistant.StkInstallDirectory, zonal, tesseral); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("HPOP */Satellite/{0} Covariance Gravity {1} {2}", StkCdmSatelliteName, zonal, tesseral); StkAssistant.TryConnect(command, out cmdResult); } } else { //outputToDebugLog(String.Format("WARNING: Undefined gravitational model: {0}", geopotentialModel[index].InnerText)); //warning = true; } if (!string.IsNullOrEmpty(LunarsolarPerturbations)) { string nBody = LunarsolarPerturbations.ToUpper(); if ((nBody != "NONE") || ((isEphemerisBased) && (isGeoRegime))) { if (nBody.Contains("SUN")) { command = String.Format("HPOP */Satellite/{0} Force ThirdBodyGravity Sun On JPLDEFile", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } if (nBody.Contains("MOON")) { command = String.Format("HPOP */Satellite/{0} Force ThirdBodyGravity Moon On JPLDEFile", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } } } else { command = String.Format("HPOP */Satellite/{0} Force ThirdBodyGravity Sun Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("HPOP */Satellite/{0} Force ThirdBodyGravity Moon Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } if (!string.IsNullOrEmpty(SolidEarthTidesPerturbation) && SolidEarthTidesPerturbation.ToUpper() == "YES") { command = String.Format("HPOP */Satellite/{0} Force SolidTides Full", StkCdmSatelliteName); // Permanent only or full tide? StkAssistant.TryConnect(command, out cmdResult); } else { command = String.Format("HPOP */Satellite/{0} Force SolidTides Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } command = String.Format("HPOP */Satellite/{0} Force OceanTides Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); if (!string.IsNullOrEmpty(DragModel)) { bool noDrag = (StkAssistant.GetSatellitePerigee(StkCdmSatellitePath, EpochISOYMD) > _leoLimit * 1E3); // m if (!"JACCHIA70DCA|NONE".Contains(DragModel)) { //outputToDebugLog(String.Format("WARNING: Undefined drag model: {0}", dragModel[index].InnerText)); //warning = true; } if ((DragModel.ToUpper() == "NONE") || noDrag) { command = String.Format("HPOP */Satellite/{0} Drag Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } else { command = String.Format("HPOP */Satellite/{0} Drag On {1} {2} \"Jacchia 1970\" File \"{3}SpaceWeather-v1.2.txt\"", StkCdmSatelliteName, Math.Sign(BallisticCoefficient).ToString("F1"), Math.Abs(BallisticCoefficient).ToString("F6"), StkAssistant.StkDataDirectory); StkAssistant.TryConnect(command, out cmdResult); } } if (!string.IsNullOrEmpty(SolarRadiationPerturbation) && SolarRadiationPerturbation.ToUpper() == "YES") { command = String.Format("HPOP */Satellite/{0} Force SRP On Model Spherical {1} {2} ShadowModel Cylindrical BoundaryMitigation On", StkCdmSatelliteName, Math.Sign(SolarRadiationCoefficient).ToString("F1"), Math.Abs(SolarRadiationCoefficient).ToString("F6")); StkAssistant.TryConnect(command, out cmdResult); } else { command = String.Format("HPOP */Satellite/{0} Force SRP Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } command = String.Format("HPOP */Satellite/{0} Force RadiationPressure Albedo Off Thermal Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("HPOP */Satellite/{0} Integrator IntegMethod RKF78 StepControl RelativeError 1E-13", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); // Set HPOP Options //stkExecute(String.Format("HPOP */Satellite/{0} Options Mass " + FloatToStr(mass)), satObj)); #endregion Force Model #region Covariance // Set up covariance command = String.Format("HPOP */Satellite/{0} Covariance On", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("HPOP */Satellite/{0} Covariance Frame LVLH", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("HPOP */Satellite/{0} Covariance Consider Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); // Force non-zero principal components if (xx == 0) { xx = small; } if (yy == 0) { yy = small; } if (zz == 0) { zz = small; } if (VxVx == 0) { VxVx = small; } if (VyVy == 0) { VyVy = small; } if (VzVz == 0) { VzVz = small; } string ldMatrix = xx + " "; ldMatrix += yx + " " + yy + " "; ldMatrix += zx + " " + zy + " " + zz + " "; ldMatrix += Vxx + " " + Vxy + " " + Vxz + " " + VxVx + " "; ldMatrix += Vyx + " " + Vyy + " " + Vyz + " " + VyVx + " " + VyVy + " "; ldMatrix += Vzx + " " + Vzy + " " + Vzz + " " + VzVx + " " + VzVy + " " + VzVz; string covCommand = String.Format("HPOP */Satellite/{0} Covariance PosVel {1}", StkCdmSatelliteName, ldMatrix); string covColor = color; if (!StkAssistant.TryConnect(covCommand, out cmdResult)) { //notes.Add("<span style=\"color:red\">WARNING: " + satObjName.Substring(3) + " CDM covariance matrix not positive definite</span>"); string zero = "0"; string nonzero = "1000"; ldMatrix = nonzero + " "; ldMatrix += zero + " " + nonzero + " "; ldMatrix += zero + " " + zero + " " + nonzero + " "; ldMatrix += zero + " " + zero + " " + zero + " " + nonzero + " "; ldMatrix += zero + " " + zero + " " + zero + " " + zero + " " + nonzero + " "; ldMatrix += zero + " " + zero + " " + zero + " " + zero + " " + zero + " " + nonzero; covColor = "#FF0000"; covCommand = String.Format("HPOP */Satellite/{0} Covariance PosVel {1}", StkCdmSatelliteName, ldMatrix); StkAssistant.TryConnect(covCommand, out cmdResult); command = String.Format("VO */Satellite/{0} Covariance Basic Show Off", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); } else { command = String.Format("VO */Satellite/{0} Covariance Scale 3.0", StkCdmSatelliteName); StkAssistant.TryConnect(command, out cmdResult); command = String.Format("VO */Satellite/{0} Covariance Basic Show On Color {1} LineWidth 2 Translucency 50", StkCdmSatelliteName, covColor); StkAssistant.TryConnect(command, out cmdResult); } #endregion Covariance command = String.Format("Propagate */Satellite/{0} {1} {2}", StkCdmSatelliteName, StkAssistant.ScenarioStartTime, StkAssistant.ScenarioStopTime); StkAssistant.TryConnect(command, out cmdResult); if (zoomTo) { StkAssistant.TryConnect(String.Format("VO * ViewFromTo Normal From */Satellite/{0}", StkCdmSatelliteName), out cmdResult); } } finally { command = "BatchGraphics * Off"; StkAssistant.TryConnect(command, out cmdResult); } return(true); }
public void EstimateProbability() { StkAssistant.SetAnalysisIntervalFromTCA(this.Primary.EpochISOYMD); string primaryPath = Primary.BaselineObjectPath; string primaryType = Primary.BaselineObjectType; string primaryName = primaryPath.Substring(primaryPath.LastIndexOf("/") + 1); string secondaryPath = Secondary.BaselineObjectPath; string secondaryName = secondaryPath.Substring(secondaryPath.LastIndexOf("/") + 1); string catName = "CAT_" + primaryName; int counter = 0; while (StkAssistant.Root.CurrentScenario.Children.Contains(AgESTKObjectType.eAdvCat, catName)) { catName = "CAT_" + primaryName + "_" + (++counter).ToString(); } IAgStkObject cat = StkAssistant.Root.CurrentScenario.Children.New(AgESTKObjectType.eAdvCat, catName); string cmdResult; StkAssistant.TryConnect("Save / " + primaryPath, out cmdResult); StkAssistant.TryConnect("Save / " + secondaryPath, out cmdResult); StkAssistant.TryConnect("ACAT */AdvCAT/" + catName + " TimePeriod \"" + StkAssistant.Scenario.StartTime + "\" \"" + StkAssistant.Scenario.StopTime + "\"", out cmdResult); StkAssistant.TryConnect("ACAT */AdvCAT/" + catName + " Primary Add \"" + primaryName + ".sa\" Cov", out cmdResult); StkAssistant.TryConnect("ACAT */AdvCAT/" + catName + " Secondary Add \"" + secondaryName + ".sa\" Cov", out cmdResult); StkAssistant.TryConnect("ACAT */AdvCAT/" + catName + " Compute ShowProgress On", out cmdResult); StkAssistant.TryConnect("VO */AdvCAT/" + catName + " AdvCATAttributes ShowSecondary On ShowAllSecondary On", out cmdResult); //StkAssistant.TryConnect("ReportCreate */AdvCAT/" + catName + " Type Display Style \"Close Approach By Min Range\"", out cmdResult); StkAssistant.TryConnect("ACATEvents_RM */AdvCAT/" + catName, out cmdResult); string catTCA; if (!cmdResult.Equals("No events found.")) { catTCA = cmdResult.Split(',')[5]; IAgStkObject catObject = StkAssistant.Root.GetObjectFromPath("*/AdvCAT/" + catName); IAgDataPrvInterval catDP = cat.DataProviders["Events by Min Range"] as IAgDataPrvInterval; IAgDrResult catResult = catDP.Exec(StkAssistant.Scenario.StartTime, StkAssistant.Scenario.StopTime); double catMaxProb = (double)catResult.DataSets.GetDataSetByName("Max Collision Probability").GetValues().GetValue(0); double catSigmaDilution = (double)catResult.DataSets.GetDataSetByName("Sigma Dilution Threshold").GetValues().GetValue(0); if (Probability == 0) { Probability = catMaxProb; } if (SigmaDilution == 0) { SigmaDilution = Math.Round(catSigmaDilution, 3); } } cat.Unload(); }
public void GenerateStkCdmObjects() { StkAssistant.SetAnalysisIntervalFromTCA(this.Primary.EpochISOYMD); this.Primary.CreateCdmSatellite(true); this.Secondary.CreateCdmSatellite(); }
public static RICResults GetRICDifferenceOverTime(string sat1Path, string sat2Path, string epochISOYMD) { IAgDate tca = StkAssistant.Root.ConversionUtility.NewDate("ISO-YMD", epochISOYMD); IAgStkObject primary, secondary; try { primary = StkAssistant.Root.GetObjectFromPath(sat1Path); secondary = StkAssistant.Root.GetObjectFromPath(sat2Path); } catch { return(new RICResults()); } double period1 = StkAssistant.GetSatellitePeriod(primary.Path, epochISOYMD); double period2 = StkAssistant.GetSatellitePeriod(secondary.Path, epochISOYMD); double period = (period1 + period2) / 2; IAgDataProviderInfo dpInfo = primary.DataProviders["RIC Coordinates"]; IAgDataProvider dataProvider = primary.DataProviders["RIC Coordinates"] as IAgDataProvider; dataProvider.PreData = secondary.Path.Replace(StkAssistant.Root.CurrentScenario.Path, ""); IAgDataPrvTimeVar dpTimeVarying = dataProvider as IAgDataPrvTimeVar; Array elements = new object[] { "Time", "Radial", "In-Track", "Cross-Track", "Range" }; IAgDrResult dpResult = dpTimeVarying.ExecElements( tca.Subtract("sec", .5 * period).Format("ISO-YMD"), tca.Add("sec", .5 * period).Format("ISO-YMD"), 10, elements); RICResults ricResults = new RICResults(); foreach (IAgDrDataSet dataset in dpResult.DataSets) { if (dataset.ElementName.Equals("Time")) { List <string> times = new List <string>(); foreach (object item in dataset.GetValues()) { times.Add(item.ToString()); } ricResults.Times = times.ToArray(); } else { List <double> values = new List <double>(); foreach (object item in dataset.GetValues()) { values.Add((double)item); } switch (dataset.ElementName) { case "Radial": ricResults.R = values.ToArray(); break; case "In-Track": ricResults.I = values.ToArray(); break; case "Cross-Track": ricResults.C = values.ToArray(); break; case "Range": ricResults.Range = values.ToArray(); break; default: break; } } } return(ricResults); }
public static CdmConjunction ReadCdmXmlByTag(string xmlPath, out string error) { error = ""; try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlPath); CdmConjunction conjunction = new CdmConjunction(); CdmSatellite[] sats = new CdmSatellite[] { new CdmSatellite(), new CdmSatellite() }; conjunction.CdmFilePath = xmlPath; conjunction.RelPosR = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_POSITION_R"); conjunction.RelPosT = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_POSITION_T"); conjunction.RelPosN = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_POSITION_N"); conjunction.RelVelR = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_VELOCITY_R"); conjunction.RelVelT = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_VELOCITY_T"); conjunction.RelVelN = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_VELOCITY_N"); conjunction.RelativeSpeed = GetDoubleFromXmlTag(xmlDoc, "RELATIVE_SPEED"); conjunction.Probability = GetDoubleFromXmlTag(xmlDoc, "COLLISION_PROBABILITY"); conjunction.ProbabilityMethod = GetStringFromXmlTag(xmlDoc, "COLLISION_PROBABILITY_METHOD"); conjunction.ID = GetStringFromXmlTag(xmlDoc, "MESSAGE_ID"); conjunction.CreationDate = GetStringFromXmlTag(xmlDoc, "CREATION_DATE"); conjunction.MissDistance = GetDoubleFromXmlTag(xmlDoc, "MISS_DISTANCE"); conjunction.TCA = GetStringFromXmlTag(xmlDoc, "TCA"); conjunction.TCA = StkAssistant.ValidateDateFormat(conjunction.TCA); conjunction.CreationDate = StkAssistant.ValidateDateFormat(conjunction.CreationDate); if (xmlDoc.GetElementsByTagName("relativeMetadataData").Count > 0) { foreach (XmlNode node in xmlDoc.GetElementsByTagName("relativeMetadataData")[0].ChildNodes) { if (node.Name.ToUpper().Equals("COMMENT")) { string metadataComment = node.InnerText; string pattern = "SIGMA_DILUTION=(?<sigmaDilution>\\d+(.\\d+)?)"; Regex dateRegex = new Regex(pattern); Match match = dateRegex.Match(metadataComment); double sd; if (match.Groups["sigmaDilution"].Success && double.TryParse(match.Groups["sigmaDilution"].Value, out sd)) { conjunction.SigmaDilution = sd; } break; } } } for (int i = 0; i < 2; i++) { sats[i].isPrimary = i == 0; sats[i].EpochISOYMD = GetStringFromXmlTag(xmlDoc, "TCA"); sats[i].EpochISOYMD = StkAssistant.ValidateDateFormat(sats[i].EpochISOYMD); // Get satellite names sats[i].SatName = GetStringFromXmlTag(xmlDoc, "OBJECT_NAME", i); // Get International Designators sats[i].InternationalDesignator = GetStringFromXmlTag(xmlDoc, "INTERNATIONAL_DESIGNATOR", i); // Get Catalog Number sats[i].SSC = GetStringFromXmlTag(xmlDoc, "OBJECT_DESIGNATOR", i); if (sats[i].SSC == "KNOWN OBJECT") { sats[i].SatName = "KNOWN OBJECT"; sats[i].SSC = "99999"; } if (sats[i].SatName.Trim() == "") { sats[i].SatName = "UNIDENTIFIED OBJECT"; } // Get ephemeris check data string ephTemp = GetStringFromXmlTag(xmlDoc, "EPHEMERIS_NAME", i); sats[i].EphemerisFile = string.IsNullOrEmpty(ephTemp) || ephTemp.ToUpper().Equals("NONE") ? null : Path.Combine(Path.GetDirectoryName(xmlPath), ephTemp); // Get Orbital Data sats[i].ReferenceFrame = GetStringFromXmlTag(xmlDoc, "REF_FRAME", i); sats[i].XPos = GetDoubleFromXmlTag(xmlDoc, "X", i); sats[i].YPos = GetDoubleFromXmlTag(xmlDoc, "Y", i); sats[i].ZPos = GetDoubleFromXmlTag(xmlDoc, "Z", i); sats[i].XVel = GetDoubleFromXmlTag(xmlDoc, "X_DOT", i); sats[i].YVel = GetDoubleFromXmlTag(xmlDoc, "Y_DOT", i); sats[i].ZVel = GetDoubleFromXmlTag(xmlDoc, "Z_DOT", i); // Get Force Model Definition sats[i].GeopotentialModel = GetStringFromXmlTag(xmlDoc, "GRAVITY_MODEL", i); sats[i].LunarsolarPerturbations = GetStringFromXmlTag(xmlDoc, "N_BODY_PERTURBATIONS", i); sats[i].SolidEarthTidesPerturbation = GetStringFromXmlTag(xmlDoc, "EARTH_TIDES", i); sats[i].SolarRadiationPerturbation = GetStringFromXmlTag(xmlDoc, "SOLAR_RAD_PRESSURE", i); sats[i].SolarRadiationCoefficient = GetDoubleFromXmlTag(xmlDoc, "CR_AREA_OVER_MASS", i); sats[i].DragModel = GetStringFromXmlTag(xmlDoc, "ATMOSPHERIC_MODEL", i); sats[i].BallisticCoefficient = GetDoubleFromXmlTag(xmlDoc, "CD_AREA_OVER_MASS", i); sats[i].CovarianceMethod = GetStringFromXmlTag(xmlDoc, "COVARIANCE_METHOD", i); sats[i].xx = GetDoubleFromXmlTag(xmlDoc, "CR_R", i); sats[i].yx = GetDoubleFromXmlTag(xmlDoc, "CT_R", i); sats[i].yy = GetDoubleFromXmlTag(xmlDoc, "CT_T", i); sats[i].zx = GetDoubleFromXmlTag(xmlDoc, "CN_R", i); sats[i].zy = GetDoubleFromXmlTag(xmlDoc, "CN_T", i); sats[i].zz = GetDoubleFromXmlTag(xmlDoc, "CN_N", i); sats[i].Vxx = GetDoubleFromXmlTag(xmlDoc, "CRDOT_R", i); sats[i].Vxy = GetDoubleFromXmlTag(xmlDoc, "CRDOT_T", i); sats[i].Vxz = GetDoubleFromXmlTag(xmlDoc, "CRDOT_N", i); sats[i].VxVx = GetDoubleFromXmlTag(xmlDoc, "CRDOT_RDOT", i); sats[i].Vyx = GetDoubleFromXmlTag(xmlDoc, "CTDOT_R", i); sats[i].Vyy = GetDoubleFromXmlTag(xmlDoc, "CTDOT_T", i); sats[i].Vyz = GetDoubleFromXmlTag(xmlDoc, "CTDOT_N", i); sats[i].VyVx = GetDoubleFromXmlTag(xmlDoc, "CTDOT_RDOT", i); sats[i].VyVy = GetDoubleFromXmlTag(xmlDoc, "CTDOT_TDOT", i); sats[i].Vzx = GetDoubleFromXmlTag(xmlDoc, "CNDOT_R", i); sats[i].Vzy = GetDoubleFromXmlTag(xmlDoc, "CNDOT_T", i); sats[i].Vzz = GetDoubleFromXmlTag(xmlDoc, "CNDOT_N", i); sats[i].VzVx = GetDoubleFromXmlTag(xmlDoc, "CNDOT_RDOT", i); sats[i].VzVy = GetDoubleFromXmlTag(xmlDoc, "CNDOT_TDOT", i); sats[i].VzVz = GetDoubleFromXmlTag(xmlDoc, "CNDOT_NDOT", i); if (sats[i].VxVx == 0) { sats[i].VxVx = small; } if (sats[i].VyVy == 0) { sats[i].VyVy = small; } if (sats[i].VzVz == 0) { sats[i].VzVz = small; } } conjunction.Primary = sats[0]; conjunction.Secondary = sats[1]; return(conjunction); } catch (Exception e) { error += e.Message; return(null); } }