Created
November 19, 2020 18:44
-
-
Save jmbarr/f1ce08fc4c3e2b5a09fde68c0633cb17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Initialise a Stone Soup state from a TLE from SpaceTrack" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"jmb 2020-11-05" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# imports\n", | |
"import numpy as np\n", | |
"from datetime import date, datetime\n", | |
"\n", | |
"# python spacetrack (See SpaceTrack PyPI page)\n", | |
"# import satellite info from the web\n", | |
"from spacetrack import SpaceTrackClient \n", | |
"import spacetrack.operators as op \n", | |
"\n", | |
"# Stone Soup routines\n", | |
"from stonesoup.types.array import StateVector, Matrix\n", | |
"from stonesoup.types.orbitalstate import OrbitalState, TLEOrbitalState" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Creates a SpaceTrack client - which is a way to query https://www.space-track.org for a TLE or TLEs. \n", | |
"# You can set up a user name and password at that site. This line won't work until you do.\n", | |
"st = SpaceTrackClient(identity='username', password='password')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# The following returns all TLEs in the date range specified with the ID 25544 (i.e. the ISS)\n", | |
"r_epoch = op.inclusive_range(date(2018, 7, 1), date(2018, 7, 3))\n", | |
"tles_json=st.tle(norad_cat_id=25544,epoch=r_epoch)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0 ISS (ZARYA)\n", | |
"1 25544U 98067A 18182.57105324 +.00001714 +00000-0 +33281-4 0 9991\n", | |
"2 25544 051.6426 307.0095 0003698 252.8831 281.8833 15.53996196120757\n" | |
] | |
} | |
], | |
"source": [ | |
"# Check the first of these\n", | |
"print(tles_json[0]['TLE_LINE0'])\n", | |
"print(tles_json[0]['TLE_LINE1'])\n", | |
"print(tles_json[0]['TLE_LINE2'])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"tle_metadata = {'line_1': tles_json[0]['TLE_LINE1'], 'line_2': tles_json[0]['TLE_LINE2']}\n", | |
"tle_state = TLEOrbitalState(None, metadata=tle_metadata)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"TLEOrbitalState(state_vector=StateVector([[-3.75652102e+06],\n", | |
" [ 5.62622198e+06],\n", | |
" [ 4.88985712e+05],\n", | |
" [-4.20560647e+03],\n", | |
" [-2.29106828e+03],\n", | |
" [-5.98628657e+03]]), timestamp=datetime.datetime(2018, 7, 1, 13, 42, 18, 999936), coordinates='TLE', grav_parameter=398600441800000.0, covar=None, metadata={'line_1': '1 25544U 98067A 18182.57105324 +.00001714 +00000-0 +33281-4 0 9991', 'line_2': '2 25544 051.6426 307.0095 0003698 252.8831 281.8833 15.53996196120757'})" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"tle_state" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment