当前位置: 首页 > news >正文

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:
        pass
    else:
        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 = 6
    covdef.Grid.Resolution.LatLon = 6
    covdef.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])
    pass

plt.plot(x,y)

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

结语

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

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

相关文章:

  • 基于OpenHarmony/HarmonyOS操作系统的ArkUI框架深入学习——开篇1
  • WebSocket| Netty netty-websocket-spring-boot-starter
  • C语言for循环结构经典练习
  • 【老生谈算法】matlab实现元胞自动机算法源码——元胞自动机
  • wireshark协议或者协议内容解码异常
  • nginx部署vue项目(包括一个nginx部署多个vue项目)
  • 【py】[打包exe]用auto-py-to-exe将py程序打包为exe文件
  • 【数据库迁移系列】使用pgloader将数据从MySQL迁移到openGauss的最佳实践
  • 广和通携智慧金融解决方案惊艳亮相紫光展锐2022金融支付生态论坛
  • 安装Java环境
  • vue(js)拖拽事件的drop失效
  • RFID技术,让书架智能化
  • Android 导出PDF PdfDocument
  • 《kaggle竞赛攻顶秘笈》 | 任务种类 | 任务评价指标 | 评价指标与目标函数 | 评价指标最佳化
  • 干货:秒懂redis集群
  • [译]Python中的类属性与实例属性的区别
  • “Material Design”设计规范在 ComponentOne For WinForm 的全新尝试!
  • 《用数据讲故事》作者Cole N. Knaflic:消除一切无效的图表
  • 【Leetcode】104. 二叉树的最大深度
  • Js基础知识(一) - 变量
  • js继承的实现方法
  • js中forEach回调同异步问题
  • LeetCode541. Reverse String II -- 按步长反转字符串
  • Meteor的表单提交:Form
  • node 版本过低
  • Nodejs和JavaWeb协助开发
  • PyCharm搭建GO开发环境(GO语言学习第1课)
  • python3 使用 asyncio 代替线程
  • React 快速上手 - 06 容器组件、展示组件、操作组件
  • SQL 难点解决:记录的引用
  • 基于webpack 的 vue 多页架构
  • 猫头鹰的深夜翻译:Java 2D Graphics, 简单的仿射变换
  • 盘点那些不知名却常用的 Git 操作
  • 设计模式走一遍---观察者模式
  • 说说动画卡顿的解决方案
  • 思否第一天
  • 学习Vue.js的五个小例子
  • Hibernate主键生成策略及选择
  • ​LeetCode解法汇总307. 区域和检索 - 数组可修改
  • #[Composer学习笔记]Part1:安装composer并通过composer创建一个项目
  • #LLM入门|Prompt#3.3_存储_Memory
  • #QT项目实战(天气预报)
  • $.ajax()
  • (13)Latex:基于ΤΕΧ的自动排版系统——写论文必备
  • (23)Linux的软硬连接
  • (Matlab)使用竞争神经网络实现数据聚类
  • (二) Windows 下 Sublime Text 3 安装离线插件 Anaconda
  • (二)WCF的Binding模型
  • (附源码)计算机毕业设计SSM教师教学质量评价系统
  • (六)什么是Vite——热更新时vite、webpack做了什么
  • (提供数据集下载)基于大语言模型LangChain与ChatGLM3-6B本地知识库调优:数据集优化、参数调整、Prompt提示词优化实战
  • (转)C语言家族扩展收藏 (转)C语言家族扩展
  • (总结)Linux下的暴力密码在线破解工具Hydra详解
  • .NET Compact Framework 多线程环境下的UI异步刷新
  • .NET Core中的去虚