STK12与Python联合仿真(三):分析星座覆盖性能

2023-10-08 12:50

本文主要是介绍STK12与Python联合仿真(三):分析星座覆盖性能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

分析星座覆盖性能

  • 打开STK,连接到工程
  • 创建种子星 (STK)
  • 创建种子星 (Python)
  • 生成星座
  • Python 创建覆盖网格
  • 绑定卫星的传感器
  • 建立星座
  • 定义多重网格
  • 计算与绘图
  • 结语

打开STK,连接到工程

jupyter:

导入相关的包

from agi.stk12.stkdesktop import STKDesktop
from agi.stk12.stkobjects import *
from agi.stk12.stkutil import *
from agi.stk12.vgt import *
import os

链接STK

STK_PID = 5600  # 根据自己刚刚得到的PID
stk = STKDesktop.AttachToApplication(pid=int(STK_PID))
# stk = STKDesktop.StartApplication(visible=True) #using optional visible argument
root = stk.Root
print(type(root))
scenario = root.CurrentScenario # 链接当前场景

创建种子星 (STK)

这里我在STK手动建立了高度600km,倾角75° 的种子卫星,并携带了对地观测角80°的传感器
然后建立Wakler星座
在这里插入图片描述
设置36个轨道面,每个轨道面10个星
在这里插入图片描述
结果如下:
在这里插入图片描述

创建种子星 (Python)

# 创建星座 —— 种子卫星
sat_seed = scenario.Children.New(AgESTKObjectType.eSatellite,'COL') # 种子卫星
# 种子卫星属性
sat_seed.SetPropagatorType(2) #  J4 摄动
keplerian = sat_seed.Propagator.InitialState.Representation.ConvertTo(1)  # eOrbitStateClassical, Use the Classical Element interface
keplerian.SizeShapeType = 0  # eSizeShapeAltitude, Changes from Ecc/Inc to Perigee/Apogee Altitude
keplerian.LocationType = 5  # eLocationTrueAnomaly, Makes sure True Anomaly is being used
keplerian.Orientation.AscNodeType = 0  # eAscNodeLAN, Use LAN instead of RAAN for data entry# Assign the perigee and apogee altitude values:
keplerian.SizeShape.PerigeeAltitude = 600      # km 近地点 高度
keplerian.SizeShape.ApogeeAltitude = 600       # km 远地点 高度# Assign the other desired orbital parameters:
keplerian.Orientation.Inclination = 75         # deg 倾角 
keplerian.Orientation.ArgOfPerigee = 0        # deg 近地点幅角度
keplerian.Orientation.AscNode.Value = 0       # deg
keplerian.Location.Value =  0              # deg 平近点角# Apply the changes made to the satellite's state and propagate:
sat_seed.Propagator.InitialState.Representation.Assign(keplerian)
sat_seed.Propagator.Propagate()
  • 添加传感器,命名Cam
# 添加传感器
sensor = sat_seed.Children.New(AgESTKObjectType.eSensor,'Cam')
# 传感器属性
sensor.CommonTasks.SetPatternSimpleConic(40,1) # 半张角40°,角分辨率1°
LOS = sensor.AccessConstraints.AddConstraint(34) # Range 类型
# 对照 https://help.agi.com/stkdevkit/Content/DocX/STKObjects~Enumerations~AgEAccessConstraints_EN.html 
LOS = LOS.QueryInterface(STKObjects.IAgAccessCnstrMinMax)  # 如果报错没有QueryInterface方法就把这一段注释
LOS.EnableMax = True
LOS.Max = 1100

这里解释一下约束
首先https://help.agi.com/stkdevkit/Content/DocX/STKObjectsEnumerationsAgEAccessConstraints_EN.html 这里解释sensor.AccessConstraints.AddConstraint(34)是IAgAccessCnstrMinMax的Range 类型
因此要接入STKObjects.IAgAccessCnstrMinMax,然后LOS.EnableMax对应的是图中的可选框,是否激活
LOS.Max = 1100表示设定的值
比如LOS.EnableMin = True
LOS.Min = 10

在这里插入图片描述

生成星座

生成星座只需要一个命令,

root.ExecuteCommand(‘Walker */Satellite/COL Type Delta NumPlanes 16 NumSatsPerPlane 10 InterPlanePhaseIncrement 1 ColorByPlane Yes’);

