geode-gnss 1.2.48__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. geode/ConvertRaw.py +201 -0
  2. geode/Utils.py +1286 -0
  3. geode/__init__.py +52 -0
  4. geode/agglomerative.py +365 -0
  5. geode/cluster.py +665 -0
  6. geode/dbConnection.py +559 -0
  7. geode/elasticity/DLN_func.py +1168 -0
  8. geode/elasticity/__init__.py +5 -0
  9. geode/elasticity/data/EarthCore.txt +25 -0
  10. geode/elasticity/data/EarthMantle56.txt +57 -0
  11. geode/elasticity/data/PB2002_plates.json +113 -0
  12. geode/elasticity/data/REF_6371_loading_love_numbers_0_40000.txt +40002 -0
  13. geode/elasticity/data/ne_50m_land.README.html +391 -0
  14. geode/elasticity/data/ne_50m_land.VERSION.txt +1 -0
  15. geode/elasticity/data/ne_50m_land.cpg +1 -0
  16. geode/elasticity/data/ne_50m_land.dbf +0 -0
  17. geode/elasticity/data/ne_50m_land.prj +1 -0
  18. geode/elasticity/data/ne_50m_land.shp +0 -0
  19. geode/elasticity/data/ne_50m_land.shx +0 -0
  20. geode/elasticity/diskload.py +600 -0
  21. geode/elasticity/elastic_gridder.py +826 -0
  22. geode/elasticity/elastic_interpolation.py +440 -0
  23. geode/elasticity/green_func.py +434 -0
  24. geode/elasticity/rectloadhs.py +601 -0
  25. geode/etm/__init__.py +0 -0
  26. geode/etm/core/__init__.py +0 -0
  27. geode/etm/core/data_classes.py +379 -0
  28. geode/etm/core/etm_config.py +377 -0
  29. geode/etm/core/etm_engine.py +611 -0
  30. geode/etm/core/etm_stacker.py +3196 -0
  31. geode/etm/core/etm_stacker_vce.py +955 -0
  32. geode/etm/core/jump_manager.py +311 -0
  33. geode/etm/core/logging_config.py +22 -0
  34. geode/etm/core/s_score.py +158 -0
  35. geode/etm/core/type_declarations.py +170 -0
  36. geode/etm/data/__init__.py +0 -0
  37. geode/etm/data/etm_database.py +143 -0
  38. geode/etm/data/solution_data.py +704 -0
  39. geode/etm/etm_functions/__init__.py +0 -0
  40. geode/etm/etm_functions/auto_jumps.py +182 -0
  41. geode/etm/etm_functions/etm_function.py +165 -0
  42. geode/etm/etm_functions/jumps.py +522 -0
  43. geode/etm/etm_functions/periodic.py +183 -0
  44. geode/etm/etm_functions/polynomial.py +133 -0
  45. geode/etm/etm_functions/stochastic_signal.py +76 -0
  46. geode/etm/least_squares/__init__.py +0 -0
  47. geode/etm/least_squares/design_matrix.py +258 -0
  48. geode/etm/least_squares/least_squares.py +880 -0
  49. geode/etm/least_squares/ls_collocation.py +62 -0
  50. geode/etm/least_squares/sva.py +202 -0
  51. geode/etm/test.py +132 -0
  52. geode/etm/visualization/__init__.py +0 -0
  53. geode/etm/visualization/data_classes.py +106 -0
  54. geode/etm/visualization/data_prep.py +230 -0
  55. geode/etm/visualization/etm_plotting.py +296 -0
  56. geode/etm/visualization/histogram_template.py +156 -0
  57. geode/etm/visualization/plot_fields.py +616 -0
  58. geode/etm/visualization/time_series_template.py +245 -0
  59. geode/gamit/__init__.py +0 -0
  60. geode/gamit/gamit_config.py +117 -0
  61. geode/gamit/gamit_session.py +461 -0
  62. geode/gamit/gamit_task.py +808 -0
  63. geode/gamit/globk_task.py +229 -0
  64. geode/gamit/parse_ztd.py +126 -0
  65. geode/gamit/station.py +481 -0
  66. geode/gamit/ztd.py +230 -0
  67. geode/metadata/__init__.py +0 -0
  68. geode/metadata/igslog.py +478 -0
  69. geode/metadata/station_info.py +1181 -0
  70. geode/network.py +402 -0
  71. geode/plots.py +181 -0
  72. geode/proto_download.py +483 -0
  73. geode/pyArchiveStruct.py +460 -0
  74. geode/pyBunch.py +408 -0
  75. geode/pyDate.py +501 -0
  76. geode/pyETM.py +3553 -0
  77. geode/pyEvents.py +78 -0
  78. geode/pyJobServer.py +581 -0
  79. geode/pyLeastSquares.py +90 -0
  80. geode/pyOTL.py +105 -0
  81. geode/pyOkada.py +783 -0
  82. geode/pyOptions.py +124 -0
  83. geode/pyPPP.py +767 -0
  84. geode/pyParseAntex.py +26 -0
  85. geode/pyProducts.py +344 -0
  86. geode/pyRinex.py +1593 -0
  87. geode/pyRinexName.py +235 -0
  88. geode/pyRunWithRetry.py +146 -0
  89. geode/pyStack.py +1097 -0
  90. geode/pyStatic1d.py +36 -0
  91. geode/snxParse.py +672 -0
  92. geode/station_selector.py +335 -0
  93. geode/tests/__init__.py +0 -0
  94. geode/tests/common.py +52 -0
  95. geode/tests/test_make_clusters.py +69 -0
  96. geode/tests/test_station_info.py +435 -0
  97. geode/tests/test_version.py +8 -0
  98. geode_gnss-1.2.48.data/scripts/AlterETM.py +250 -0
  99. geode_gnss-1.2.48.data/scripts/ArchiveService.py +1067 -0
  100. geode_gnss-1.2.48.data/scripts/CloseStationInfo.py +79 -0
  101. geode_gnss-1.2.48.data/scripts/ConvertDate.py +34 -0
  102. geode_gnss-1.2.48.data/scripts/ConvertTrimble.py +70 -0
  103. geode_gnss-1.2.48.data/scripts/CreateEtmFunctions.py +203 -0
  104. geode_gnss-1.2.48.data/scripts/DRA.py +484 -0
  105. geode_gnss-1.2.48.data/scripts/DownloadSources.py +1559 -0
  106. geode_gnss-1.2.48.data/scripts/DownloadSourcesFill.py +337 -0
  107. geode_gnss-1.2.48.data/scripts/EtmStacker.py +891 -0
  108. geode_gnss-1.2.48.data/scripts/FixPlate.py +558 -0
  109. geode_gnss-1.2.48.data/scripts/GenerateKml.py +578 -0
  110. geode_gnss-1.2.48.data/scripts/GenerateSinex.py +131 -0
  111. geode_gnss-1.2.48.data/scripts/IntegrityCheck.py +1132 -0
  112. geode_gnss-1.2.48.data/scripts/LocateRinex.py +334 -0
  113. geode_gnss-1.2.48.data/scripts/ModelProcessing.py +347 -0
  114. geode_gnss-1.2.48.data/scripts/NEQStack.py +240 -0
  115. geode_gnss-1.2.48.data/scripts/OTL_FES2014b.py +178 -0
  116. geode_gnss-1.2.48.data/scripts/ParallelGamit.py +804 -0
  117. geode_gnss-1.2.48.data/scripts/PlotETM.py +691 -0
  118. geode_gnss-1.2.48.data/scripts/PlotMapView.py +375 -0
  119. geode_gnss-1.2.48.data/scripts/QueryETM.py +170 -0
  120. geode_gnss-1.2.48.data/scripts/S-score.py +94 -0
  121. geode_gnss-1.2.48.data/scripts/ScanArchive.py +1430 -0
  122. geode_gnss-1.2.48.data/scripts/Stacker.py +431 -0
  123. geode_gnss-1.2.48.data/scripts/StationInfoEdit.py +524 -0
  124. geode_gnss-1.2.48.data/scripts/SyncOrbits.py +244 -0
  125. geode_gnss-1.2.48.data/scripts/TrajectoryFit.py +466 -0
  126. geode_gnss-1.2.48.data/scripts/UpdateEarthquakes.py +188 -0
  127. geode_gnss-1.2.48.data/scripts/WeeklyCombination.py +423 -0
  128. geode_gnss-1.2.48.data/scripts/Ztd2trp.py +138 -0
  129. geode_gnss-1.2.48.data/scripts/crz2rnx +143 -0
  130. geode_gnss-1.2.48.data/scripts/rename_crinex.sh +26 -0
  131. geode_gnss-1.2.48.data/scripts/rename_crinex2lower.sh +20 -0
  132. geode_gnss-1.2.48.data/scripts/rename_with_logs.sh +24 -0
  133. geode_gnss-1.2.48.data/scripts/rnx2crz +144 -0
  134. geode_gnss-1.2.48.dist-info/METADATA +228 -0
  135. geode_gnss-1.2.48.dist-info/RECORD +138 -0
  136. geode_gnss-1.2.48.dist-info/WHEEL +5 -0
  137. geode_gnss-1.2.48.dist-info/licenses/LICENSE +28 -0
  138. geode_gnss-1.2.48.dist-info/top_level.txt +1 -0
