{ "cells": [ { "cell_type": "markdown", "id": "0c8618fe", "metadata": {}, "source": [ "# Example Notebook\n", "This Jupyter Notebook is meant to illustrate how the SatChecker Ephemeris API (https://satchecker.cps.iau.org/ephemeris) can be used with python. The example below is for the name-jdstep endpoint.\n", "\n" ] }, { "cell_type": "code", "execution_count": 32, "id": "fe4d42e9", "metadata": {}, "outputs": [], "source": [ "import requests" ] }, { "cell_type": "markdown", "id": "5bff29eb", "metadata": {}, "source": [ "In order to get position predictions over a range of time, you will need to provide the start and end times (JD) and the desired time step. The time step is optional, and it defaults to 2 minutes (0.00138889 JD) if not provided. Since the API can only be called for one satellite at a time with the current endpoints, you can call it over a list if you need to check multiple satellites." ] }, { "cell_type": "code", "execution_count": 48, "id": "5704068e", "metadata": {}, "outputs": [], "source": [ "start_jd = 2460208.5\n", "stop_jd = 2460209.75\n", "\n", "# .2 is 4.8 hours\n", "step_jd = 0.2\n", "\n", "observer_latitude = 32\n", "observer_longitude = -110\n", "observer_elevation = 0\n", "\n", "\n", "satellite_list = [\n", " \"STARLINK-30109\",\n", " \"STARLINK-30407\",\n", " \"STARLINK-30408\",\n", " \"STARLINK-30377\",\n", " \"STARLINK-30422\",\n", " \"STARLINK-30402\",\n", " \"STARLINK-30411\",\n", " \"STARLINK-30418\",\n", "]" ] }, { "cell_type": "markdown", "id": "3c34e022", "metadata": {}, "source": [ "In order to see all passes, visible and not, you can specify a min_altitude of -90. The default min_altitude if you don't specify anything is 0, which will only return visible passes. " ] }, { "cell_type": "code", "execution_count": 51, "id": "57473ad3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30109&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30407&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30408&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30377&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30422&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30402&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30411&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n", "https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name=STARLINK-30418&elevation=0&latitude=32&longitude=-110&startjd=2460208.5&stopjd=2460209.75&stepjd=0.2&min_altitude=-90\n" ] } ], "source": [ "visible_satellites = []\n", "not_visible_satellites = []\n", "\n", "for satellite in satellite_list:\n", " response = requests.get(\n", " f\"https://satchecker.cps.iau.org/ephemeris/name-jdstep/?name={satellite}&elevation={observer_elevation}&latitude={observer_latitude}&longitude={observer_longitude}&startjd={start_jd}&stopjd={stop_jd}&stepjd={step_jd}&min_altitude=-90\",\n", " timeout=10,\n", " )\n", " info = response.json()\n", " print(response.url)\n", " #print(info)\n", " fields = info[\"fields\"]\n", " altitude_index = fields.index(\"altitude_deg\")\n", "\n", " # Iterate through each satellite's data\n", " for satellite_data in info[\"data\"]:\n", " # Extract the satellite's name and altitude using the fields' indexes\n", " satellite_name = satellite_data[fields.index(\"name\")]\n", " altitude_deg = satellite_data[altitude_index]\n", "\n", " # Check if the satellite is visible\n", " if altitude_deg > 0:\n", " visible_satellites.append(satellite_data)\n", " else:\n", " not_visible_satellites.append(satellite_data)" ] }, { "cell_type": "markdown", "id": "685fe200", "metadata": {}, "source": [ "Results are returned in JSON, which you can use to get specific info about each pass. This shows all visible passes for all satellites in the list specified:" ] }, { "cell_type": "code", "execution_count": 4, "id": "99c4e764", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", "Visible Satellites: \n", "STARLINK-30109\n", "Altitude (degrees): 0.1377401\n", "Azimuth (degrees): 244.31156368\n", "Time: 2460209.1\n", "--------------------------------------\n", "\n", "\n", "\n" ] } ], "source": [ "fields = info[\"fields\"]\n", "data = info[\"data\"]\n", "\n", "print(\"\\n\")\n", "print(\"Visible Satellites: \")\n", "for satellite in visible_satellites:\n", " satellite_info = dict(zip(fields, satellite, strict=True))\n", " \n", " print(satellite_info.get(\"name\"))\n", " print(\"Altitude (degrees): \", satellite_info.get(\"altitude_deg\"))\n", " print(\"Azimuth (degrees): \", satellite_info.get(\"azimuth_deg\"))\n", " print(\"Time: \", satellite_info.get(\"julian_date\"))\n", " print(\"--------------------------------------\")\n", "\n", "print(\"\\n\\n\")\n" ] }, { "cell_type": "markdown", "id": "914a67eb", "metadata": {}, "source": [ "This shows each pass that isn't visible for all satellites in the list specified, skipping the position since it's not relevant:" ] }, { "cell_type": "code", "execution_count": 5, "id": "ad3ea2b4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Not Currently Visible: \n", "STARLINK-30109\n", "2460208.5\n", "-------------------------\n", "STARLINK-30109\n", "2460208.7\n", "-------------------------\n", "STARLINK-30109\n", "2460208.9\n", "-------------------------\n", "STARLINK-30109\n", "2460209.3\n", "-------------------------\n", "STARLINK-30109\n", "2460209.5\n", "-------------------------\n", "STARLINK-30109\n", "2460209.7\n", "-------------------------\n", "STARLINK-30407\n", "2460208.5\n", "-------------------------\n", "STARLINK-30407\n", "2460208.7\n", "-------------------------\n", "STARLINK-30407\n", "2460208.9\n", "-------------------------\n", "STARLINK-30407\n", "2460209.1\n", "-------------------------\n", "STARLINK-30407\n", "2460209.3\n", "-------------------------\n", "STARLINK-30407\n", "2460209.5\n", "-------------------------\n", "STARLINK-30407\n", "2460209.7\n", "-------------------------\n", "STARLINK-30408\n", "2460208.5\n", "-------------------------\n", "STARLINK-30408\n", "2460208.7\n", "-------------------------\n", "STARLINK-30408\n", "2460208.9\n", "-------------------------\n", "STARLINK-30408\n", "2460209.1\n", "-------------------------\n", "STARLINK-30408\n", "2460209.3\n", "-------------------------\n", "STARLINK-30408\n", "2460209.5\n", "-------------------------\n", "STARLINK-30408\n", "2460209.7\n", "-------------------------\n", "STARLINK-30377\n", "2460208.5\n", "-------------------------\n", "STARLINK-30377\n", "2460208.7\n", "-------------------------\n", "STARLINK-30377\n", "2460208.9\n", "-------------------------\n", "STARLINK-30377\n", "2460209.1\n", "-------------------------\n", "STARLINK-30377\n", "2460209.3\n", "-------------------------\n", "STARLINK-30377\n", "2460209.5\n", "-------------------------\n", "STARLINK-30377\n", "2460209.7\n", "-------------------------\n", "STARLINK-30422\n", "2460208.5\n", "-------------------------\n", "STARLINK-30422\n", "2460208.7\n", "-------------------------\n", "STARLINK-30422\n", "2460208.9\n", "-------------------------\n", "STARLINK-30422\n", "2460209.1\n", "-------------------------\n", "STARLINK-30422\n", "2460209.3\n", "-------------------------\n", "STARLINK-30422\n", "2460209.5\n", "-------------------------\n", "STARLINK-30422\n", "2460209.7\n", "-------------------------\n", "STARLINK-30402\n", "2460208.5\n", "-------------------------\n", "STARLINK-30402\n", "2460208.7\n", "-------------------------\n", "STARLINK-30402\n", "2460208.9\n", "-------------------------\n", "STARLINK-30402\n", "2460209.1\n", "-------------------------\n", "STARLINK-30402\n", "2460209.3\n", "-------------------------\n", "STARLINK-30402\n", "2460209.5\n", "-------------------------\n", "STARLINK-30402\n", "2460209.7\n", "-------------------------\n", "STARLINK-30411\n", "2460208.5\n", "-------------------------\n", "STARLINK-30411\n", "2460208.7\n", "-------------------------\n", "STARLINK-30411\n", "2460208.9\n", "-------------------------\n", "STARLINK-30411\n", "2460209.1\n", "-------------------------\n", "STARLINK-30411\n", "2460209.3\n", "-------------------------\n", "STARLINK-30411\n", "2460209.5\n", "-------------------------\n", "STARLINK-30411\n", "2460209.7\n", "-------------------------\n", "STARLINK-30418\n", "2460208.5\n", "-------------------------\n", "STARLINK-30418\n", "2460208.7\n", "-------------------------\n", "STARLINK-30418\n", "2460208.9\n", "-------------------------\n", "STARLINK-30418\n", "2460209.1\n", "-------------------------\n", "STARLINK-30418\n", "2460209.3\n", "-------------------------\n", "STARLINK-30418\n", "2460209.5\n", "-------------------------\n", "STARLINK-30418\n", "2460209.7\n", "-------------------------\n" ] } ], "source": [ "print(\"Not Currently Visible: \")\n", "for satellite in not_visible_satellites:\n", " satellite_info = dict(zip(fields, satellite, strict=True))\n", " print(satellite_info[\"name\"])\n", " print(satellite_info[\"julian_date\"])\n", " print(\"-------------------------\")" ] } ], "metadata": { "kernelspec": { "display_name": "env", "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.12.11" } }, "nbformat": 4, "nbformat_minor": 5 }