-
Notifications
You must be signed in to change notification settings - Fork 0
/
splitApref.py
65 lines (57 loc) · 1.88 KB
/
splitApref.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
#!/usr/bin/env python3
""" This script splits the APREF solution in two. It creates two SINEX files,
one for stations with more than 2 years of data and one for the rest. The second
one keeps two stations from the first as constraints
Requirements:
- GMT program gmtselect
- GA program rdsinex
Usage: splitAPREF.py
"""
from geodepy import gnss
import os
# Read in the solution epoch
epochs = {}
epochs_block = gnss.read_sinex_solution_epochs_block('SNXEPO.SNX')
for epoch in epochs_block:
if epoch[1:9] != 'SOLUTION' and epoch[0] != '*':
stat = epoch[1:5]
start = epoch[16:28]
if start[0:1] == '9':
start = '19' + start
else:
start = '20' + start
end = epoch[29:41]
if end[0:1] == '9':
end = '19' + end
else:
end = '20' + end
try:
epochs[stat].append(start)
epochs[stat].append(end)
except KeyError:
epochs[stat] = []
epochs[stat].append(start)
epochs[stat].append(end)
# Calculate the time series durations and add appropriate list: con for 2 years
# or more and noncon for the rest
exclude = ['CEDU', 'MAC1', 'HOBA', 'CA19']
con = []
noncon = []
for key, value in epochs.items():
value.sort()
duration = int(value[-1][0:4]) - int(value[0][0:4])
if value[0][5:8] > value[-1][5:8]:
duration -= 1
# These two stations link the con and noncon networks, as they are
# included in both
if key == 'KALG' or key == '21NA':
continue
if duration < 2 or key in exclude:
noncon.append(key)
else:
con.append(key)
# Create the two SINEX files with the stns in the supplied list removed
gnss.remove_stns_sinex('SNXEPO.SNX', con)
os.rename('output.snx', 'SNXEPO.SNX.NONCON.AUS')
gnss.remove_stns_sinex('SNXEPO.SNX', noncon)
os.rename('output.snx', 'SNXEPO.SNX.CON.AUS')