‘Walker */Satellite/COL Type Delta NumPlanes 16 NumSatsPerPlane 10 InterPlanePhaseIncrement 1 ColorByPlane Yes’ 这里面中,COL是种子卫星的平面,往后的参数依次是 轨道平面数、每轨道卫星数、轨道相位因子,对应STK如下
在这里插入图片描述
(这里为了演示能快一点就减少了卫星数量)

Python 创建覆盖网格

covdef = scenario.Children.New(AgESTKObjectType.eCoverageDefinition,'testCov') # 创建Coverage definition

这里对应STK的
在这里插入图片描述
设置 Converage Defination的属性

covdef.Grid.BoundsType = 6 # VAR1
'''
1 Global
2 Latitude Bounds
3 Latitude Line
4 Longitude Line
5 Custom Boundary
6 LatLon Region
'''
covdef.Grid.Resolution.LatLon = 6   # VAR2
covdef.PointDefinition.Altitude = 10 # 10 km  # VAR3# 如果选择eBoundsLatLonRegion可以定义网格的覆盖区域
# covdef.Grid.BoundsType = ‘eBoundsLatLonRegion’;
# covdef.Grid.Bounds.MinLongitude = -120;
# covdef.Grid.Bounds.MaxLongitude = 120;
# covdef.Grid.Bounds.MinLatitude = -30;
# covdef.Grid.Bounds.MaxLatitude = 30;

这里分别对应
在这里插入图片描述

绑定卫星的传感器

  1. 要读取所有可用的对象,放入all_list
  2. 由于我们只需要卫星的传感器,即放入sensor_list 里面
  3. 卫星传感器在列表中是交替列出的,因此只要间隔取样就可以了
all_list = covdef.AssetList.AvailableAssets
sensor_list = []
for e in range(len(all_list)):if e%2 == 0:passelse:sensor_list.append(all_list[e])

将所有传感器塞入

for j in sensor_list:covdef.AssetList.Add(j)

建立星座

sate_constellation = scenario.Children.New(AgESTKObjectType.eConstellation,'COL')
for obj in tqdm(all_list):sate_constellation.Objects.Add(obj)

定义多重网格

有时候我们需要分析不同高度的覆盖性能,但是手动添加太过繁琐,一下例程演示0-300km,采样间隔10km的网格创建。
并把不同网格放在一个列表里

covdef_lits = []
for i in range(0,310,10):_string = 'CovDef' + str(i)covdef = scenario.Children.New(AgESTKObjectType.eCoverageDefinition, _string)covdef.Grid.BoundsType = 6covdef.Grid.Resolution.LatLon = 6covdef.PointDefinition.Altitude = i for j in sensor_list:covdef.AssetList.Add(j)covdef_lits.append(covdef)

计算与绘图

方法变量值描述
eFmAccessConstraint0Access Constraint Figure of Merit.
eFmAccessDuration1Access Duration Figure of Merit.
eFmAccessSeparation2Access Separation Figure of Merit.
eFmCoverageTime3Coverage Time Figure of Merit.
eFmDilutionOfPrecision4Dilution of Precision Figure of Merit.
eFmNAssetCoverage5N Asset Coverage Figure of Merit.
eFmNavigationAccuracy6Navigation Accuracy Figure of Merit.
eFmNumberOfAccesses7Number of Accesses Figure of Merit.
eFmNumberOfGaps8Number of Gaps Figure of Merit.
eFmResponseTime9Response Time Figure of Merit.
eFmRevisitTime10Revisit Time Figure of Merit.
eFmSimpleCoverage11Simple Coverage Figure of Merit.
eFmTimeAverageGap12Time Average Gap Figure of Merit.
eFmSystemResponseTime13System Response Time Figure of Merit.
eFmAgeOfData14Age of Data Figure of Merit.
eFmScalarCalculation15Scalar Calculation Figure of Merit.
eFmSystemAgeOfData16System Age Of Data Figure of Merit.
figmerit1.SetDefinitionType(1)  # eFmAccessDuration 
covdef_tmp.ComputeAccesses();
pov = covdef_tmp.DataProviders.Item('Coverage by Latitude').Exec() # Coverage By Latitude

这里对照Reoprt Style 的属性
在这里插入图片描述在这里插入图片描述

data_array = pov.DataSets.ToArray() # 转换为数组

在这里插入图片描述
对比STK数据
在这里插入图片描述
在这里插入图片描述
完成绘图

