# AvailableObstructions returns a one dimensional array of obstruction paths availableArray = cbObstrConstraint.AvailableObstructions
# In this example add all available obstructions print('Available obstructions') for i in range(0, len(availableArray)): print(availableArray[i]) if availableArray[i] != "Sun": # Sun is enabled by default cbObstrConstraint.AddObstruction(availableArray[i])
# AssignedObstructions returns a one dimensional array of obstruction paths assignedArray = cbObstrConstraint.AssignedObstructions
print('Assigned obstructions') for i in range(0, len(assignedArray)): print(assignedArray[i])
Add and configure a lighting condition access constraint
# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate() minmax = accessConstraints.AddConstraint(AgEAccessConstraints.eCstrLunarElevationAngle) minmax.EnableMin = True minmax.Min = 11.1 minmax.EnableMax = True minmax.Max = 88.8
Add and configure a sun elevation angle access constraint
# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate() minmax = accessConstraints.AddConstraint(AgEAccessConstraints.eCstrSunElevationAngle) minmax.EnableMin = True minmax.Min = 22.2 minmax.EnableMax = True minmax.Max = 77.7
# To make this more efficient, wrap this method between calls to root.BeginUpdate() and root.EndUpdate() # Attitude constraint altitude = accessConstraints.AddConstraint(AgEAccessConstraints.eCstrAltitude) altitude.EnableMin = True altitude.Min = 20.5 # km
Add multiple access constraints of the same type to an STK Object
# Print results for i in range(0, results.Count): result = results.Item(i) print('Time: %s HasAccess: %s' % (result.Time, str(result.AccessSatisfied)))
for j in range(0, result.Constraints.Count): constraint = result.Constraints.Item(j) print('Constraint: %s Object: %s Status: %s Value:%s' % (constraint.Constraint, constraint.ObjectPath, constraint.Status, str(constraint.Value)))
Compute and extract access interval times
[Python - STK API]
# IAgStkAccess access: Access calculation # Get and display the Computed Access Intervals intervalCollection = access.ComputedAccessIntervalTimes
# Set the intervals to use to the Computed Access Intervals computedIntervals = intervalCollection.ToArray(0, -1) access.SpecifyAccessIntervals(computedIntervals)
Configure the access analysis time period to specified time instants.
# For this code snippet, let's use the time interval when the satellite reached min and max altitude values. # Note, this assumes time at min happens before time at max. timeOfAltMin = satellite.Vgt.Events.Item('GroundTrajectory.Detic.LLA.Altitude.TimeOfMin') timeOfAltMax = satellite.Vgt.Events.Item('GroundTrajectory.Detic.LLA.Altitude.TimeOfMax')
# Set the access time period with the times we figured out above. access = satellite.GetAccessToObject(facility) access.AccessTimePeriod = AgEAccessTimeType.eUserSpecAccessTime accessTimePeriod = access.AccessTimePeriodData
object1 = accesses[0][0] # e.g. "Satellite/MySatellite" object2 = accesses[0][1] # e.g. "Facility/MyFacility" computed = accesses[0][2] # e.g. True (if access has been computed)
Create an area target (on the current scenario central body)
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root
# Create the AreaTarget on the current scenario central body (use # NewOnCentralBody to specify explicitly the central body) areaTarget = root.CurrentScenario.Children.New(AgESTKObjectType.eAreaTarget, 'MyAreaTarget')
Define area target boundary and position from list of lat/lon/alt
# By using the fine grained interfaces, # BeginUpdate/EndUpdate prevent intermediate redraws root.BeginUpdate() areaTarget.AreaType = AgEAreaType.ePattern patterns = areaTarget.AreaTypeData patterns.Add(48.897, 18.637) patterns.Add(46.534, 13.919) patterns.Add(44.173, 21.476) root.EndUpdate() areaTarget.AutoCentroid = True
Define area target boundary and position from list of lat/lon/alt (using common tasks)
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root # IAgAreaTarget areaTarget: AreaTarget object # Remove all points in the area target areaTarget.AreaTypeData.RemoveAll()
# By using the CommonTasks interface, # make an array of latitude and longitude boundary points boundary = [[29, -12], [29, 34], [6, 34], [6, -12]]
# SetAreaTypePattern expects a two dimensional array of latitude and longitude values areaTarget.CommonTasks.SetAreaTypePattern(boundary)
List all points in an area target
[Python - STK API]
# IAgAreaTarget areaTarget: AreaTarget object if (areaTarget.AreaType == AgEAreaType.ePattern):
# Get IAgAreaTypePatternCollection interface from AreaTypeData patternPoints = areaTarget.AreaTypeData
# ToArray returns a two dimensional array of latitude and longitude points areaTargetPoints = patternPoints.ToArray()
print('All points in Area Target') for i in range(0, len(areaTargetPoints)): print('Latitude: %s Longitude: %s' % (str(areaTargetPoints[i][0]), str(areaTargetPoints[i][1])))
# By using the fine grained interfaces, # BeginUpdate/EndUpdate prevent intermediate redraws root.BeginUpdate() areaTarget.AreaType = AgEAreaType.eEllipse ellipse = areaTarget.AreaTypeData ellipse.SemiMajorAxis = 85.25 # in km (distance dimension) ellipse.SemiMinorAxis = 80.75 # in km (distance dimension) ellipse.Bearing = 44 # in deg (angle dimension) root.EndUpdate()
Set an elliptical area target (using common tasks)
# By using the CommonTasks interface areaTarget.CommonTasks.SetAreaTypeEllipse(85.25, 80.75, 44)
Create a chain (on the current scenario central body)
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root # Create the Chain on the current scenario central body (use # NewOnCentralBody to specify explicitly the central body) chain = root.CurrentScenario.Children.New(AgESTKObjectType.eChain, 'MyChain')
# Specify our own time period chain.SetTimePeriodType(AgEChTimePeriodType.eUserSpecifiedTimePeriod)
# Get chain time period interface chainUserTimePeriod = chain.TimePeriod chainUserTimePeriod.TimeInterval.SetExplicitInterval( scenario.AnalysisInterval.FindStartTime(), scenario.AnalysisInterval.FindStopTime()) # Set to scenario period
# IAgChain chain: Chain Object # Compute the chain access if not done already. chain.ComputeAccess()
# Considered Start and Stop time print('Chain considered start time: %s' % chain.Vgt.Events.Item('ConsideredStartTime').FindOccurrence().Epoch) print('Chain considered stop time: %s' % chain.Vgt.Events.Item('ConsideredStopTime').FindOccurrence().Epoch)
Create a New CoverageDefinition (on the current scenario central body)
[Python - STK API]
# IAgScenario scenario: Scenario object # Create new Coverage Definition and set the Bounds to an area target coverage = scenario.Children.New(AgESTKObjectType.eCoverageDefinition, 'MyCoverage') coverage.Grid.BoundsType = AgECvBounds.eBoundsCustomRegions covGrid = coverage.Grid bounds = covGrid.Bounds bounds.AreaTargets.Add('AreaTarget/MyAreaTarget') # Define the Grid Resolution Res = covGrid.Resolution Res.LatLon = .5 # deg # Set the satellite as the Asset coverage.AssetList.Add('Satellite/MySatellite')
# Turn off Show Grid Points coverage.Graphics.Static.IsPointsVisible = False
Extracting Elements from Data Providers with Groups
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model root # IAgSatellite satellite: Satellite object # IAgScenario scenario: Scenario object # Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') satPosDP = satellite.DataProviders.Item('Cartesian Position').Group.Item('ICRF').Exec(scenario.StartTime, scenario.StopTime, 60) satx = satPosDP.DataSets.GetDataSetByName('x').GetValues() saty = satPosDP.DataSets.GetDataSetByName('y').GetValues() satz = satPosDP.DataSets.GetDataSetByName('z').GetValues()
satVelDP = satellite.DataProviders.GetDataPrvTimeVarFromPath('Cartesian Velocity/ICRF').Exec(scenario.StartTime, scenario.StopTime, 60) # There are 4 Methods to get DP From a Path depending on the kind of DP: # GetDataPrvTimeVarFromPath # GetDataPrvIntervalFromPath # GetDataPrvInfoFromPath # GetDataPrvFixedFromPath satvx = satVelDP.DataSets.GetDataSetByName('x').GetValues() satvy = satVelDP.DataSets.GetDataSetByName('y').GetValues() satvz = satVelDP.DataSets.GetDataSetByName('z').GetValues()
Extracting Elements from Data Providers with PreData
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model root # IAgFacility facility: Facility object # IAgScenario scenario: Scenario object # Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') facChooseDP = facility.DataProviders.Item('Points Choose System') dataProvCenter = facChooseDP.Group.Item('Center') # Choose the reference system you want to report the Center point in dataProvCenter.PreData = 'CentralBody/Earth TOD' rptElems = [['Time'], ['x'], ['y'], ['z']] results = dataProvCenter.ExecElements(scenario.StartTime, scenario.StopTime, 60, rptElems) datasets = results.DataSets Time = datasets.GetDataSetByName('Time').GetValues() facTODx = datasets.GetDataSetByName('x').GetValues() facTODy = datasets.GetDataSetByName('y').GetValues() facTODz = datasets.GetDataSetByName('z').GetValues()
Getting Data for a Single Point in Time
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model root # IAgSatellite satellite: Satellite object # Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') satPassDP = satellite.DataProviders.Item('Precision Passes').ExecSingle(2600) passes = satPassDP.DataSets.GetDataSetByName('Precision Pass Number').GetValues()
Getting Data for Specific Points and Elements
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model root # IAgSatellite satellite: Satellite object # Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') times = [[0], [15000], [20000], [55000]] elems = [['Time'], ['Precision Pass Number']] satPassesDP = satellite.DataProviders.Item('Precision Passes').ExecSingleElementsArray(times, elems) passes = satPassesDP.GetArray(1)
Using a Time Dependent Data Provider and requesting only specified elements
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model root # IAgSatellite satellite: Satellite object # IAgScenario scenario: Scenario object # Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') elems = [['Time'], ['q1'], ['q2'], ['q3'], ['q4']] satDP = satellite.DataProviders.Item('Attitude Quaternions').ExecElements(scenario.StartTime, scenario.StopTime, 60, elems) # Whenever you pass an index to an array, you need to cast it to a long # equivalent (int32) satTime = satDP.DataSets.Item(0).GetValues satq1 = satDP.DataSets.Item(1).GetValues satq2 = satDP.DataSets.Item(2).GetValues satq3 = satDP.DataSets.Item(3).GetValues satq4 = satDP.DataSets.Item(4).GetValues
# Change DateFormat dimension to epoch seconds to make the data easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') # Get the current scenario scenario = root.CurrentScenario # Set up the access object access = satellite.GetAccessToObject(facility) access.ComputeAccess() # Get the Access AER Data Provider accessDP = access.DataProviders.Item('Access Data').Exec(scenario.StartTime, scenario.StopTime)
track1 = mto.Tracks.AddTrack(1, mtoTimes, mtoLats, mtoLons, mtoAlts) track1.Interpolate = True # Change the color of the track mto.Graphics.Tracks.GetTrackFromId(1).Color = Colors.Red
Load MTO track points from file
[Python - STK API]
# LoadPoints expects the path an Ephemeris file path # IAgMto mto: MTO Object track2 = mto.Tracks.Add(2) track2.Points.LoadPoints(r'C:\Program Files\AGI\STK_ODTK 13\Data\Resources\stktraining\text\EphemerisLLATimePosVel_Example.e') track2.Interpolate = True
# Assign the perigee and apogee altitude values: keplerian.SizeShape.PerigeeAltitude = 500 # km keplerian.SizeShape.ApogeeAltitude = 600 # km
# Assign the other desired orbital parameters: keplerian.Orientation.Inclination = 90 # deg keplerian.Orientation.ArgOfPerigee = 12 # deg keplerian.Orientation.AscNode.Value = 24 # deg keplerian.Location.Value = 180 # deg
# Apply the changes made to the satellite's state and propagate: satellite.Propagator.InitialState.Representation.Assign(keplerian) satellite.Propagator.Propagate()
# IAgSatellite satellite: Satellite object satellite.SetPropagatorType(AgEVePropagatorType.ePropagatorSGP4) propagator = satellite.Propagator propagator.EphemerisInterval.SetImplicitInterval( root.CurrentScenario.Vgt.EventIntervals.Item("AnalysisInterval")) # Link to scenario period propagator.CommonTasks.AddSegsFromOnlineSource('25544') # International Space Station propagator.AutoUpdateEnabled = True propagator.Propagate()
Set satellite propagator to SPICE and propagate
[Python - STK API]
# IAgSatellite satellite: Satellite object # IAgStkObjectRoot root: STK Object Model Root satellite.SetPropagatorType(AgEVePropagatorType.ePropagatorSPICE) propagator = satellite.Propagator propagator.Spice = r'C:\Program Files\AGI\STK_ODTK 13\STKData\Spice\planets.bsp' # Make sure this is a valid path propagator.BodyName = 'MARS'
propagator.EphemerisInterval.SetImplicitInterval( root.CurrentScenario.Vgt.EventIntervals.Item("AnalysisInterval")) # Link to scenario period propagator.Step = 60.0 propagator.Propagate()
# IAgSatellite satellite: Satellite object # Remove all data displays so you can easily pick one that may already be in # the list satellite.VO.DataDisplay.RemoveAll() # Add LLA data display and change size/title datadisplay = satellite.VO.DataDisplay.Add('LLA Position') datadisplay.IsVisible = True datadisplay.FontSize = AgEVOFontSize.eMedium datadisplay.TitleText = 'My Data Display' datadisplay.IsShowNameEnabled = False
# IAgSatellite satellite: Satellite object # Set swath in the 2D properties swath = satellite.Graphics.Swath swath.SetElevationType(AgEVeGfxElevation.eElevationGroundElevation) swath.Elevation.Angle = 30 # deg satellite.Graphics.Swath.Options = AgEVeGfxOptions.eOptionsEdgeLimits
Set 2D/3D Elevation Contours
[Python - STK API]
# IAgSatellite satellite: Satellite object # Set the contours in the 2D properties contours = satellite.Graphics.ElevContours contours.IsVisible = True contours.NumOfDecimalDigits = 0 contours.Elevations.AddLevelRange(0, 90, 10) # Min, Max, Step # Turn the contours on in the 3D properties satellite.VO.ElevContours.IsVisible = True
Set 2D/3D Pass Display Properties
[Python - STK API]
# IAgSatellite satellite: Satellite object # Display one pass for ground track and orbit on 2D passdata = satellite.Graphics.PassData groundTrack = passdata.GroundTrack groundTrack.SetLeadDataType(AgELeadTrailData.eDataOnePass) groundTrack.SetTrailSameAsLead orbit = passdata.Orbit orbit.SetLeadDataType(AgELeadTrailData.eDataOnePass) orbit.SetTrailSameAsLead # Display one orbit pass and no ground track on 3D passdata3D = satellite.VO.Pass.TrackData.PassData groundTrack3D = passdata3D.GroundTrack groundTrack3D.SetLeadDataType(AgELeadTrailData.eDataNone) groundTrack3D.SetTrailSameAsLead orbit3D = passdata3D.Orbit orbit3D.SetLeadDataType(AgELeadTrailData.eDataOnePass) orbit3D.SetTrailSameAsLead
Set 2D/3D Range Contours
[Python - STK API]
# IAgSatellite satellite: Satellite object # Set a contour level in the 2D properties rangeContours = satellite.Graphics.RangeContours rangeContours.IsVisible = True rangeLevel = rangeContours.LevelAttributes.AddLevel(2000) # km rangeLevel.Color = Colors.Fuchsia rangeLevel.LineWidth = AgELineWidth.e5 rangeLevel.LabelAngle = 90 rangeLevel.UserTextVisible = True rangeLevel.UserText = 'Range' # Turn the contours on in the 3D properties satellite.VO.RangeContours.IsVisible = True
# IAgSensor sensor: Sensor object # Change pattern and set sensor.CommonTasks.SetPatternRectangular(20, 25) # Change pointing and set sensor.CommonTasks.SetPointingFixedAzEl(90, 60, AgEAzElAboutBoresight.eAzElAboutBoresightRotate) # Change location and set sensor.SetLocationType(AgESnLocation.eSnFixed) sensor.LocationData.AssignCartesian(-.0004, -.0004, .004)
Add a new phase and use the same performance models as the first phase
[Python - STK API]
# IAgAvtrPhases phases: Phase Collection object # Add a new phase at the end of the mission newPhase = phases.Add() # Rename the phase newPhase.Name = 'New Phase' # Copy the performance models from the first phase and paste it to the new phase phases[0].CopyPerformanceModels() newPhase.PastePerformanceModels()
Add a takeoff procedure from a runway
[Python - STK API]
# IAgAvtrProcedureCollection procedures: Procedure Collection object # Add a takeoff procedure with a runway as a site takeoff = procedures.Add(AgEAvtrSiteType.eSiteRunway, AgEAvtrProcedureType.eProcTakeoff)
# Get the runway heading options headingOptions = takeoff.RunwayHeadingOptions # Opt to use the headwind runway headingOptions.RunwayMode = AgEAvtrRunwayHighLowEnd.eHeadwind
# Set the takeoff mode and get that interface takeoff.TakeoffMode = AgEAvtrTakeoffMode.eTakeoffNormal takeoffNormal = takeoff.ModeAsNormal
# Set the takeoff climb angle takeoffNormal.TakeoffClimbAngle = 5 # Set the departure altitude above the runway takeoffNormal.DepartureAltitude = 600 # Set the altitude offset for the runway takeoffNormal.RunwayAltitudeOffset = 10 # Use terrain for the runway's altitude takeoffNormal.UseRunwayTerrain = True
# Set the navigation to use a Straight Ahead strategy basicManeuver.NavigationStrategyType = 'Straight Ahead' # Get the options for the straight ahead strategy straightAhead = basicManeuver.Navigation # Opt to maintain course (as opposed to maintain heading) straightAhead.ReferenceFrame = AgEAvtrStraightAheadRefFrame.eMaintainCourse
# Set the profile to use a Autopilot - Vertical Plane strategy basicManeuver.ProfileStrategyType = 'Autopilot - Vertical Plane' # Get the options for the profile strategy autopilot = basicManeuver.Profile # Opt to maintain the initial altitude autopilot.AltitudeMode = AgEAvtrAutopilotAltitudeMode.eAutopilotHoldInitAltitude airspeedOptions = autopilot.AirspeedOptions # Opt to maintain a specified airspeed airspeedOptions.AirspeedMode = AgEAvtrBasicManeuverAirspeedMode.eMaintainSpecifiedAirspeed # Specify the airspeed airspeedOptions.SpecifiedAirspeed = 250
# Configure the options on the Attitude / Performance / Fuel page basicManeuver.FlightMode = AgEAvtrPhaseOfFlight.eFlightPhaseCruise # Override the fuel flow basicManeuver.FuelFlowType = AgEAvtrBasicManeuverFuelFlowType.eBasicManeuverFuelFlowOverride basicManeuver.OverrideFuelFlowValue = 1000
# Set the basic stopping conditions basicManeuver.UseMaxDownrange = True basicManeuver.MaxDownrange = 10 basicManeuver.UseStopFuelState = False basicManeuver.UseMaxTimeOfFlight = False
# Get the runway heading options headingOptions = landing.RunwayHeadingOptions # Land from the low end headingOptions.RunwayMode = AgEAvtrRunwayHighLowEnd.eLowEnd
# Use a standard instrument approach landing.ApproachMode = AgEAvtrApproachMode.eStandardInstrumentApproach # Get the options for a standard instrument approach sia = landing.ModeAsStandardInstrumentApproach # Change the approach altitude sia.ApproachAltitude = 1000 # Change the glideslope sia.Glideslope = 4 # Offset the runway altitude sia.RunwayAltitudeOffset = 10 # Use the terrain as an altitude reference for the runway sia.UseRunwayTerrain = True
Add and configure an enroute procedure
[Python - STK API]
# IAgAvtrProcedureCollection procedures: Procedure Collection object # Add an enroute procedure with a site type of End of Previous Procedure enroute = procedures.AddAtIndex(1, AgEAvtrSiteType.eSiteEndOfPrevProcedure, AgEAvtrProcedureType.eProcEnroute) # Get the altitude options altitudeOptions = enroute.AltitudeMSLOptions # To specify an altitude, turn off the option to use the default cruise altitude altitudeOptions.UseDefaultCruiseAltitude = False # Set the altitude altitudeOptions.MSLAltitude = 10000
# Get the navigation options navigationOptions = enroute.NavigationOptions # Set the route to arrive on a specified course navigationOptions.NavMode = AgEAvtrPointToPointMode.eArriveOnCourse # Set the course navigationOptions.ArriveOnCourse = 30 # Use a magnetic heading navigationOptions.UseMagneticHeading = True
# Get the navigation options airspeedOptions = enroute.EnrouteCruiseAirspeedOptions # Fly at max speed airspeedOptions.CruiseSpeedType = AgEAvtrCruiseSpeed.eMaxAirspeed # To specify an airspeed to fly at, set the speed type to other airspeed airspeedOptions.CruiseSpeedType = AgEAvtrCruiseSpeed.eOtherAirspeed # Then set the airspeed and airspeed type airspeedOptions.SetOtherAirspeed(AgEAvtrAirspeedType.eTAS, 200)
Add and remove procedures
[Python - STK API]
# IAgAvtrProcedureCollection procedures: Procedure Collection object # IAgAvtrPropagator propagator: Aviator Propagator object # Add a takeoff procedure with a runway as a site. This will add the procedure takeoff = procedures.Add(AgEAvtrSiteType.eSiteRunway, AgEAvtrProcedureType.eProcTakeoff) # Add a procedure at a given index (starting from 0) enroute = procedures.AddAtIndex(1, AgEAvtrSiteType.eSiteEndOfPrevProcedure, AgEAvtrProcedureType.eProcEnroute)
# Make sure to propagate the mission to calculate the route propagator.Propagate() # Get the mission mission = propagator.AvtrMission # Check to see if the mission is valid (must first be propagated) isValid = mission.IsValid
# Get the number of procedures procedureCount = procedures.Count # Remove the procedure at the given index procedures.RemoveAtIndex(1) # Remove the given procedure procedures.Remove(takeoff)
# Propagate the mission propagator.Propagate()
Configure a procedure time options
[Python - STK API]
# IAgAvtrProcedure procedure: Procedure object # Get the time in epoch seconds root.UnitPreferences.SetCurrentUnit('DateFormat', 'EpSec') # Get the time options timeOptions = procedure.TimeOptions # Get the start time startTime = timeOptions.StartTime # Set the procedure to interrupt after 15 seconds timeOptions.SetInterruptTime(15)
Configure a runway site
[Python - STK API]
# IAgAvtrSiteRunway runway: Runway object # Set the latitude, longitude, and altitude runway.Latitude = 41 runway.Longitude = 77 runway.Altitude = 5
# Set the altitude reference runway.AltitudeRef = AgEAvtrAGLMSL.eAltMSL
# Set the heading runway.HighEndHeading = 195 # Opt to use true heading runway.IsMagnetic = False
# Set the length of the runway runway.Length = 5
# Rename the runway runway.Name = 'New User Runway' # Add the runway to the catalog to use it for next time runway.AddToCatalog(1)
Configure a runway site from a runway in the Aviator catalog
[Python - STK API]
# IAgAvtrSiteRunway runway: Runway object # IAgAvtrCatalog catalog: Aviator catalog object # Get the source of user runways userRunways = catalog.RunwayCategory.UserRunways # Check that the runway exists in the catalog if userRunways.Contains('New User Runway') is True: # If so, get the user runway with the given name runwayFromCatalog = userRunways.GetUserRunway('New User Runway') # Copy the parameters of that runway runway.CopyFromCatalog(runwayFromCatalog)
Configure the Advanced Fixed Wing Tool and set the aircraft to use the resulting performance models
[Python - STK API]
# IAgAvtrAircraft aviatorAircraft: Aviator Aircraft object # Get the advanced fixed wing tool advFixedWingTool = aviatorAircraft.AdvFixedWingTool # Set the basic geometry advFixedWingTool.WingArea = 300 advFixedWingTool.FlapsArea = 50 advFixedWingTool.SpeedbrakesArea = 10 # Set the structural and human factor limits advFixedWingTool.MaxAltitude = 65000 advFixedWingTool.MaxMach = 0.98 advFixedWingTool.MaxEAS = 460 advFixedWingTool.MinLoadFactor = -2.5 advFixedWingTool.MaxLoadFactor = 4.5
# Opt to enforce the max temperature limit advFixedWingTool.UseMaxTemperatureLimit = True advFixedWingTool.MaxTemperature = 900
# Use a subsonic aerodynamic strategy advFixedWingTool.AeroStrategy = AgEAvtrAdvFixedWingAeroStrategy.eSubsonicAero # Cache the aerodynamic data to improve calculation speed advFixedWingTool.CacheAeroData = True # Use a high bypass turbofan advFixedWingTool.PowerplantStrategy = AgEAvtrAdvFixedWingPowerplantStrategy.eTurbofanHighBypass # Cache the fuel flow data to improve calculation speed advFixedWingTool.CacheFuelFlow = True
# Create the corresponding performance models that reference the advanced fixed wing tool # Specify the name, whether to override any existing models with the same name, and whether to set the new models as the default performance models advFixedWingTool.CreateAllPerfModels('AdvancedModels', True, True)
# Save the changes in the catalog aviatorAircraft.Save()
Configure the Aviator propagator
[Python - STK API]
# IAgAircraft aircraft: Aircraft object # Set to Propagator to Aviator aircraft.SetRouteType(AgEVePropagatorType.ePropagatorAviator) # Get the aircraft's route aircraftRoute = aircraft.Route # Get the Aviator propagator propagator = aircraftRoute.AvtrPropagator # Get the Aviator mission mission = propagator.AvtrMission # Get the list of phases from the mission phases = mission.Phases # Get the list of procedures from the first phase procedures = phases[0].Procedures # Propagate the route propagator.Propagate()
Configure the basic acceleration performance model of an aircraft
[Python - STK API]
# IAgAvtrAircraft aviatorAircraft: Aviator Aircraft object # Get the acceleration type acceleration = aviatorAircraft.Acceleration # Get the build in performance model basicAccModel = acceleration.GetBuiltInModel()
# Get the level turns options levelTurns = basicAccModel.LevelTurns # Set a max bank angle of 25 levelTurns.SetLevelTurn(AgEAvtrTurnMode.eTurnModeBankAngle, 25) # Get the climb and descent transition options climbAndDescent = basicAccModel.ClimbAndDescentTransitions # Set the max pull up G to 1 climbAndDescent.MaxPullUpG = 1.2 # Get the attitude transition options attitudeTransitions = basicAccModel.AttitudeTransitions # Set the max roll rate to 25 attitudeTransitions.RollRate = 25
# Get the aerodynamics aero = basicAccModel.Aerodynamics # Use simple aerodynamics aero.AeroStrategy = AgEAvtrAircraftAeroStrategy.eAircraftAeroSimple # Get the options for the simple aerodynamics and set some parameters simpleAero = aero.ModeAsSimple simpleAero.SRef = 5 simpleAero.ClMax = 3.1 simpleAero.Cd = 0.05
# Get the propulsion prop = basicAccModel.Propulsion # Use simple propulsion prop.PropStrategy = AgEAvtrAircraftPropStrategy.eAircraftPropSimple # Get the simple propulsion options and set some parameters simpleProp = prop.ModeAsSimple simpleProp.MaxThrustAccel = 0.6 simpleProp.MinThrustDecel = 0.4 simpleProp.SetDensityScaling(True, 0.02)
# Save the changes to the catalog aviatorAircraft.Save()
Configure the basic cruise performance model of an aircraft
[Python - STK API]
# IAgAvtrAircraft aviatorAircraft: Aviator Aircraft object # Get the cruise type cruise = aviatorAircraft.Cruise # Get the build in performance model basicCruiseModel = cruise.GetBuiltInModel()
# Set the ceiling altitude basicCruiseModel.CeilingAltitude = 50000 # Set the default cruise altitude basicCruiseModel.DefaultCruiseAltitude = 10000 # Set the airspeed type basicCruiseModel.AirspeedType = AgEAvtrAirspeedType.eTAS # Opt to not use the fuel flow calculated by the aero/prop model and instead specify the values basicCruiseModel.UseAeroPropFuel = False
# Set the various airspeeds and fuel flows basicCruiseModel.MinAirspeed = 110 basicCruiseModel.MinAirspeedFuelFlow = 10000
# Save the changes to the catalog aviatorAircraft.Save()
Configure the performance models to be used in the phase
[Python - STK API]
# IAgAvtrPhase phase: Phase object # Get the acceleration performance model used for the current phase acceleration = phase.GetPerformanceModelByType('Acceleration') # Check if it is linked to the catalog isLinkedToCatalog = acceleration.IsLinkedToCatalog # Use the performance model in the catalog named "Built-In Model" acceleration.LinkToCatalog('Built-In Model')
# Get the VTOL performance model vtol = phase.GetPerformanceModelByType('VTOL') # Create a new vtol model of type AGI VTOL Model. Note that this new model does not exist in the catalog and only exists in the phase. vtol.CreateNew('AGI VTOL Model') # Rename the performance model vtol.Rename('Temporary VTOL Model')
Configure the weather and atmosphere of the Mission
[Python - STK API]
# IAgAvtrMission mission: Aviator Mission object # Get the wind model used for the mission windModel = mission.WindModel # Let's use the mission model windModel.WindModelSource = AgEAvtrWindAtmosModelSource.eMissionModel # Let's use constant wind windModel.WindModelType = AgEAvtrWindModelType.eConstantWind # Get the constant wind model options constantWind = windModel.ModeAsConstant # Set the wind bearing constantWind.WindBearing = 30 # Set the wind speed constantWind.WindSpeed = 5
# Get the atmosphere model used for the mission atmosphere = mission.AtmosphereModel # Let's use the mission model atmosphere.AtmosphereModelSource = AgEAvtrWindAtmosModelSource.eMissionModel # Get the basic atmosphere options basicAtmosphere = atmosphere.ModeAsBasic # Use standard 1976 atmosphere basicAtmosphere.BasicModelType = AgEAvtrAtmosphereModel.eStandard1976 # Opt to override the values basicAtmosphere.UseNonStandardAtmosphere = True # Override the temperature basicAtmosphere.Temperature = 290
Configure the wind and atmosphere for a procedure
[Python - STK API]
# IAgAvtrProcedure procedure: Procedure object # Get the wind model for the procedure windModel = procedure.WindModel # Use the procedure model windModel.WindModelSource = AgEAvtrWindAtmosModelSource.eProcedureModel # Let's use constant wind windModel.WindModelType = AgEAvtrWindModelType.eConstantWind # Get the constant wind model options constantWind = windModel.ModeAsConstant # Set the wind bearing constantWind.WindBearing = 30 # Set the wind speed constantWind.WindSpeed = 5
# Get the atmosphere model used for the procedure atmosphere = procedure.AtmosphereModel # Let's use the procedure model atmosphere.AtmosphereModelSource = AgEAvtrWindAtmosModelSource.eProcedureModel # Get the basic atmosphere options basicAtmosphere = atmosphere.ModeAsBasic # Use standard 1976 atmosphere basicAtmosphere.BasicModelType = AgEAvtrAtmosphereModel.eStandard1976
Create a new performance model for an aircraft
[Python - STK API]
# IAgAvtrAircraft aviatorAircraft: Aviator Aircraft object # Get the acceleration type acceleration = aviatorAircraft.Acceleration # Get the names of the current acceleration models modelNames = acceleration.ChildNames # Check how many models there are modelCount = len(modelNames) # Get the child types (for example AGI Basic Acceleration Model, Advanced Acceleration Model) modelTypes = acceleration.ChildTypes # Create a new performance model of type "Advanced Acceleration Model" newPerformanceModel = acceleration.AddChildOfType('Advanced Acceleration Model', 'Model Name') # Save the changes to the catalog aviatorAircraft.Save()
Rename a procedure and its site
[Python - STK API]
# IAgAvtrProcedure procedure: Procedure object # Rename the procedure procedure.Name = 'New Procedure' # Get the site corresponding to the procedure site = procedure.Site # Rename the site site.Name = 'New Site'
Set the aircraft used for the mission to an aircraft found in the Aviator catalog
[Python - STK API]
# IAgAvtrPropagator propagator: Aviator Propagator object # Get the Aviator catalog catalog = propagator.AvtrCatalog # Get the aircraft category category = catalog.AircraftCategory # Get the user aircraft models aircraftModels = category.AircraftModels # Get the basic fighter fighter = aircraftModels.GetAircraft('Basic Fighter') # Get the mission mission = propagator.AvtrMission # Set the vehicle used for the mission mission.Vehicle = fighter
Set the Configuration used for the Mission
[Python - STK API]
# IAgAvtrMission mission: Aviator Mission object # Get the configuration used for the mission configuration = mission.Configuration # Set the max landing weight configuration.MaxLandingWeight = 300000 # Set the empty weight configuration.EmptyWeight = 210000 # Update the center of gravity of the aircraft when empty configuration.SetEmptyCG(2, 0, 1)
# Get the stations stations = configuration.GetStations() # Check if there is an internal fuel station if stations.ContainsStation('Internal Fuel') is True: # Get the fuel tank fuelTank = stations.GetInternalFuelTankByName('Internal Fuel') # Set the capacity of the fuel tank fuelTank.Capacity = 175000 # Set the initial state of the fuel tank fuelTank.InitialFuelState = 125000
# Add a new payload station newPayload = stations.AddPayloadStation() # Set the position of the payload station newPayload.SetPosition(0, 2, 0) # Add an external fuel tank externalTank = newPayload.AddExternalFuelTank() # Set the empty weight of the tank externalTank.EmptyWeight = 2000
# IAgScenario scenario: Scenario object # Create a array of LLA values and interoplate them over the specified # central body positionArray = [[35.017], [-118.540], [0], [44.570], [-96.474], [0], [31.101], [-82.619], [0]] manager = scenario.SceneManager # Interpolate points over great arc interpolator = manager.Initializers.GreatArcInterpolator.InitializeWithCentralBody('Earth') interpolator.Granularity = .1 result = interpolator.Interpolate(positionArray)
# IAgStkObjectRoot root: STK Object Model Root # IAgCrdnProvider vgtSat: Vector Geometry Tool Interface # Change DateFormat dimension to epoch seconds to make the time easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') timeInstFactory = vgtSat.Events.Factory timeEpoch = timeInstFactory.CreateEventEpoch('FixedTime', 'Fixed Epoch Time') timeEpoch.Epoch = 3600
Create a new Time Interval
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root # IAgCrdnProvider vgtSat: Vector Geometry Tool Interface # Change DateFormat dimension to epoch seconds to make the time easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') timeIntFactory = vgtSat.EventIntervals.Factory timeInterval = timeIntFactory.CreateEventIntervalFixed('TimeInterval', 'Fixed time interval') timeInterval.SetInterval(60, 120)
# IAgSatellite satellite: Satellite object vgtSat = satellite.Vgt # Get handle to the Center point on the satellite centerPtSat = vgtSat.Points.Item('Center') # Get handle to the Body Y Vector bodyYSat = vgtSat.Vectors.Item('Body.Y') # Get handle to the Body Axes bodyAxes = vgtSat.Axes.Item('Body') icrfAxes = vgtSat.Axes.Item('ICRF')
Get Times From Defined Time Instant and create an cell array
[Python - STK API]
# IAgStkObjectRoot root: STK Object Model Root # IAgCrdnProvider vgtSat: Vector Geometry Tool Interface # Change DateFormat dimension to epoch seconds to make the time easier to handle in # Python root.UnitPreferences.Item('DateFormat').SetCurrentUnit('EpSec') satStart = vgtSat.Events.Item('AvailabilityStartTime') start = satStart.FindOccurrence().Epoch