Skip to content

Commit 6298c8f

Browse files
committed
working RINEX .obs parser
1 parent b987d35 commit 6298c8f

File tree

10 files changed

+1166
-319
lines changed

10 files changed

+1166
-319
lines changed

Code/RTKLIB-Tools/Crunch Data.ipynb

Lines changed: 315 additions & 88 deletions
Large diffs are not rendered by default.

Code/RTKLIB-Tools/Load Data.ipynb

Lines changed: 111 additions & 114 deletions
Large diffs are not rendered by default.

Code/RTKLIB-Tools/Port Data.ipynb

Lines changed: 156 additions & 42 deletions
Large diffs are not rendered by default.

Code/RTKLIB-Tools/Untitled1.ipynb

Lines changed: 379 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,379 @@
1+
{
2+
"metadata": {
3+
"name": "Untitled1"
4+
},
5+
"nbformat": 3,
6+
"nbformat_minor": 0,
7+
"worksheets": [
8+
{
9+
"cells": [
10+
{
11+
"cell_type": "code",
12+
"collapsed": false,
13+
"input": [
14+
"from matplotlib import pyplot, mpl\n",
15+
"from pandas.lib import Timestamp\n",
16+
"import pandas as pd\n",
17+
"import scipy as sp\n",
18+
"import numpy as np\n",
19+
"import pylab as pl\n",
20+
"import geopy as gp\n",
21+
"import sklearn as sk\n",
22+
"import ephem\n",
23+
"from plot_utils import *\n",
24+
"from file_utils import *\n",
25+
"from rtklib_utils import *\n",
26+
"from ephem_utils import *\n",
27+
"\n",
28+
"from sklearn import svm\n",
29+
"from sklearn.metrics import roc_curve, auc"
30+
],
31+
"language": "python",
32+
"metadata": {},
33+
"outputs": [
34+
{
35+
"output_type": "stream",
36+
"stream": "stderr",
37+
"text": [
38+
"/usr/lib/python3.3/importlib/_bootstrap.py:313: UserWarning: Module pytz was already imported from /usr/local/lib/python3.3/dist-packages/pytz/__init__.py, but /usr/lib/python3/dist-packages is being added to sys.path\n",
39+
" return f(*args, **kwds)\n",
40+
"/usr/lib/python3.3/importlib/_bootstrap.py:313: UserWarning: Module dateutil was already imported from /usr/local/lib/python3.3/dist-packages/dateutil/__init__.py, but /usr/lib/python3/dist-packages is being added to sys.path\n",
41+
" return f(*args, **kwds)\n"
42+
]
43+
}
44+
],
45+
"prompt_number": 1
46+
},
47+
{
48+
"cell_type": "code",
49+
"collapsed": false,
50+
"input": [],
51+
"language": "python",
52+
"metadata": {},
53+
"outputs": [],
54+
"prompt_number": 48
55+
},
56+
{
57+
"cell_type": "code",
58+
"collapsed": false,
59+
"input": [
60+
"indir = '/home/ruffin/Documents/Data/in/'\n",
61+
"filename = 'CMU_center'\n",
62+
"df, header = readObs(indir + filename + '/', filename + '.obs')\n",
63+
"writeObs(indir + filename + '/', filename + '2.obs', df, header)"
64+
],
65+
"language": "python",
66+
"metadata": {},
67+
"outputs": [
68+
{
69+
"html": [
70+
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
71+
"<table border=\"1\" class=\"dataframe\">\n",
72+
" <thead>\n",
73+
" <tr style=\"text-align: right;\">\n",
74+
" <th></th>\n",
75+
" <th></th>\n",
76+
" <th>satData</th>\n",
77+
" </tr>\n",
78+
" <tr>\n",
79+
" <th>%_GPST</th>\n",
80+
" <th>satID</th>\n",
81+
" <th></th>\n",
82+
" </tr>\n",
83+
" </thead>\n",
84+
" <tbody>\n",
85+
" <tr>\n",
86+
" <th rowspan=\"5\" valign=\"top\">2013-07-28 00:04:41.800000</th>\n",
87+
" <th>G02</th>\n",
88+
" <td> G 2 20798587.222 64245.344 -292....</td>\n",
89+
" </tr>\n",
90+
" <tr>\n",
91+
" <th>S38</th>\n",
92+
" <td> S38 38119695.104 334980.3572 -1274....</td>\n",
93+
" </tr>\n",
94+
" <tr>\n",
95+
" <th>G04</th>\n",
96+
" <td> G 4 20340108.358 679975.293 -2616....</td>\n",
97+
" </tr>\n",
98+
" <tr>\n",
99+
" <th>G25</th>\n",
100+
" <td> G25 23622313.488 -364769.798 1299....</td>\n",
101+
" </tr>\n",
102+
" <tr>\n",
103+
" <th>G05</th>\n",
104+
" <td> G 5 22881315.972 -596016.782 2204....</td>\n",
105+
" </tr>\n",
106+
" </tbody>\n",
107+
"</table>\n",
108+
"</div>"
109+
],
110+
"output_type": "pyout",
111+
"prompt_number": 4,
112+
"text": [
113+
" satData\n",
114+
"%_GPST satID \n",
115+
"2013-07-28 00:04:41.800000 G02 G 2 20798587.222 64245.344 -292....\n",
116+
" S38 S38 38119695.104 334980.3572 -1274....\n",
117+
" G04 G 4 20340108.358 679975.293 -2616....\n",
118+
" G25 G25 23622313.488 -364769.798 1299....\n",
119+
" G05 G 5 22881315.972 -596016.782 2204...."
120+
]
121+
}
122+
],
123+
"prompt_number": 4
124+
},
125+
{
126+
"cell_type": "code",
127+
"collapsed": false,
128+
"input": [
129+
"uniq_satID = getSatsList(df)\n",
130+
"print(uniq_satID)"
131+
],
132+
"language": "python",
133+
"metadata": {},
134+
"outputs": [
135+
{
136+
"output_type": "stream",
137+
"stream": "stdout",
138+
"text": [
139+
"['04', '25', '05', '23', '17', '13', '10', '12', '02']\n"
140+
]
141+
}
142+
],
143+
"prompt_number": 4
144+
},
145+
{
146+
"cell_type": "code",
147+
"collapsed": false,
148+
"input": [],
149+
"language": "python",
150+
"metadata": {},
151+
"outputs": [],
152+
"prompt_number": 4
153+
},
154+
{
155+
"cell_type": "code",
156+
"collapsed": false,
157+
"input": [
158+
"noradUrl = 'http://www.celestrak.com/NORAD/elements/gps-ops.txt'\n",
159+
"noradFile = 'gps-ops.txt'"
160+
],
161+
"language": "python",
162+
"metadata": {},
163+
"outputs": [],
164+
"prompt_number": 5
165+
},
166+
{
167+
"cell_type": "code",
168+
"collapsed": false,
169+
"input": [
170+
"dir = indir\n",
171+
"dfObs = df\n",
172+
"headerObs = header\n",
173+
"\n",
174+
"\n",
175+
"headerObsLines = headerObs.split('\\n')\n",
176+
"for line in headerObsLines:\n",
177+
" if 'APPROX POSITION XYZ' in line:\n",
178+
" list = line.split()\n",
179+
" x = float(list[0])\n",
180+
" y = float(list[1])\n",
181+
" z = float(list[2])\n",
182+
" lat, lon, elv = xyz2plh(x,y,z)\n",
183+
" break\n",
184+
"lat, lon, elv = xyz2plh(x,y,z)\n",
185+
"reference = gp.point.Point(lat,lon,elv)\n",
186+
"date = df.index[0][0]\n",
187+
"satlist = loadTLE(dir + noradFile)\n",
188+
"satObs = getSatsList(dfObs)\n",
189+
"satConsts = getSatConsts(satlist, satObs, date, reference)"
190+
],
191+
"language": "python",
192+
"metadata": {},
193+
"outputs": [
194+
{
195+
"output_type": "stream",
196+
"stream": "stdout",
197+
"text": [
198+
"04\n",
199+
"10\n",
200+
"13\n",
201+
"23\n",
202+
"02\n",
203+
"17\n",
204+
"12\n",
205+
"05\n",
206+
"25\n"
207+
]
208+
}
209+
],
210+
"prompt_number": 6
211+
},
212+
{
213+
"cell_type": "code",
214+
"collapsed": false,
215+
"input": [
216+
"print(satConsts)"
217+
],
218+
"language": "python",
219+
"metadata": {},
220+
"outputs": [
221+
{
222+
"output_type": "stream",
223+
"stream": "stdout",
224+
"text": [
225+
"[['G04', 64.492722520768083, 39.861305015085406], ['G10', 68.004730659907764, 132.30105109109212], ['G13', 14.311659075501021, 83.831289834824474], ['G23', 12.377180455371452, 56.434697564418812], ['G02', 65.141139699434063, 290.09231352315845], ['G17', 32.983024483126592, 112.96004539950204], ['G12', 50.408466055946171, 280.67913805434364], ['G05', 29.301436407273833, 199.40500957306944], ['G25', 20.05583109200882, 317.15125539194457]]\n"
226+
]
227+
}
228+
],
229+
"prompt_number": 7
230+
},
231+
{
232+
"cell_type": "code",
233+
"collapsed": false,
234+
"input": [
235+
"import ephem"
236+
],
237+
"language": "python",
238+
"metadata": {},
239+
"outputs": [],
240+
"prompt_number": 9
241+
},
242+
{
243+
"cell_type": "code",
244+
"collapsed": false,
245+
"input": [
246+
"def generateData(dir, noradFile):\n",
247+
" folders = findFolders(dir)\n",
248+
" for folder in folders:\n",
249+
" print('reading: ' + dir + folder + '/' + folder + '.obs')\n",
250+
" df, header = readObs(dir + folder + '/', folder + '.obs')\n",
251+
" headerLines = header.split('\\n')\n",
252+
" for line in headerLines:\n",
253+
" if 'APPROX POSITION XYZ' in line:\n",
254+
" list = line.split()\n",
255+
" x = float(list[0])\n",
256+
" y = float(list[1])\n",
257+
" z = float(list[2])\n",
258+
" lat, lon, elv = xyz2plh(x,y,z)\n",
259+
" break\n",
260+
" lat, lon, elv = xyz2plh(x,y,z)\n",
261+
" reference = gp.point.Point(lat,lon,elv)\n",
262+
" date = df.index[0][0]\n",
263+
" satlist = loadTLE(dir + noradFile)\n",
264+
" satObs = getSatsList(df)\n",
265+
" satConsts = getSatConsts(satlist, satObs, date, reference)\n",
266+
" dfs = generateMasks(df, satConsts)\n",
267+
" \n",
268+
" for x, dfx in enumerate(dfs):\n",
269+
" folderx = folder + '.v' + str(x)\n",
270+
" dirx = dir + folderx + '/'\n",
271+
" filepathx = dirx + folderx\t\n",
272+
" filepath = dir + folder + '/' + folder\n",
273+
" checkDir(dirx,'w')\n",
274+
" print(dirx + folderx)\n",
275+
" writeObs(dirx, folderx + '.obs', df, header)\n",
276+
" shutil.copyfile(filepath + '.nav', filepathx + '.nav')\n",
277+
" shutil.copyfile(filepath + '.sbs', filepathx + '.sbs')\n"
278+
],
279+
"language": "python",
280+
"metadata": {},
281+
"outputs": [],
282+
"prompt_number": 25
283+
},
284+
{
285+
"cell_type": "code",
286+
"collapsed": false,
287+
"input": [
288+
"dir = indir\n",
289+
"generateData(dir, noradFile)"
290+
],
291+
"language": "python",
292+
"metadata": {},
293+
"outputs": [
294+
{
295+
"output_type": "stream",
296+
"stream": "stdout",
297+
"text": [
298+
"reading: /home/ruffin/Documents/Data/in/CMU_center/CMU_center.obs\n",
299+
"04\n",
300+
"10\n",
301+
"13\n",
302+
"23\n",
303+
"02\n",
304+
"17\n",
305+
"12\n",
306+
"05\n",
307+
"25\n",
308+
"Checking directory: /home/ruffin/Documents/Data/in/CMU_center.v0/\n",
309+
"/home/ruffin/Documents/Data/in/CMU_center.v0/CMU_center.v0\n",
310+
"Checking directory: /home/ruffin/Documents/Data/in/CMU_center.v1/\n",
311+
"/home/ruffin/Documents/Data/in/CMU_center.v1/CMU_center.v1\n",
312+
"Checking directory: /home/ruffin/Documents/Data/in/CMU_center.v2/"
313+
]
314+
},
315+
{
316+
"output_type": "stream",
317+
"stream": "stdout",
318+
"text": [
319+
"\n",
320+
"/home/ruffin/Documents/Data/in/CMU_center.v2/CMU_center.v2\n"
321+
]
322+
}
323+
],
324+
"prompt_number": 26
325+
},
326+
{
327+
"cell_type": "code",
328+
"collapsed": false,
329+
"input": [
330+
"dict = {}"
331+
],
332+
"language": "python",
333+
"metadata": {},
334+
"outputs": [],
335+
"prompt_number": 3
336+
},
337+
{
338+
"cell_type": "code",
339+
"collapsed": false,
340+
"input": [
341+
"dict['cat'] = 2"
342+
],
343+
"language": "python",
344+
"metadata": {},
345+
"outputs": [],
346+
"prompt_number": 4
347+
},
348+
{
349+
"cell_type": "code",
350+
"collapsed": false,
351+
"input": [
352+
"dict['cat']"
353+
],
354+
"language": "python",
355+
"metadata": {},
356+
"outputs": [
357+
{
358+
"output_type": "pyout",
359+
"prompt_number": 5,
360+
"text": [
361+
"2"
362+
]
363+
}
364+
],
365+
"prompt_number": 5
366+
},
367+
{
368+
"cell_type": "code",
369+
"collapsed": false,
370+
"input": [],
371+
"language": "python",
372+
"metadata": {},
373+
"outputs": []
374+
}
375+
],
376+
"metadata": {}
377+
}
378+
]
379+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)