Skip to content

Commit cc901a6

Browse files
committed
adds ephemeris downloader tutorial
1 parent 96b428a commit cc901a6

4 files changed

Lines changed: 143 additions & 5 deletions

File tree

docs/source/tutorials/tutorials.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ available in the :code:`utils` directory.
5757
tutorials_visualizations_notebook
5858
tutorials_coordinates_notebook
5959
tutorials_utilities_notebook
60+
tutorials_ephemeris_downloader_notebook
6061
tutorials_sv_models_notebook
6162
tutorials_gnss_models_notebook
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "../../../notebooks/tutorials/ephemeris_downloader.ipynb"
3+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "a1126926",
6+
"metadata": {},
7+
"source": [
8+
"# Ephemeris Downloader"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "929486f6",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import numpy as np\n",
19+
"import gnss_lib_py as glp\n",
20+
"from datetime import datetime, timezone"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "8ea72a0c",
26+
"metadata": {},
27+
"source": [
28+
"The `load_ephemeris` function from the `utils/ephemeris_downloader.py` file can be used to automatically download ephemeris files and check whether the correct ephemeris files have already been downloaded.\n",
29+
"\n",
30+
"As an example, say we want to find satellite positions for a specific location and time. We will use `load_ephemeris` to download the correct ephemeris files."
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"id": "2bbfabff",
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"lat, lon, alt = 37.42984154652992, -122.16946303566934, 0.\n",
41+
"timestamp_start = datetime(year=2023, month=3, day=14, hour=12, tzinfo=timezone.utc)\n",
42+
"timestamp_end = datetime(year=2023, month=3, day=14, hour=13, tzinfo=timezone.utc)"
43+
]
44+
},
45+
{
46+
"cell_type": "markdown",
47+
"id": "32390f44",
48+
"metadata": {},
49+
"source": [
50+
"To download ephemeris simply pass in the file type you want to download (either `sp3`, `clk`, or `rinex_nav` and the time at which you want the ephemeris in units of GPS milliseconds. The output of the `load_ephemeris` function is the path to the ephemeris files."
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": null,
56+
"id": "13e826e6",
57+
"metadata": {},
58+
"outputs": [],
59+
"source": [
60+
"gps_millis = glp.datetime_to_gps_millis(np.array([timestamp_start,timestamp_end]))\n",
61+
"sp3_path = glp.load_ephemeris(file_type=\"sp3\", \n",
62+
" gps_millis=gps_millis,\n",
63+
" verbose=True)"
64+
]
65+
},
66+
{
67+
"cell_type": "markdown",
68+
"id": "fb631ff0",
69+
"metadata": {},
70+
"source": [
71+
"To visualize the data, we can then plot the satellite positions using a skyplot from our receiver's location we input above. For the skyplot we need to parse the sp3 file we downloaded using the `Sp3` class and then create a `NavData` instance to pass in our receiver's position."
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": null,
77+
"id": "a09816e3",
78+
"metadata": {},
79+
"outputs": [],
80+
"source": [
81+
"# load the sp3 file\n",
82+
"sp3 = glp.Sp3(sp3_path)\n",
83+
"\n",
84+
"# create receiver state NavData instance to pass into skyplot function\n",
85+
"x_rx_m, y_rx_m, z_rx_m = glp.geodetic_to_ecef(np.array([[lat,lon,alt]]))[0]\n",
86+
"receiver_state = glp.NavData()\n",
87+
"receiver_state[\"gps_millis\"] = glp.datetime_to_gps_millis(timestamp_start)\n",
88+
"receiver_state[\"x_rx_m\"] = x_rx_m\n",
89+
"receiver_state[\"y_rx_m\"] = y_rx_m\n",
90+
"receiver_state[\"z_rx_m\"] = z_rx_m"
91+
]
92+
},
93+
{
94+
"cell_type": "markdown",
95+
"id": "bcfe81aa",
96+
"metadata": {},
97+
"source": [
98+
"Now we can plot the skyplot from the downloaded data. For readability, we crop the sp3 data to only include satellite positions between the start and end timestamp from above."
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": null,
104+
"id": "cd23bf03",
105+
"metadata": {},
106+
"outputs": [],
107+
"source": [
108+
"cropped_sp3 = sp3.where(\"gps_millis\",gps_millis[0],\"geq\").where(\"gps_millis\",gps_millis[1],\"leq\")\n",
109+
"fig = glp.plot_skyplot(cropped_sp3,receiver_state)"
110+
]
111+
}
112+
],
113+
"metadata": {
114+
"kernelspec": {
115+
"display_name": "Python 3 (ipykernel)",
116+
"language": "python",
117+
"name": "python3"
118+
},
119+
"language_info": {
120+
"codemirror_mode": {
121+
"name": "ipython",
122+
"version": 3
123+
},
124+
"file_extension": ".py",
125+
"mimetype": "text/x-python",
126+
"name": "python",
127+
"nbconvert_exporter": "python",
128+
"pygments_lexer": "ipython3",
129+
"version": "3.8.9"
130+
}
131+
},
132+
"nbformat": 4,
133+
"nbformat_minor": 5
134+
}

notebooks/tutorials/sv_models.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"cell_type": "markdown",
129129
"metadata": {},
130130
"source": [
131-
"## Adding SV states to `NavData` with received measurements using broadcast ephemeris"
131+
"# Adding SV states to `NavData` with received measurements using broadcast ephemeris"
132132
]
133133
},
134134
{
@@ -220,7 +220,7 @@
220220
"cell_type": "markdown",
221221
"metadata": {},
222222
"source": [
223-
"## Add SV states for visible satellites given a series of times and positions"
223+
"# Add SV states for visible satellites given a series of times and positions"
224224
]
225225
},
226226
{
@@ -335,7 +335,7 @@
335335
"cell_type": "markdown",
336336
"metadata": {},
337337
"source": [
338-
"## Finding PRNs and states for visible SVs for a given position and time"
338+
"# Finding PRNs and states for visible SVs for a given position and time"
339339
]
340340
},
341341
{
@@ -373,7 +373,7 @@
373373
"cell_type": "markdown",
374374
"metadata": {},
375375
"source": [
376-
"## Finding SV states at given time and for specific PRNs"
376+
"# Finding SV states at given time and for specific PRNs"
377377
]
378378
},
379379
{
@@ -423,7 +423,7 @@
423423
"cell_type": "markdown",
424424
"metadata": {},
425425
"source": [
426-
"## Simulating SV positions given elevation and azimuth"
426+
"# Simulating SV positions given elevation and azimuth"
427427
]
428428
},
429429
{

0 commit comments

Comments
 (0)