-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgnss绘制指定区域.py
141 lines (135 loc) · 4.98 KB
/
gnss绘制指定区域.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*- coding: utf-8 -*-
# @Time : 2022/1/3 14:21
# @Author : xymeng
# @FileName: 001.py 绘制TEC等值线专用程序
# @Link : 原文链接:https://blog.csdn.net/absll/article/details/127837253
# @Software: PyCharm
import os
import matplotlib.pyplot as plt
import numpy as np
'''
绘图区域在指定经纬度5°的范围
'''
span = 5
Lat = input('请输入纬度:'.format())
Lon = input('请输入经度:'.format())
Latdown = int(Lat) - span
Londown = int(Lon) - span
Latup = int(Lat) + span
Lonup = int(Lon) + span
counLat = int(2 * (span / 2.5))
counLon = int(2 * (span / 5))
numlat = int((90 - int(Lat)) / 2.5) + 2
print(counLat)
print(counLon)
print(numlat)
'''
store the lat,lon,and,TEC value
'''
lat = []
lon = []
TEC0 = []
TEC = []
TEC2D = np.zeros(shape=(counLat, counLon))
picnum = 1
timenum = 1
num1 = 0
folder = r'/Users/ming/Downloads/AFG_rrd/'
'''
定义初始经纬度
'''
Lon0 = -180.0
Lat0 = 90
'''
Search for each ionex file
'''
for ifile in os.listdir(folder):
'''
num: Record the count of the region
count: Record the count of the Map
'''
num = 1
count = 1
timenum = 0
path = os.path.join(folder, ifile)
print(path)
with open(path, 'r', encoding='ISO-8859-1') as ionex:
icontent0 = ionex.readlines()
for i in range(len(icontent0)):
'''
Turn list including other symbol into list only consisting of character
'''
icontent1 = icontent0[i].split(' ')
for x in range(icontent1.count('')):
icontent1.remove('')
if len(icontent1) >= 5:
if icontent1[-1] == 'LAT/LON1/LON2/DLON/H\n' and num <= counLat and count <= 13:
deltla = 2.5
deltlo = 5
num1 = num1 + 1
lat0 = Lat0 - (deltla * num1)
print(num1)
print(lat0)
if num1 <= numlat:
if lat0 >= Latdown and lat0 <= Latup:
lat.append(lat0)
num = num + 1
'''
Begin putting TEC value into TEC list
'''
ynum = 0
for y in range(1, 6):
print('xxx')
tecvalue1 = icontent0[i + y].split(' ')
for z in range(tecvalue1.count('')):
tecvalue1.remove('')
for lo in range(len(tecvalue1)):
if (Lon0 >= Londown) and (Lon0 <= Lonup):
print(tecvalue1[lo])
lon.append(Lon0)
TEC2D[num - 2][ynum] = int(tecvalue1[lo])
ynum = ynum + 1
Lon0 = Lon0 + deltlo
Lon0 = -180
elif (num1 > numlat) and num1 <= (71 - numlat):
pass
if num >= (counLat + 1):
if num1 <= numlat:
timenum = timenum + 1
lonfin = list(set(lon))
lonfin.sort(key=lon.index)
print(lonfin)
print(lat)
LON, LAT = np.meshgrid(lonfin, lat)
plt.figure()
plt.contourf(LON, LAT, TEC2D, 8, cmap='plasma')
C = plt.contour(LON, LAT, TEC2D, 8, cmap='plasma')
# 添加标记,标记处不显示轮廓线,颜色为黑色,保留两位小数
plt.clabel(C, inline=True, colors='k', fmt='%1.2f')
path = 'F:/contour-outcome-region' + '/' + str(picnum) + '/'
if not os.path.exists(path): # 如果不存在路径,则创建这个路径
os.makedirs(path)
plt.savefig(path + '/' + str(timenum) + '.jpg')
plt.close()
elif (num1 > numlat) and num1 <= 71:
print('elif')
pass
else:
print('else')
num = 1
num1 = 0
count = count + 1
lon.clear()
lat.clear()
TEC = list(TEC)
TEC.clear()
TEC2D = np.zeros(shape=(counLat, counLon))
Lon0 = -180.0
Lat0 = 90
picnum = picnum + 1
lon.clear()
lat.clear()
TEC.clear()
TEC2D = np.zeros(shape=(counLat, counLon))
Lon0 = -180.0
Lat0 = 90