geode/ConvertRaw.py ADDED
@@ -0,0 +1,201 @@
1
+ """
2
+ Project: Geodesy Database Engine (GeoDE)
3
+ Date: 11/28/2023
4
+ Author: Demian D. Gomez
5
+ Module to convert T0x files to RINEX
6
+ """
7
+
8
+ import glob
9
+ import os
10
+ import re
11
+ import shutil
12
+ import tempfile
13
+
14
+ from tqdm import tqdm
15
+
16
+ # app
17
+ from . import Utils
18
+ from . import pyRinex
19
+ from . import pyRunWithRetry
20
+ from .pyEvents import Event
21
+
22
+
23
+ class ConvertRawException(Exception):
24
+ def __init__(self, value):
25
+ self.value = value
26
+ self.event = Event(Description=value, EventType='error')
27
+
28
+ def __str__(self):
29
+ return str(self.value)
30
+
31
+
32
+ class ConvertRaw(object):
33
+ def __init__(self, station_code='stnm', path_to_raw=None, out_path=None,
34
+ atx_file=None, antenna=None, ant_serial=None):
35
+ # logger information and setup
36
+ self.logger = []
37
+ self.station_code = station_code
38
+ self.path_to_raw = path_to_raw
39
+ self.out_path = out_path
40
+
41
+ self.logger.append(Event(Description='Initialized ConvertRaw for station code %s with path %s '
42
+ 'and output path %s' % (station_code, path_to_raw, out_path)))
43
+
44
+ if not os.path.isdir(out_path):
45
+ os.makedirs(out_path)
46
+
47
+ # if a single file is passed, then just work with that file. If a path, then do a search
48
+ if os.path.isdir(path_to_raw):
49
+ # a directory was passed
50
+ self.file_list = list(glob.iglob('**/*.*', root_dir=path_to_raw, recursive=True))
51
+ else:
52
+ # single file
53
+ self.file_list = [path_to_raw]
54
+
55
+ self.logger.append(Event(Description='List of files to process: ' + ', '.join(self.file_list)))
56
+
57
+ # if antenna is not none, then parse ATX and find provided antenna to replace in RINEX
58
+ if atx_file is not None and antenna is not None:
59
+ atx = Utils.parse_atx_antennas(atx_file)
60
+ # figure out if we have wildcards in the antenna name
61
+ ant = re.findall(antenna, '\n'.join(atx))
62
+ if not ant or len(ant) > 1:
63
+ raise ConvertRawException(
64
+ 'Too many matches found. Use a more specific antenna name regex:\n' + '\n'.join(ant))
65
+ else:
66
+ self.antenna = ant[0]
67
+ self.antenna_serial = ant_serial
68
+
69
+ self.logger.append(Event(Description='Replacing ANT # / TYPE record with provided information:' +
70
+ (' ' + ant_serial if ant_serial is not None else '') +
71
+ ' %-16s%4s' % (ant, 'NONE')))
72
+ else:
73
+ self.antenna = None
74
+ self.antenna_serial = None
75
+
76
+ def print_events(self):
77
+ for event in self.logger:
78
+ tqdm.write(' -- ' + str(event))
79
+
80
+ def process_files(self):
81
+ result = False
82
+
83
+ for file in self.file_list:
84
+ # TRIMBLE CONVERSION
85
+ if file[-3:].upper() in ('T00', 'T01', 'T02'):
86
+ self.logger.append(Event(Description='Invoking Trimble Conversion'))
87
+ result = self.convert_trimble(file)
88
+ # OTHER CONVERSIONS COMING SOON
89
+ else:
90
+ self.logger.append(Event(Description='Raw format not supported: %s' % file[-3:].upper()))
91
+
92
+ return result
93
+
94
+ def merge_rinex(self):
95
+
96
+ # go through the output folder and find all RINEX files to see if more than one file per day
97
+ file_list = []
98
+ for ft in ('*d.Z', '*.gz', '*d.z'):
99
+ file_list += list(glob.iglob(ft, root_dir=self.out_path, recursive=False))
100
+
101
+ date_dict = {}
102
+
103
+ for file in file_list:
104
+ abs_filename = os.path.join(self.out_path, file)
105
+
106
+ rnx = pyRinex.ReadRinex('???', self.station_code, abs_filename, min_time_seconds=300)
107
+
108
+ if rnx.date.yyyyddd() + f'_{rnx.interval:>02.0f}' in date_dict.keys():
109
+ date_dict[rnx.date.yyyyddd() + f'_{rnx.interval:>02.0f}'].append(abs_filename)
110
+ else:
111
+ date_dict[rnx.date.yyyyddd() + f'_{rnx.interval:>02.0f}'] = [abs_filename]
112
+
113
+ # now figure out if any dates have more than one file
114
+ for d, files in date_dict.items():
115
+ if len(files) > 1:
116
+
117
+ rnx = []
118
+ self.logger.append(Event(Description='Processing date / interval %s' % d))
119
+ for frnx in files:
120
+ self.logger.append(Event(Description='Uncompressing %s' % frnx))
121
+ # do the same for the rest
122
+ rnx.append(pyRinex.ReadRinex('???', self.station_code, frnx, min_time_seconds=300))
123
+ os.remove(frnx)
124
+
125
+ # use a file name that we know has been deleted already
126
+ spliced_rnx = os.path.join(self.out_path, rnx[0].rinex)
127
+
128
+ fs = ' '.join([rx.rinex_path for rx in rnx])
129
+
130
+ cmd = pyRunWithRetry.RunCommand('gfzrnx_lx -finp %s -fout %s -vo %i'
131
+ % (fs, spliced_rnx, 2), 300)
132
+ _, _ = cmd.run_shell()
133
+
134
+ rx = pyRinex.ReadRinex('???', self.station_code, spliced_rnx, min_time_seconds=300)
135
+
136
+ # compress
137
+ rx.compress_local_copyto(self.out_path)
138
+ os.remove(spliced_rnx)
139
+
140
+ def convert_trimble(self, filename):
141
+ # create a dictionary to save how many files there are for each date
142
+
143
+ result = True
144
+
145
+ tmp_dir = tempfile.mkdtemp(suffix='.tmp', prefix=os.path.join(self.out_path, 'process.'))
146
+
147
+ t0_file = os.path.join(self.path_to_raw, filename).replace(' ', '\\ ')
148
+
149
+ self.logger.append(Event(Description='Processing file %s' % t0_file))
150
+
151
+ # use runpkr00 to convert to tgd
152
+ os.system('runpkr00 -g -d %s %s' % (t0_file, tmp_dir))
153
+ # stdout, stderr = cmd.run_shell()
154
+ self.logger.append(Event(Description='Executed runpkr00 -g -d %s %s'
155
+ % (t0_file, tmp_dir)))
156
+
157
+ file = os.path.basename(filename)
158
+
159
+ # now TEQC
160
+ rinex = os.path.join(tmp_dir, file[0:4]) + '0010.00o'
161
+
162
+ # DDG: sometimes the output is DAT not TGD ???
163
+ if os.path.exists(os.path.join(tmp_dir, file.split('.')[0]) + '.tgd'):
164
+ tgd = os.path.join(tmp_dir, file.split('.')[0]) + '.tgd'
165
+ else:
166
+ tgd = os.path.join(tmp_dir, file.split('.')[0]) + '.dat'
167
+
168
+ err = os.path.join(tmp_dir, 'err.txt')
169
+
170
+ os.system('teqc +C2 +L5 +L8 -tr d %s > %s 2> %s' % (tgd, rinex, err))
171
+
172
+ self.logger.append(Event(Description='Executed teqc -tr d %s > %s 2> %s' % (tgd, rinex, err)))
173
+
174
+ try:
175
+ rnx = pyRinex.ReadRinex('???', self.station_code, rinex, min_time_seconds=300)
176
+
177
+ rnx.rename(self.station_code + rnx.date.ddd() + '0.' + rnx.date.yyyy()[2:] + 'o')
178
+
179
+ if self.antenna:
180
+ header = rnx.replace_record(rnx.header, 'ANT # / TYPE',
181
+ [self.antenna_serial if self.antenna_serial is not None else rnx.antNo,
182
+ '%-16s%4s' % (self.antenna, 'NONE')])
183
+ header = rnx.insert_comment(header, 'ConvertRaw REPLACED ANT %s' % rnx.antType)
184
+ rnx.write_rinex(header)
185
+
186
+ # make sure the header reflects the curated information
187
+ rnx.normalize_header()
188
+ # write the file
189
+ rnx.compress_local_copyto(self.out_path)
190
+
191
+ except pyRinex.pyRinexException as e:
192
+ self.logger.append(Event(Description=str(e), EventType='error'))
193
+ result = False
194
+
195
+ # cleanup
196
+ try:
197
+ shutil.rmtree(tmp_dir)
198
+ except Exception as e:
199
+ self.logger.append(Event(Description=str(e), EventType='error'))
200
+
201
+ return result