|
| 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 | +} |
0 commit comments