import copy
from datetime import datetime
from datetime import timedelta
from dateutil import parser
import matplotlib
matplotlib.use('TKAgg')
import matplotlib.pyplot as plt
import numpy as np
from numpy import mean
from tkinter import *
import time
import math
satellite=["sat0","sat1","sat2","sat3","sat4","sat5","sat6","sat7","sat8"]
address_name=["Abidjan","Accra","Asmara","Balikpapan","Bozeman","Crystal-Lake","Elk-City","Hanahan","Iquique",
"Lhasa","Madras","Manaus","Mangalore","Minsk","Munchen","Parole","Recife","Rio-de-Janeiro",
"Sarajevo","Wallingford-Center","Yaounde","北京","南宁","武汉"]
address_position={"Abidjan":[-4.02+360,5.32],"Accra":[-0.2+360,5.56],"Asmara":[15.33,38.97],"Balikpapan":[116.86,-1.21],
"Bozeman":[-111.04+360,45.68],"Crystal-Lake":[-88.33+360,42.23],"Elk-City":[-99.41+360,35.4],"Hanahan":[-80.01+360,32.93],
"Iquique":[-69.91+360,-20.26],"Lhasa":[91.13,29.65],"Madras":[80.25,13.06],"Manaus":[-60.01+360,-3.12],
"Mangalore":[75.16,12.95],"Minsk":[27.58,53.9],"Munchen":[11.54,48.14],"Parole":[-76.55+360,38.98],
"Recife":[-34.91+360,-8.09],"Rio-de-Janeiro":[-43.46+360,-22.72],"Sarajevo":[18.43,43.87],"Wallingford-Center":[-72.82+360,41.45],
"Yaounde":[11.51,3.87],"北京":[116.39,39.91],"南宁":[108.33,22.8],"武汉":[114.28,30.57]}
dict_circle={"sat0":[],"sat1":[],"sat2":[],"sat3":[],"sat4":[],"sat5":[],"sat6":[],"sat7":[],"sat8":[]}#每个卫星覆盖的圆,【时间,经度,纬度】
address_timewindow={"Abidjan":[],"Accra":[],"Asmara":[],"Balikpapan":[],"Bozeman":[],"Crystal-Lake":[],"Elk-City":[],"Hanahan":[],"Iquique":[],
"Lhasa":[],"Madras":[],"Manaus":[],"Mangalore":[],"Minsk":[],"Munchen":[],"Parole":[],"Recife":[],"Rio-de-Janeiro":[],"Sarajevo":[],"Wallingford-Center":[],"Yaounde":[],"北京":[],"南宁":[],"武汉":[]}#每个地点对应的窗口时间
address_single_timewindow={}
address_double_timewindow = {"Abidjan": [], "Accra": [], "Asmara": [], "Balikpapan": [], "Bozeman": [],
"Crystal-Lake": [], "Elk-City": [], "Hanahan": [], "Iquique": [],
"Lhasa": [], "Madras": [], "Manaus": [], "Mangalore": [], "Minsk": [], "Munchen": [],
"Parole": [], "Recife": [], "Rio-de-Janeiro": [], "Sarajevo": [],
"Wallingford-Center": [], "Yaounde": [], "北京": [], "南宁": [], "武汉": []}
address_freetime = {"Abidjan": [], "Accra": [], "Asmara": [], "Balikpapan": [], "Bozeman": [], "Crystal-Lake": [],
"Elk-City": [], "Hanahan": [], "Iquique": [],
"Lhasa": [], "Madras": [], "Manaus": [], "Mangalore": [], "Minsk": [], "Munchen": [],
"Parole": [], "Recife": [], "Rio-de-Janeiro": [], "Sarajevo": [], "Wallingford-Center": [],
"Yaounde": [], "北京": [], "南宁": [], "武汉": []}#间隙
max_freetime=[]#最大时间间隙
ave_freetime=[]#平均时间间隙
def getshijiancha(str1,str2):
#datetime.strptime是日期形式,相减之后变成datedelta时间差形式
#输入str,返回时间差
timetmp1=datetime.strptime(str(datetime.strptime(str1, '%Y/%m/%d,%H:%M:%S')-datetime.strptime(str2, '%Y/%m/%d,%H:%M:%S')),'%H:%M:%S')
return(timetmp1.hour * 3600 + timetmp1.minute * 60 + timetmp1.second)
def date2second(str):
str=datetime.strptime(str, '%Y/%m/%d,%H:%M:%S')
return (str.hour * 3600 + str.minute * 60 + str.second)
def dataprocessing():#传入相关的卫星和地点
global address_single_timewindow
for sat in dict_circle:
time = datetime(2022, 1, 1, 0, 0, 0) # 起始时间
file = open('Data/SatelliteInfo/SatCoverInfo_' + sat[3] + '.txt')
lines = file.readlines()
i = 0
while (i < len(lines)):
point = [] # 时间,圆心精度,圆心维度,半径
min1 = lines[i + 6].split() # 前为经度最小值,后为纬度
max1 = lines[i + 16].split() # 前为经度最大值,后为纬度
r = (float(max1[0]) - float(min1[0])) / 2
center = r + float(min1[0]) # 圆心的经度
point.append(time.strftime("%Y/%m/%d,%H:%M:%S"))
point.append(center)
point.append(float(min1[1]))
point.append(r)
dict_circle[sat].append(point)
time = time + timedelta(seconds=1) # 时间+1s
i += 22
# break#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1测试点,记得删掉
start = 0
end = 0
# 地点经度:address_position[address][0],地点纬度:address_position[address][1]
# 卫星覆盖圆心:dict_circle[circle][t][1],dict_circle[circle][t][2]
# 半径:dict_circle[circle][t][3]
for address in address_position:
for circle in dict_circle:
for t in range(0, 86401):
if (start == 0): # 还没找到开始的时间窗口,则加入开始时间
if ((address_position[address][0] - dict_circle[circle][t][1]) ** 2 +
(address_position[address][1] - dict_circle[circle][t][2]) ** 2) <= 49.07:
start = dict_circle[circle][t][0]
elif ((start != 0) and (end == 0)): # 还没找到结束的时间窗口,则加入结束时间
if ((address_position[address][0] - dict_circle[circle][t][1]) ** 2 +
(address_position[address][1] - dict_circle[circle][t][2]) ** 2) > 49.07:
end = dict_circle[circle][t][0]
address_timewindow[address].append([circle, start, end])
start = end = 0
# print(address_timewindow["Abidjan"])
# 计算时间窗口
# repeat:重叠时间段
repeat = {"Abidjan": [], "Accra": [], "Asmara": [], "Balikpapan": [], "Bozeman": [], "Crystal-Lake": [],
"Elk-City": [], "Hanahan": [], "Iquique": [],
"Lhasa": [], "Madras": [], "Manaus": [], "Mangalore": [], "Minsk": [], "Munchen": [], "Parole": [],
"Recife": [], "Rio-de-Janeiro": [], "Sarajevo": [], "Wallingford-Center": [], "Yaounde": [], "北京": [],
"南宁": [], "武汉": []}
tmp = 0
for address in address_timewindow:
for i in range(0, len(address_timewindow[address])):
for t in range(i + 1, len(address_timewindow[address])):
if ((address_timewindow[address][t][2] <= address_timewindow[address][i][1]) or (
address_timewindow[address][t][1] >= address_timewindow[address][i][2])):
continue
repeat[address].append([i, t])#记录重叠的时间窗口的序号,以配对形式记录
# for address in address_timewindow:
# address_single_timewindow[address]=address_timewindow[address]
address_single_timewindow=copy.deepcopy(address_timewindow)
jiaoji = []
# for address in repeat:
# print(repeat[address])
for address in repeat:
if (repeat[address]):
# 按照重叠卫星的第二个降序排列,这样先删除后面的元素不会影响前面的元素
repeat[address] = sorted(repeat[address], key=lambda x: x[1], reverse=True)
for timedui in repeat[address]:
# print(type(address_single_timewindow[address][timedui[0]][1]))
# print(address_single_timewindow[address][timedui[0]][1])
# 求并集
address_single_timewindow[address][timedui[0]][1] = min(address_timewindow[address][timedui[0]][1],
.whl
- 粉丝: 3923
- 资源: 4859
最新资源
- 基于树莓派的人脸识别全部资料+详细文档+高分项目.zip
- 基于树莓派的甲醛,二氧化碳等环境监控全部资料+详细文档+高分项目.zip
- 基于树莓派的实时图传&数传(天空端)全部资料+详细文档+高分项目.zip
- 基于树莓派的食堂点餐系统嵌入式课设,全部资料+详细文档+高分项目.zip
- 基于树莓派的双目视觉智能小车全部资料+详细文档+高分项目.zip
- 基于树莓派的延时摄影程序全部资料+详细文档+高分项目.zip
- 基于树莓派和NODE的智能镜子项目全部资料+详细文档+高分项目.zip
- 基于树莓派的医疗语音识别应用全部资料+详细文档+高分项目.zip
- 基于树莓派使用运营商网络的免流量WIFI路由器全部资料+详细文档+高分项目.zip
- 基于树莓派网页控制LED和视频监控的项目全部资料+详细文档+高分项目.zip
- 基于树莓派实现ADIS16505 IMU的数据采集全部资料+详细文档+高分项目.zip
- 基于腾讯云IOT平台实现树莓派上面的蜂鸣器控制全部资料+详细文档+高分项目.zip
- 焊接机器人的分类及应用 - .pdf
- 焊接机器人工作站系统中焊接工艺的设计 - .pdf
- 焊接机器人工作站系统设计原则探讨 - .pdf
- 焊接机器人工作站在VHS高速列车转向架构架生产中的应用 - .pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