赞
踩
这次来通过STK实际设计一个SAR卫星星座并计算我们所关注的星座参数。
1.STK与python 的交互——STK Python API
本文将通过STK 自己的 API 来进行与python的交互。我在编程初期的时候,用的是win32com和comtypes来交互,网上能查到的方法也大多是这两类。从我自身的体验看,以上两类方法环境配置很复杂,编程的过程也比较混乱。后面我统一换成了STK Python API,环境配置非常简单,pip安装以下就行。根据官方文档,STK Python API有以下优点:
安装STK Python API打包的Wheel文件。文件随STK安装一起包含在bin/AgPythonAPI目录中。
python -m pip install "<STK installation directory>/bin/AgPythonAPI/agi.stk12-12.2.0-py3-none-any.whl"
验证是否安装。在Python文件中,复制并粘贴下面的代码并运行。
- from agi.stk12.stkengine import STKEngine
-
- stk = STKEngine.StartApplication(noGraphics=True)
- print(stk.Version)
输出STK版本则安装成功。
如果你有代码是用win 32 或 Comtypes写的,可以参考官方的 Migration Guide 来修改。
2.通过STK Python API 创建星座
第一步,导入API并关联当前场景(当不知道import什么的时候,全都import就好了)。
- # Start new instance of STK using the new API
- # Get reference to running STK instance using the new API
- from agi.stk12 import *
- from agi.stk12.stkdesktop import STKDesktop
- from agi.stk12.stkobjects import *
- from agi.stk12.stkutil import *
- from agi.stk12.vgt import *
- stk = STKDesktop.AttachToApplication()
- # Get the IAgStkObjectRoot interface
- root = stk.Root
- scenario=root.CurrentScenario
生成种子卫星并设置轨道六根数:
- satellite = scenario.Children.New(AgESTKObjectType.eSatellite, 'SatWalkerSeed')
- keplerian = satellite.Propagator.InitialState.Representation.ConvertTo(1) # eOrbitStateClassical, Use the Classical Element interface
- keplerian.SizeShapeType = 4 # Semimajor Axis and Eccentricity
- keplerian.LocationType = 5 # eLocationTrueAnomaly, Makes sure True Anomaly is being used
- keplerian.Orientation.AscNodeType = 1 # eAscNodeRAAN, Use RAAN for data entry
-
- keplerian.SizeShape.SemiMajorAxis = 6800 # km
- keplerian.SizeShape.Eccentricity = 0 #
-
- # 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 True anomaly
- satellite.Propagator.InitialState.Representation.Assign(keplerian)
- satellite.Propagator.Propagate()
这里采用了半长轴、偏心率、倾角、近地点俯角、升交点赤经、真近点角来定义卫星卫星轨道,如果想用其它的输入如平近点角、轨道高度等可以调整一开始的type设置。
添加SAR传感器并定义视场:
- root.ExecuteCommand('New / */Satellite/' + 'SatWalkerSeed' +'/Sensor'+' sensar') #设置SAR传感器
- root.ExecuteCommand('Define */Satellite/SatWalkerSeed/Sensor/sensar SAR 12 52 80 80 TrackParentAltitude On') #传感器与卫星本体同高度
这里采用ExecuteCommand命令直接添加,这个命令比较方便。传感器参数参照的ICEYE公司的商业SAR卫星。
用种子卫星生成Walker Delta星座:
- numPlanes=20, numSatsPerPlane=5, interPlanePhaseIncement=0
- root.ExecuteCommand('Walker */Satellite/SatWalkerSeed Type Delta NumPlanes '+\
- str(int(numPlanes))+ \
- ' NumSatsPerPlane ' + \
- str(int(numSatsPerPlane)) + \
- ' InterPlanePhaseIncrement ' + \
- str(int(interPlanePhaseIncement)) + \
- ' ColorByPlane ' + 'No' + " ConstellationName SimConst")
- satellite.Unload()
设计此星座目的是增大地面覆盖范围的同时保证较小的卫星重访时间。所以选择Walker星座。直接用定义的星座参数生成星座。顺便把多余的种子卫星去掉。
3.计算星座参数
星座覆盖率及重访问时间计算:
- root.ExecuteCommand("New / */CoverageDefinition/ CovCalc ")
-
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Grid AreaOfInterest LatBounds -70 70") # 按照纬度设置为区域
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Grid PointGranularity LatLon 20 ")# + str(covAlt * 1000)) #设置计算间隔
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Grid PointAltitude AltAboveTerrain 0.0")
- root.ExecuteCommand('Cov */CoverageDefinition/CovCalc Access AutoRecompute Off') # 关闭自动计算
- root.ExecuteCommand("Graphics */CoverageDefinition/CovCalc Static Points Off") # 关闭点显示
- root.ExecuteCommand("New / */CoverageDefinition/CovCalc/FigureOfMerit/ fomrevisit")
- root.ExecuteCommand(
- "Cov */CoverageDefinition/CovCalc/FigureOfMerit/fomrevisit FOMDefine Definition RevisitTime Compute Maximum")
- root.ExecuteCommand("Graphics */CoverageDefinition/CovCalc/FigureOfMerit/fomrevisit Static Off")
- root.ExecuteCommand("New / */CoverageDefinition/CovCalc/FigureOfMerit/ fom")
- root.ExecuteCommand("New / */CoverageDefinition/CovCalc/FigureOfMerit/ fomrevisit_ave") #计算平均重访问时间
- root.ExecuteCommand(
- "Cov */CoverageDefinition/CovCalc/FigureOfMerit/fomrevisit_ave FOMDefine Definition RevisitTime Compute Average")
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc/FigureOfMerit/fom FOMDefine Definition Simple Coverage") #简单覆盖
- #root.ExecuteCommand("Cov */CoverageDefinition/CovCalc/FigureOfMerit/fom FOMDefine #Satisfaction AtLeast 1") # n重覆盖
- root.ExecuteCommand("Graphics */CoverageDefinition/CovCalc/FigureOfMerit/fom Static Off")
- root.ExecuteCommand("Graphics */CoverageDefinition/CovCalc/FigureOfMerit/fom FOMContours Animation StartStop 0 2 1 ColorRamp red green Show On")
- root.ExecuteCommand("Graphics */CoverageDefinition/CovCalc/FigureOfMerit/fom Legend Animation Display On ShowOnMap On") # 添加显示图例
- fom = root.getObjectFromPath("CoverageDefinition/CovCalc/FigureOfMerit/fom")
- covDef = root.getObjectFromPath("CoverageDefinition/CovCalc")
-
- satList = scenario.Children.GetElements(AgESTKObjectType.eSatellite) #获取场景所有卫星集合
- if satList[0].HasChildren:
- for sat in satList:
- root.ExecuteCommand(
- "Cov */CoverageDefinition/CovCalc Asset */Satellite/" + sat.InstanceName + "/Sensor/sensar Assign") # 分配传感器
- root.ExecuteCommand(
- "Cov */CoverageDefinition/CovCalc Asset */Satellite/" + sat.InstanceName + "/Sensor/sensar Activate") # activate
- else:
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Asset */Constellation/SimConst Assign") #
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Asset */Constellation/SimConst Activate")
-
- # 覆盖率计算
- root.ExecuteCommand("Cov */CoverageDefinition/CovCalc Access Compute")
- t = fom.DataProviders.GetDataPrvFixedFromPath('Static Satisfaction').Exec()
- coverageRate = t.DataSets.GetDataSetByName('Percent Satisfied').GetValues()[0]
-
- #最大重访问时间
- fomrevisit = root.getObjectFromPath("CoverageDefinition/CovCalc/FigureOfMerit/fomrevisit")
- t2 = fomrevisit.DataProviders.GetDataPrvFixedFromPath('Value by Latitude').Exec()
- revisit_time = t2.DataSets.GetDataSetByName('Maximum').GetValues()
- #平均重访问时间
- fomrevisit_ave = root.getObjectFromPath("CoverageDefinition/CovCalc/FigureOfMerit/fomrevisit_ave")
- t3 = fomrevisit_ave.DataProviders.GetDataPrvFixedFromPath('Value by Latitude').Exec()
- revisit_time_ave = t3.DataSets.GetDataSetByName('Average').GetValues()
具体实现方式就是定义覆盖要素,然后从报告中读取覆盖率、对纬正负70区域的最大以及平均重访问时间。
这次先讲到这里,后续会讲一下如何生成并分析SAR星座对地观测的场景。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。