-
Notifications
You must be signed in to change notification settings - Fork 29
/
Code.txt
925 lines (781 loc) · 29.4 KB
/
Code.txt
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
comment: 主函数
@author: GanAH 2020/2/20.
@version 1.0.
@contact: [email protected]
"""
import sys, os
import time
from database.database import Database
if hasattr(sys, 'frozen'):
os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH']
from window import windowDS
from PyQt5.QtWidgets import QApplication, QMainWindow, QSplashScreen,QProgressBar
from PyQt5 import QtCore, QtGui
class SplashPanel(QSplashScreen):
def __init__(self):
super(SplashPanel, self).__init__()
message_font = QtGui.QFont()
message_font.setBold(True)
message_font.setPointSize(14)
self.setFont(message_font)
# 创建启动界面,支持png透明图片
self.setPixmap(QtGui.QPixmap("./source/Flash.png"))
# 淡入效果
self.setWindowOpacity(0)
t = 0
while t <= 50:
newOpacity = self.windowOpacity() + 0.06
if newOpacity > 1:
break
self.setWindowOpacity(newOpacity)
self.show()
t -= 1
time.sleep(0.04)
progressBar = QProgressBar(self)
progressBar.setGeometry(0,self.pixmap().height()-100,self.pixmap().width(),15)
progressBar.show()
# 启动信息
self.showMessage('加载配置文件...', alignment=QtCore.Qt.AlignBottom | QtCore.Qt.AlignCenter, color=QtCore.Qt.white)
# 加载配置文件
# Database().loadConfigJson()
for i in range(101):
progressBar.setValue(i)
if i == 81:
self.showMessage('加载系统配置...', alignment=QtCore.Qt.AlignBottom | QtCore.Qt.AlignCenter,
color=QtCore.Qt.white)
Database().loadConfigJson()
time.sleep(0.03)
time.sleep(0.01)
self.showMessage("完成所有配置文件载入,请稍等...", alignment=QtCore.Qt.AlignBottom | QtCore.Qt.AlignCenter,
color=QtCore.Qt.white)
time.sleep(1)
# 淡出效果
t = 0
while t <= 50:
newOpacity = self.windowOpacity() - 0.01
if newOpacity < 0:
break
self.setWindowOpacity(newOpacity)
t += 1
time.sleep(0.03)
# 关闭启动画面
# splash.close()
def mousePressEvent(self, evt):
pass
# 重写鼠标点击事件,阻止点击后消失
def mouseDoubleClickEvent(self, *args, **kwargs):
pass
# 重写鼠标双击事件,阻止出现卡顿现象
def enterEvent(self, *args, **kwargs):
pass
# 重写鼠标移动事件,阻止出现卡顿现象
def mouseMoveEvent(self, *args, **kwargs):
pass
# 重写鼠标移动事件,阻止出现卡顿现象
if __name__ == '__main__':
# 窗体构建
app = QApplication(sys.argv)
# 自适应分辨率
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
# 启动页面
splash = SplashPanel()
# 设置进程,启动加载页面时可以进行其他操作而不会卡死
app.processEvents()
MainWindow = QMainWindow()
# 界面重构存储区域
ui = windowDS.Ui_mainWindow()
ui.setupUi(MainWindow)
# MainWindow.show()
MainWindow.showMaximized()
splash.finish(MainWindow)
splash.deleteLater()
sys.exit(app.exec_())
#!usr/bin/env python
# -*- coding: utf-8 -*-
import os
def all_path(dirname,fileFilter = None):
result = []
for maindir, subdir, file_name_list in os.walk(dirname):
for filename in file_name_list:
apath = os.path.join(maindir, filename)
if fileFilter is None:
result.append(apath)
else:
if apath[-len(fileFilter):] == fileFilter:
result.append(apath)
return result
fileDir = r"E:\CodePrograme\Python\EMACS"
fileFilterList = all_path(fileDir,"py")
print(fileFilterList)
# 开始逐个打开并写入一个txt文件
resultF = open("Code.txt","w",encoding='UTF-8')
for i in range(len(fileFilterList)):
with open(fileFilterList[i],"r",encoding='UTF-8') as f:
print("now write:",fileFilterList[i])
for line in f:
resultF.write(line)
f.close()
print("finish write Files")
resultF.close()
"""
Demonstrates using custom hillshading in a 3D surface plot.
"""
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cbook
from matplotlib import cm
from matplotlib.colors import LightSource
import matplotlib.pyplot as plt
import numpy as np
filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)
with np.load(filename) as dem:
z = dem['elevation']
nrows, ncols = z.shape
x = np.linspace(dem['xmin'], dem['xmax'], ncols)
y = np.linspace(dem['ymin'], dem['ymax'], nrows)
x, y = np.meshgrid(x, y)
region = np.s_[1:500, 1:500]
x, y, z = x[region], y[region], z[region]
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
ls = LightSource(270, 45)
# To use a custom hillshading mode, override the built-in shading and pass
# in the rgb colors of the shaded surface calculated from "shade".
rgb = ls.shade(z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb,
linewidth=0, antialiased=False, shade=False)
plt.show()#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
comment: 临时中转数据库
@author: GanAH 2020/3/1.
@version 1.0.
@contact: [email protected]
"""
import json
import os
from database import ellipsoid
class Database(object):
# 基本配置文件信息
configJsonPath = "./source/para_json/config.json"
LicensePath = None
envir = "CPU"
default_envir = "CPU"
speaker = 0
default_speaker = 0
workspace = None
default_workspace = "./workspace/"
# 数据库文件路径
databaseFilePath = None
databaseDefaultFilePath = "./source/database/project.db"
# 椭球参数:a,b,偏心率e,第二偏心率e'
ellipsoid = None
userCheckEllipsoid = "WGS84"
# 地球自转角速度rad/s -RotationalAngularVelocity
earth_RAV = 7.29211511467e-5
# 光速 m/s
light_speed = 299792458
localHelpDocument = "./source/template/404.html"
onlineHelpLink = "https://www.ganahe.top/archives/measureSoftwareHelp.html"
baiduMapLinkPath = "./source/template/baiduMap.html"
mapJSVarPath = "./source/template/pointsVar.js"
userBaiduAK = None
userBaiduNK = None
# 铁路曲线计算RC文件路径
circulaiCurveCRFilePath = None
oFilePathList = []
nFilePathList = []
sppFilePathList = []
sp3FilePathList = []
# 解算后单点数据,类型为DataFrame
stationPositionDataFrame = None
# 重力场反演必要文件路径
inversionGroupFilePath = None
# 重力测量数据解算重力异常
gravityMeasureFilePath = None
grivatyModelPath = None
gravityAnomalyData = None
def loadConfigJson(self):
"""
加载Json配置文件
:return: None
"""
# 读取json文件内容,返回字典格式
with open(self.configJsonPath, 'r', encoding='utf8')as fp:
# with open('../source/para_json/config.json', 'r', encoding='utf8')as fp:
dict_data = json.load(fp)
fp.close()
Database.envir = dict_data["envir"]
Database.workspace = dict_data["workspace"]
Database.databaseFilePath = dict_data["databaseFilePath"]
Database.userCheckEllipsoid = dict_data["userCheckEllipsoid"]
# 保存椭球参数
Database.ellipsoid = ellipsoid.Ellipsoid(WGS84=ellipsoid.WGS84(dict_data["elliPara"]["WGS84_Ellipsoid"]),
CGCS2000=ellipsoid.CGCS2000(
dict_data["elliPara"]["CGCS2000_Ellipsoid"]),
krasovskiEllipsoid=ellipsoid.krasovskiEllipsoid(
dict_data["elliPara"]["krasovskiEllipsoid"]),
internationalEllipsoid_1975=ellipsoid.internationalEllipsoid_1975(
dict_data["elliPara"]["internationalEllipsoid_1975"]),
userPrivateEllipsoid=ellipsoid.userPrivateEllipsoid(
dict_data["elliPara"]["userPrivateEllipsoid"]), )
Database.LicensePath = dict_data["License"]
def writeJsonKeyValue(self, key1, value, key2=None):
"""
修改键值
:param key1: 键
:param value: 值
:param key2: 内键 主键为model时
:return:
"""
try:
with open(self.configJsonPath, "r") as f:
jsonData = json.load(f)
f.close()
if key1 == "model" and key2 != None: # json内字典
jsonData[key1][key2] = value
with open(self.configJsonPath, "w") as r:
json.dump(jsonData, r)
return True
elif key1 != "model" and key2 is None:
jsonData[key1] = value
with open(self.configJsonPath, "w") as r2:
json.dump(jsonData, r2)
return True
else:
return False
except Exception as e:
return e.__str__()
def connectDatabase(self):
# 创建一个cursor 游标(用于执行SQL语句)
# cursor = conn.cursor()
# # 执行SQL语句
# # 创建user表
# cursor.execute('create table user (id varchar(20) primary key, name varchar(20))')
# # 向表中插入数据
# cursor.execute('insert into user (id, name) values (\'1\', \'seven bai\')')
# # 执行查询语句
# cursor.execute('select * from user where id=?', ('1',))
# # rowcount返回影响的行数(可以在执行update,delete,inset后执行查看)
# cursor.rowcount
# # 查询结果
# values = cursor.fetchall()
# print(values)
# # 关闭cursor
# cursor.close()
# # 提交事务
# conn.commit()
# # 关闭数据库连接
# conn.close()
pass
# 坐标转换读入的原始数据
@property
def coorTranSourceData(self):
return self._coorTranSourceData
@coorTranSourceData.setter
def coorTranSourceData(self, fileReadData):
self._coorTranSourceData = fileReadData
@property
def coorTranTargetData(self):
return self._coorTranTargetData
@coorTranTargetData.setter
def coorTranTargetData(self, fileReadData):
self._coorTranTargetData = fileReadData
# 坐标系统转换原始坐标文件
coorSystemTranSourcePath = None
_publicPointNumber = 3
@property
def publicPointNumber(self):
return self._publicPointNumber
@publicPointNumber.setter
def publicPointNumber(self, count):
self._publicPointNumber = count
# 坐标转换结果
@property
def coorTranResultDict(self):
return self._coorTranResultDict
@coorTranResultDict.setter
def coorTranResultDict(self, resultDict):
self._coorTranResultDict = resultDict
@property
def coorTranResultFormatListData(self):
return self._coorTranResultFormatListData
@coorTranResultFormatListData.setter
def coorTranResultFormatListData(self, list):
self._coorTranResultFormatListData = list
@property
def targetPointName(self):
return self._coorTranResult
@targetPointName.setter
def targetPointName(self, resultList):
self._coorTranResult = resultList
# 徕卡数据
@property
def leicaSourceGsiData(self):
return self._leicaSourceGsiData
@leicaSourceGsiData.setter
def leicaSourceGsiData(self, gsiSourceStr):
self._leicaSourceGsiData = gsiSourceStr
@property
def leicaAnalysisDict(self):
return self._leicaAnalysisDict
@leicaAnalysisDict.setter
def leicaAnalysisDict(self, analysisDict):
self._leicaAnalysisDict = analysisDict
@property
def COSAControlNetMersureData(self):
return self._COSAControlNetMersureData
@COSAControlNetMersureData.setter
def COSAControlNetMersureData(self, kesaSourceData):
self._COSAControlNetMersureData = kesaSourceData
@property
def stableDotGroupMeasure_I(self):
return self.stableDotGroupMeasure_I
@stableDotGroupMeasure_I.setter
def stableDotGroupMeasure_I(self, measure_I):
self.stableDotGroupMeasure_I = measure_I
@property
def stableDotGroupMeasure_II(self):
return self.stableDotGroupMeasure_II
@stableDotGroupMeasure_II.setter
def stableDotGroupMeasure_II(self, measure_II):
self.stableDotGroupMeasure_II = measure_II
@property
def stablePointCoorGroup(self):
return self.stablePointCoorGroup
@stablePointCoorGroup.setter
def stablePointCoorGroup(self, coorGroup):
self.stablePointCoorGroup = coorGroup
@property
def filePath(self):
"""
#获取文件路径
#解释器,设定与获取类的静态属性,MVC模式
#
#注意这下杠杠!
#.....我服了,不然会调用错误,Java,c就没有你这么傲娇的语言
------10-15
垃圾明明是你变量名和函数名一致了! -----2019-12-29
:return:_filePath
"""
return self.path
@filePath.setter
def filePath(self, path):
"""
设定打开的文件路径
:param path:
:return:
"""
self.path = path
@property
def collect_vetc_time(self):
return self._collect_vetc_time
@collect_vetc_time.setter
def collect_vetc_time(self, etc_time):
self._collect_vetc_time = etc_time
@property
def lat_lon(self):
return self._lat_lon
@lat_lon.setter
def lat_lon(self, lat_lon):
self._lat_lon = lat_lon
@property
def earth_vetc(self):
return self._earth_vetc
@earth_vetc.setter
def earth_vetc(self, earthETC):
self._earth_vetc = earthETC
"""
# SPP导航电文及观测文件
"""
_navigationMessage = None
_satelliteObservations = None
@property
def navigationMess(self):
return self._navigationMessage
@navigationMess.setter
def navigationMess(self, navigationMssData):
self._navigationMessage = navigationMssData
@property
def satelliteObs(self):
return self._satelliteObservations
@satelliteObs.setter
def satelliteObs(self, setelliteObsver):
self._satelliteObservations = setelliteObsver
# 异常消息处理
_warnExceptionText = None
@property
def warnExceptionText(self):
return self._warnExceptionText
@warnExceptionText.setter
def warnExceptionText(self, exceptionText):
self._warnExceptionText = exceptionText
# 标准气象元素
_To = 20 # 摄氏度
_Po = 1013.25 # mbar
_RHo = 0.5
@property
def standardMeteorologicalElement(self):
"""
获取内部存储的标准气象元素
:return: list [To,Po,RHo]
"""
return [self._To, self._Po, self._RHo]
@standardMeteorologicalElement.setter
def standardMeteorologicalElement(self, listElement):
"""
设定标准气象元素
:param listElement: len = 3,[To,Po,RHo]
"""
self._To = listElement[0]
self._Po = listElement[1]
self._RHo = listElement[2]
"""
# 地球磁北极坐标,单位:度 在初始化时进行检查更新!
"""
_fia_earth = 79.93
_lambda_earth = 288.04
@property
def earth_N_pole_coor(self):
return self._fia_earth, self._lambda_earth
@earth_N_pole_coor.setter
def earth_N_pole_coor(self, fia_earth_N_pole, lamda_earth_N_pole):
self._fia_earth = fia_earth_N_pole
self._lambda_earth = lamda_earth_N_pole
"""
# RINEX 文件状态
# 存在: 1 /否: 0
# 文件状态 - 正常: 1 /否: 0
"""
Nfile_exist = 0
Nfile_status = 1
Ofile_exist = 0
Ofile_status = 1
@property
def RINEX_status(self, file_type):
"""
获取卫星文件状态信息
:param file_type: O-obverseFile ; N-navagate;
:return:exist_code:0;1
"""
if file_type == "N":
return self.Nfile_exist, self.Nfile_status
elif file_type == "O":
return self.Ofile_exist, self.Ofile_status
else:
return -1
@RINEX_status.setter
def RINEX_status(self, file_type, exist_code, status_code):
"""
设定文件状态信息
:param file_type: O-obverseFile ; N-navagate;
:param exist_code: 1-exist;0-not exist
:param status_code:1-ok;0-false
:return: boolean
"""
# print("执行了?")
if file_type == "N":
print("测试数据库", exist_code, status_code)
self.Nfile_exist = exist_code
self.Nfile_status = status_code
print("测试数据库", self.Nfile_exist, self.Nfile_status)
return True
elif file_type == "O":
self.Ofile_exist = exist_code
self.Ofile_status = status_code
return True
else:
return False
def getSppFilePath(self, type=None):
if type.lower() == "o":
return self.oFilePathList
elif type.lower() == "n":
return self.nFilePathList
else:
return self.sppFilePathList
def setSppFilePath(self, fileList):
# 清空数据
Database.oFilePathList = []
Database.nFilePathList = []
Database.sppFilePathList = []
# 从文件列表查找相同名组
while len(fileList) > 1:
i = 1
if len(fileList) > 1:
dirIndex, fileNameSaveIndex = os.path.split(fileList[0])
dirSerch, fileNameSaveSerch = os.path.split(fileList[i])
# 找到同名文件数据组
if fileNameSaveIndex[:-1] == fileNameSaveSerch[:-1]:
if fileNameSaveIndex[-1].lower() == "o" and fileNameSaveSerch[-1].lower() == "n":
Database.oFilePathList.append(fileList[0])
Database.nFilePathList.append(fileList[i])
elif fileNameSaveIndex[-1].lower() == "n" and fileNameSaveSerch[-1].lower() == "o":
Database.oFilePathList.append(fileList[i])
Database.nFilePathList.append(fileList[0])
# 删除该位置数据
fileList.pop(i)
fileList.pop(0)
else:
fileList.pop(0)
i += 1
def setPppFilePath(self, fileList):
# 清空数据
Database.oFilePathList = []
Database.sp3FilePathList = []
# 从文件列表查找相同名组
while len(fileList) > 0:
dirIndex, fileName = os.path.split(fileList[0])
if fileName[-1].lower() == "o":
Database.oFilePathList.append(fileList[0])
if fileName[-1].lower() == "3":
Database.sp3FilePathList.append(fileList[0])
# 删除该位置数据
fileList.pop(0)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
"""
comment:数据处理集合
@author: GanAH 2019/9/27.
@version 1.0.
@contact: [email protected]
"""
import sys
from PyQt5 import QtWidgets
class DataFilter(object):
app = QtWidgets.QApplication(sys.argv)
textArea = QtWidgets.QTextEdit()
headEndSign = "END OF HEADER"
def __init__(self,textArea):
self.textArea = textArea
def staLocation(sourceArrayStrCoor):
"""
单星历数据处理
第一行为星历信息
后七条为广播轨道
:param sourceArrayStrCoor: 传入的未处理原始字符数据
:return: para:已处理的结果数据
"""
# 广播轨道数据存储
filterResult = [[0] * 4 for da in range(7)]
for i in range(8):
PRN_time = [0, 0, 0, 0]
rowData = [0, 0, 0, 0]
# 如果为第一行星历数据
if i == 0:
print(re.split('[\s]', sourceArrayStrCoor[i].strip()))
strPrn = re.split('[\s]', sourceArrayStrCoor[i].strip())
PRN_time[0] = strPrn[0]
PRN_time[1] = strPrn[9]
PRN_time[2] = strPrn[10]
PRN_time[3] = strPrn[11]
# 广播轨道数据
else:
for j in range(4):
if j == 0:
rowData[j] = sourceArrayStrCoor[i][3:22]
else:
rowData[j] = sourceArrayStrCoor[i][(j - 1) * 19 + 22:j * 19 + 22]
filterResult[i - 1] = rowData
# 数据处理结果存入,循环i次,但第一次开始才是广播轨道数据
return PRN_time, filterResult
def twoMISstringToFloat(self, twoMISstrArray):
"""
字符串数据转float型
:return: float
"""
# 获取长度
arrayLen = len(twoMISstrArray)
arraychildLen = len(twoMISstrArray[0])
floatArray = [[0] * 4 for da in range(7)]
# 开始转换
for i in range(arrayLen):
for j in range(arraychildLen):
floatArray[i][j] = float(twoMISstrArray[i][j])
return floatArray
def igsDataFilter(self, listDatas):
"""
IGS电离层数据清洗
:param listData:list--data
:return: dic-->headStr,list-->dayETC,
"""
textArea = self.textArea
"""
# 头文件处理体
# 获取头文件结束位置(行号),传递给第二循环体:数据清洗体
"""
# 限定参数
listData = listDatas
headLineEndIndex = 0
for i in range(len(listData)): # 划分文件
presentLine = listData[i].strip() # 逐行处理,除去字符串首前尾后的空格,字符串内部不计入
if presentLine == self.headEndSign:
headLineEndIndex = i
break
"""
# 采集数据清洗体
#字典存储ETC
:key:时间(hours)及组号
:keyword:不同经度的TEC(-180~180°每隔5°采集)
"""
start_etc_map = "STARTOFTECMAP"
time_list_index = []
TIME_LON_LAT_ETC = []
for i in range(headLineEndIndex + 1, len(listData)):
etc_map_line = listData[i].replace(" ", "") # 去除所有的空格
# print("测试:"+etc_map_line)
if (start_etc_map in etc_map_line) is True:
"""
#不同时间分组处理头数据:组别listData【i】/时间listData【i+1】/及排序listData【i+2】
#说明:years + months + days + hours + etc_list_number
# i 为匹配的行号,从当前匹配的位置起算三行为预处理数据
"""
# 分隔
etc_list_number = listData[i].split()[0]
textArea.append("\n匹配位置:"+str(i)+ "对应序号:" + str(etc_list_number))
timeList = listData[i + 1].split()
textArea.append("时间戳:"+str( timeList))
child_head = timeList[0] + "-" + timeList[1] + "-" + timeList[2] + "-" + timeList[
3] + "-" + etc_list_number
textArea.append(child_head)
#去除时间列表无关信息
timeList = list(timeList)
for i in range(4):
'''
#循环pop的话,默认pop尾数(栈顶)
# 如按序号pop,需要注意每次pop后总长度已经减小
'''
timeList.pop()
time_list_index.append(timeList)
"""
# 确定组别范围后,内循环获取该组内数据
# 开始位置:i+1 为 START OF TECMAP的下一个:采集数据处的经纬度-高程
"""
end_etc_map = "ENDOFTECMAP"
lat_lon_H = "LAT/LON1/LON2/DLON/H"
list_ETC_lat_index = []
list_ETC_lat_data = []
for no in range(i + 2, len(listData)): # 遇到start etc map,从i+2即每单元开始记录
list_end_control = listData[no].replace(" ", "")
if (lat_lon_H in list_end_control) is True: #遇头分划另类处理输出
textArea.append("---文件划分---")
textArea.append(str(etc_list_number)+ "组"+str( no)+ "行::"+ str(self.__lat_lon_etc(listData[no])))
# 删除说明注释LAT/LON1/LON2/DLON/H的纬度头文件并存入,重复13次,可优化
listPop = self.__lat_lon_etc(listData[no])
listPop.pop(5)
list_ETC_lat_index.append(listPop)
#内部小循环取相同纬度下不同经度数据
#
list_lat = []
for latRound in range(no+1,no+6):
datalist = listData[latRound].split()
for indexData in range(len(datalist)):
list_lat.append(datalist[indexData])
#加入总数组
TIME_LON_LAT_ETC.append(list_lat)
#完成,加入总数组
list_ETC_lat_data.append(list_lat)
elif(end_etc_map in list_end_control) is True: #遇尾不输出,跳出当前小循环
textArea.append("时间切换,下一个采集时间:------------------")
break
else:
textArea.append(str(etc_list_number)+ "组"+str( no)+"行::"+str(listData[no].split()))
"""
# 文件循环结束,外循环退出
# 标志:ENDOFFILE
"""
end_of_file = "ENDOFFILE"
if (end_of_file in etc_map_line) is True:
textArea.append("\n文件清洗结束!!!!!!!!!!!\n")
break
textArea.append("\n===========最终结果:==========")
# print(" 时间:",time_list_index)
# print("经纬度:", list_ETC_lat_index)
# print("三维数据:",TIME_LON_LAT_ETC)
# print("长度:",len(TIME_LON_LAT_ETC),len(TIME_LON_LAT_ETC[0]))
#返回清洗的数据结果
return time_list_index,list_ETC_lat_index,TIME_LON_LAT_ETC
def __lat_lon_etc(self, list_lat_lon):
"""
将不同经度的ETC分隔返回
:param list_lat_lon:单纬度数据 str
<p>-87.5-180.0 180.0 5.0 450.0 LAT/LON1/LON2/DLON/H
:return:单行分隔数据结果
"""
splitLAT_LON = [0, 0, 0, 0, 0,0] # 13*5
for i in range(5):
if i == 0:
splitLAT_LON[i] = list_lat_lon[0:8]
else:
splitLAT_LON[i] = list_lat_lon[(i - 1) * 6 + 8:i * 6 + 8]
splitLAT_LON[5] = "LAT/LON1/LON2/DLON/H"
return splitLAT_LON
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
comment: 椭球参数类
@author: GanAH 2020/7/25.
@version 1.0.
@contact: [email protected]
"""
class Ellipsoid(object):
def __init__(self, WGS84=None, CGCS2000=None, internationalEllipsoid_1975=None, krasovskiEllipsoid=None,
userPrivateEllipsoid=None):
self.WGS84 = WGS84
self.CGCS2000 = CGCS2000
self.internationalEllipsoid_1975 = internationalEllipsoid_1975
self.krasovskiEllipsoid = krasovskiEllipsoid
self.userPrivateEllipsoid = userPrivateEllipsoid
class WGS84(object):
def __init__(self,paraList):
self.a = paraList[0]
self.b = paraList[1]
# 扁率α
self.alpha = paraList[2]
self.e = paraList[3]
self.dot_e = paraList[4]
self.c = self.a * self.a / self.b
class CGCS2000(object):
def __init__(self,paraList):
self.a = paraList[0]
self.b = paraList[1]
# 扁率α
self.alpha = paraList[2]
self.e = paraList[3]
self.dot_e = paraList[4]
self.c = self.a * self.a / self.b
class internationalEllipsoid_1975(object):
def __init__(self,paraList):
self.a = paraList[0]
self.b = paraList[1]
# 扁率α
self.alpha = paraList[2]
self.e = paraList[3]
self.dot_e = paraList[4]
self.c = self.a * self.a / self.b
class krasovskiEllipsoid(object):
def __init__(self,paraList):
self.a = paraList[0]
self.b = paraList[1]
# 扁率α
self.alpha = paraList[2]
self.e = paraList[3]
self.dot_e = paraList[4]
self.c = self.a * self.a / self.b
class userPrivateEllipsoid(object):
def __init__(self, paraList):
self.a = paraList[0]
self.b = paraList[1]
# 扁率α
self.alpha = paraList[2]
self.e = paraList[3]
self.dot_e = paraList[4]
self.c = self.a * self.a / self.b#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
comment:
@author: GanAH 2020/3/1.
@version 1.0.
@contact: [email protected]
"""