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 }
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 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 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 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(); }