import numpy as np
from matplotlib import pyplot as plt
data_array = np.array(data_array)
x = []
y = []
for ele in data_array:x.append(ele[0])y.append(ele[1])passplt.plot(x,y)

在这里插入图片描述
对比STK生成的图
在这里插入图片描述

结语

Python 有很多接口都是整形变量,不像MATLAB可以直接用字符串那么方便,需要自己找对应的变量。
我一般是对照着MATLAB的例程找到一些范式,可以在网站中慢慢找
STK Help

本文所有代码我将上传至我的Github

这篇关于STK12与Python联合仿真(三):分析星座覆盖性能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/165394

相关文章

Python判断for循环最后一次的6种方法

《Python判断for循环最后一次的6种方法》在Python中,通常我们不会直接判断for循环是否正在执行最后一次迭代,因为Python的for循环是基于可迭代对象的,它不知道也不关心迭代的内部状态... 目录1.使用enuhttp://www.chinasem.cnmerate()和len()来判断for

使用Python实现高效的端口扫描器

《使用Python实现高效的端口扫描器》在网络安全领域,端口扫描是一项基本而重要的技能,通过端口扫描,可以发现目标主机上开放的服务和端口,这对于安全评估、渗透测试等有着不可忽视的作用,本文将介绍如何使... 目录1. 端口扫描的基本原理2. 使用python实现端口扫描2.1 安装必要的库2.2 编写端口扫

使用Python实现操作mongodb详解

《使用Python实现操作mongodb详解》这篇文章主要为大家详细介绍了使用Python实现操作mongodb的相关知识,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、示例二、常用指令三、遇到的问题一、示例from pymongo import MongoClientf

使用Python合并 Excel单元格指定行列或单元格范围

《使用Python合并Excel单元格指定行列或单元格范围》合并Excel单元格是Excel数据处理和表格设计中的一项常用操作,本文将介绍如何通过Python合并Excel中的指定行列或单... 目录python Excel库安装Python合并Excel 中的指定行Python合并Excel 中的指定列P

一文详解Python中数据清洗与处理的常用方法

《一文详解Python中数据清洗与处理的常用方法》在数据处理与分析过程中,缺失值、重复值、异常值等问题是常见的挑战,本文总结了多种数据清洗与处理方法,文中的示例代码简洁易懂,有需要的小伙伴可以参考下... 目录缺失值处理重复值处理异常值处理数据类型转换文本清洗数据分组统计数据分箱数据标准化在数据处理与分析过

Python调用另一个py文件并传递参数常见的方法及其应用场景

《Python调用另一个py文件并传递参数常见的方法及其应用场景》:本文主要介绍在Python中调用另一个py文件并传递参数的几种常见方法,包括使用import语句、exec函数、subproce... 目录前言1. 使用import语句1.1 基本用法1.2 导入特定函数1.3 处理文件路径2. 使用ex

Python脚本实现自动删除C盘临时文件夹

《Python脚本实现自动删除C盘临时文件夹》在日常使用电脑的过程中,临时文件夹往往会积累大量的无用数据,占用宝贵的磁盘空间,下面我们就来看看Python如何通过脚本实现自动删除C盘临时文件夹吧... 目录一、准备工作二、python脚本编写三、脚本解析四、运行脚本五、案例演示六、注意事项七、总结在日常使用

Python将大量遥感数据的值缩放指定倍数的方法(推荐)

《Python将大量遥感数据的值缩放指定倍数的方法(推荐)》本文介绍基于Python中的gdal模块,批量读取大量多波段遥感影像文件,分别对各波段数据加以数值处理,并将所得处理后数据保存为新的遥感影像... 本文介绍基于python中的gdal模块,批量读取大量多波段遥感影像文件,分别对各波段数据加以数值处

python管理工具之conda安装部署及使用详解

《python管理工具之conda安装部署及使用详解》这篇文章详细介绍了如何安装和使用conda来管理Python环境,它涵盖了从安装部署、镜像源配置到具体的conda使用方法,包括创建、激活、安装包... 目录pytpshheraerUhon管理工具:conda部署+使用一、安装部署1、 下载2、 安装3

Python进阶之Excel基本操作介绍

《Python进阶之Excel基本操作介绍》在现实中,很多工作都需要与数据打交道,Excel作为常用的数据处理工具,一直备受人们的青睐,本文主要为大家介绍了一些Python中Excel的基本操作,希望... 目录概述写入使用 xlwt使用 XlsxWriter读取修改概述在现实中,很多工作都需要与数据打交