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和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

一文深入详解Python的secrets模块

《一文深入详解Python的secrets模块》在构建涉及用户身份认证、权限管理、加密通信等系统时,开发者最不能忽视的一个问题就是“安全性”,Python在3.6版本中引入了专门面向安全用途的secr... 目录引言一、背景与动机:为什么需要 secrets 模块?二、secrets 模块的核心功能1. 基

python常见环境管理工具超全解析

《python常见环境管理工具超全解析》在Python开发中,管理多个项目及其依赖项通常是一个挑战,下面:本文主要介绍python常见环境管理工具的相关资料,文中通过代码介绍的非常详细,需要的朋友... 目录1. conda2. pip3. uvuv 工具自动创建和管理环境的特点4. setup.py5.

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Python虚拟环境与Conda使用指南分享

《Python虚拟环境与Conda使用指南分享》:本文主要介绍Python虚拟环境与Conda使用指南,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、python 虚拟环境概述1.1 什么是虚拟环境1.2 为什么需要虚拟环境二、Python 内置的虚拟环境工具

Python实例题之pygame开发打飞机游戏实例代码

《Python实例题之pygame开发打飞机游戏实例代码》对于python的学习者,能够写出一个飞机大战的程序代码,是不是感觉到非常的开心,:本文主要介绍Python实例题之pygame开发打飞机... 目录题目pygame-aircraft-game使用 Pygame 开发的打飞机游戏脚本代码解释初始化部

Python pip下载包及所有依赖到指定文件夹的步骤说明

《Pythonpip下载包及所有依赖到指定文件夹的步骤说明》为了方便开发和部署,我们常常需要将Python项目所依赖的第三方包导出到本地文件夹中,:本文主要介绍Pythonpip下载包及所有依... 目录步骤说明命令格式示例参数说明离线安装方法注意事项总结要使用pip下载包及其所有依赖到指定文件夹,请按照以