{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#!pip install shapely" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "import os\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import healpy as hp\n", "\n", "from rubin_sim.data import get_data_dir\n", "import sqlite3\n", "\n", "\n", "from part1 import pointToLineDistance\n", "from utils import create_constellation, starlink_constellation" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "# find the baseline survey simulation file that got downloaded with rubin_sim\n", "dd = get_data_dir()\n", "baseline_file = os.path.join(dd,'sim_baseline/baseline.db')\n", "\n", "# Conenct to the sqlite database\n", "con = sqlite3.connect(baseline_file)\n", "\n", "# We can just load the whole thing into a dataframe\n", "df = pd.read_sql('select * from observations;', con)\n", "\n", "con.close()" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
observationIdfieldRAfieldDecobservationStartMJDflush_by_mjdvisitExposureTimefilterrotSkyPosrotSkyPos_desirednumExposures...sunAzsunRAsunDecmoonRAmoonDecmoonDistancesolarElongmoonPhasecummTelAzscripted_id
00310.024480-60.81292860218.00180660218.02357630.0y-297.249225-297.2492252...255.593220186.644048-2.87082727.60946311.95611194.490314102.95865187.407902169.4544440
11310.601871-63.56142560218.00225460218.02357630.0y-297.708278-297.7082782...255.500445186.644453-2.87100127.61533811.95943895.029204101.74395987.404494170.5028750
22311.292611-66.31777460218.00270360218.02357630.0y-297.909620-297.9096202...255.407493186.644858-2.87117627.62120811.96276595.563446100.49786087.401088171.4067380
33312.140731-69.08266660218.00315260218.02357630.0y-297.838337-297.8383372...255.314364186.645264-2.87135027.62707311.96609396.09284299.22126187.397685172.1977910
44304.170163-73.37544260218.00362360218.02357630.0y-309.290623-309.2906232...255.216260186.645690-2.87153327.63323211.96959399.60537094.82114287.394110177.2398030
..................................................................
20817442081744347.124408-44.12166563870.10431263870.13574430.0u16.31387916.3138791...226.952534186.231318-2.693059256.910781-17.67980377.943326130.15487539.323876118.2561600
20817452081745344.049134-45.89553163870.10474663870.13574430.0u5.7510505.7510501...226.779699186.231710-2.693228256.915974-17.67942475.449290127.58979939.326371127.9561450
20817462081746340.774233-47.59327463870.10518063870.13574430.0u-4.958170-4.9581701...226.606027186.232103-2.693397256.921178-17.67904372.960208124.99724339.328872136.9576540
20817472081747337.288929-49.20207763870.10561463870.13574430.0u-15.452126-15.4521261...226.432028186.232495-2.693565256.926379-17.67866470.481515122.38291539.331373144.9248850
20817482081748345.028793-48.92782063870.10609063870.13574430.0u3.1656843.1656841...226.240437186.232925-2.693750256.932091-17.67824775.538872125.19919539.334119129.7598360
\n", "

2081749 rows × 44 columns

\n", "
" ], "text/plain": [ " observationId fieldRA fieldDec observationStartMJD \\\n", "0 0 310.024480 -60.812928 60218.001806 \n", "1 1 310.601871 -63.561425 60218.002254 \n", "2 2 311.292611 -66.317774 60218.002703 \n", "3 3 312.140731 -69.082666 60218.003152 \n", "4 4 304.170163 -73.375442 60218.003623 \n", "... ... ... ... ... \n", "2081744 2081744 347.124408 -44.121665 63870.104312 \n", "2081745 2081745 344.049134 -45.895531 63870.104746 \n", "2081746 2081746 340.774233 -47.593274 63870.105180 \n", "2081747 2081747 337.288929 -49.202077 63870.105614 \n", "2081748 2081748 345.028793 -48.927820 63870.106090 \n", "\n", " flush_by_mjd visitExposureTime filter rotSkyPos \\\n", "0 60218.023576 30.0 y -297.249225 \n", "1 60218.023576 30.0 y -297.708278 \n", "2 60218.023576 30.0 y -297.909620 \n", "3 60218.023576 30.0 y -297.838337 \n", "4 60218.023576 30.0 y -309.290623 \n", "... ... ... ... ... \n", "2081744 63870.135744 30.0 u 16.313879 \n", "2081745 63870.135744 30.0 u 5.751050 \n", "2081746 63870.135744 30.0 u -4.958170 \n", "2081747 63870.135744 30.0 u -15.452126 \n", "2081748 63870.135744 30.0 u 3.165684 \n", "\n", " rotSkyPos_desired numExposures ... sunAz sunRA \\\n", "0 -297.249225 2 ... 255.593220 186.644048 \n", "1 -297.708278 2 ... 255.500445 186.644453 \n", "2 -297.909620 2 ... 255.407493 186.644858 \n", "3 -297.838337 2 ... 255.314364 186.645264 \n", "4 -309.290623 2 ... 255.216260 186.645690 \n", "... ... ... ... ... ... \n", "2081744 16.313879 1 ... 226.952534 186.231318 \n", "2081745 5.751050 1 ... 226.779699 186.231710 \n", "2081746 -4.958170 1 ... 226.606027 186.232103 \n", "2081747 -15.452126 1 ... 226.432028 186.232495 \n", "2081748 3.165684 1 ... 226.240437 186.232925 \n", "\n", " sunDec moonRA moonDec moonDistance solarElong moonPhase \\\n", "0 -2.870827 27.609463 11.956111 94.490314 102.958651 87.407902 \n", "1 -2.871001 27.615338 11.959438 95.029204 101.743959 87.404494 \n", "2 -2.871176 27.621208 11.962765 95.563446 100.497860 87.401088 \n", "3 -2.871350 27.627073 11.966093 96.092842 99.221261 87.397685 \n", "4 -2.871533 27.633232 11.969593 99.605370 94.821142 87.394110 \n", "... ... ... ... ... ... ... \n", "2081744 -2.693059 256.910781 -17.679803 77.943326 130.154875 39.323876 \n", "2081745 -2.693228 256.915974 -17.679424 75.449290 127.589799 39.326371 \n", "2081746 -2.693397 256.921178 -17.679043 72.960208 124.997243 39.328872 \n", "2081747 -2.693565 256.926379 -17.678664 70.481515 122.382915 39.331373 \n", "2081748 -2.693750 256.932091 -17.678247 75.538872 125.199195 39.334119 \n", "\n", " cummTelAz scripted_id \n", "0 169.454444 0 \n", "1 170.502875 0 \n", "2 171.406738 0 \n", "3 172.197791 0 \n", "4 177.239803 0 \n", "... ... ... \n", "2081744 118.256160 0 \n", "2081745 127.956145 0 \n", "2081746 136.957654 0 \n", "2081747 144.924885 0 \n", "2081748 129.759836 0 \n", "\n", "[2081749 rows x 44 columns]" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# take a look at what the data looks like\n", "df" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "data=df[['fieldRA','fieldDec','observationStartMJD']]" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fieldRAfieldDecobservationStartMJD
0310.024480-60.81292860218.001806
1310.601871-63.56142560218.002254
2311.292611-66.31777460218.002703
3312.140731-69.08266660218.003152
4304.170163-73.37544260218.003623
............
2081744347.124408-44.12166563870.104312
2081745344.049134-45.89553163870.104746
2081746340.774233-47.59327463870.105180
2081747337.288929-49.20207763870.105614
2081748345.028793-48.92782063870.106090
\n", "

2081749 rows × 3 columns

\n", "
" ], "text/plain": [ " fieldRA fieldDec observationStartMJD\n", "0 310.024480 -60.812928 60218.001806\n", "1 310.601871 -63.561425 60218.002254\n", "2 311.292611 -66.317774 60218.002703\n", "3 312.140731 -69.082666 60218.003152\n", "4 304.170163 -73.375442 60218.003623\n", "... ... ... ...\n", "2081744 347.124408 -44.121665 63870.104312\n", "2081745 344.049134 -45.895531 63870.104746\n", "2081746 340.774233 -47.593274 63870.105180\n", "2081747 337.288929 -49.202077 63870.105614\n", "2081748 345.028793 -48.927820 63870.106090\n", "\n", "[2081749 rows x 3 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "***random helper functions because it wont import properly\n" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "\n", "import numpy as np \n", "from shapely.geometry import LineString\n", "from shapely.geometry import Point\n", "from rubin_sim.utils import Site\n", "import ephem\n", "from rubin_sim.utils import _angularSeparation, _buildTree, xyz_angular_radius\n", "from rubin_sim.scheduler.utils import read_fields\n", "from astropy import time\n", "from shapely import geometry\n", "\n", "class Constellation(object):\n", " \"\"\"\n", " Have a class to hold ephem satellite objects\n", "\n", " Parameters\n", " ----------\n", " sat_tle_list : list of str\n", " A list of satellite TLEs to be used\n", " tstep : float (5)\n", " The time step to use when computing satellite positions in an exposure\n", " \"\"\"\n", "\n", " def __init__(self, sat_tle_list, alt_limit=30., fov=3.5, tstep=5., exptime=30., seed=42):\n", " np.random.seed(seed)\n", " self.sat_list = [ephem.readtle(tle.split('\\n')[0], tle.split('\\n')[1], tle.split('\\n')[2]) for tle in sat_tle_list]\n", " self.alt_limit_rad = np.radians(alt_limit)\n", " self.fov_rad = np.radians(fov)\n", " self._make_observer()\n", " self._make_fields()\n", " self.tsteps = np.arange(0, exptime+tstep, tstep)/3600./24. # to days\n", "\n", " self.radius = xyz_angular_radius(fov)\n", "\n", " def _make_fields(self):\n", " \"\"\"\n", " Make tesselation of the sky\n", " \"\"\"\n", " # RA and dec in radians\n", " fields = read_fields()\n", "\n", " # crop off so we only worry about things that are up\n", " good = np.where(fields['dec'] > (self.alt_limit_rad - self.fov_rad))[0]\n", " self.fields = fields[good]\n", "\n", " self.fields_empty = np.zeros(self.fields.size)\n", "\n", " # we'll use a single tessellation of alt az\n", " leafsize = 100\n", " self.tree = _buildTree(self.fields['RA'], self.fields['dec'], leafsize, scale=None)\n", "\n", " def _make_observer(self):\n", " telescope = Site(name='LSST')\n", "\n", " self.observer = ephem.Observer()\n", " self.observer.lat = telescope.latitude_rad\n", " self.observer.lon = telescope.longitude_rad\n", " self.observer.elevation = telescope.height\n", "\n", " def advance_epoch(self, advance=100):\n", " \"\"\"\n", " Advance the epoch of all the satellites\n", " \"\"\"\n", "\n", " # Because someone went and put a valueError where there should have been a warning\n", " # I prodly present the hackiest kludge of all time\n", " for sat in self.sat_list:\n", " sat._epoch += advance\n", "\n", " def set_epoch(self, mjd):\n", " for sat in self.sat_list:\n", " sat._epoch = mjd\n", "\n", " #self.update_mjd gives a bunch of positions \n", " def update_mjd(self, mjd, indx=None):\n", " \"\"\"\n", " mjd : float\n", " The MJD to advance the satellites to (days)\n", " indx : list-like of ints\n", " Only propigate a subset of satellites. \n", " \"\"\"\n", " self.active_indx = indx\n", "\n", " self.observer.date = ephem.date(time.Time(mjd, format='mjd').datetime)\n", "\n", " self.altitudes_rad = []\n", " self.azimuth_rad = []\n", " self.eclip = []\n", " if self.active_indx is None:\n", " indx = np.arange(len(self.sat_list))\n", " else:\n", " indx = self.active_indx\n", " for i in indx:\n", " sat = self.sat_list[i]\n", " try:\n", " sat.compute(self.observer)\n", " except ValueError:\n", " self.set_epoch(self.observer.date+np.random.uniform()*10)\n", " sat.compute(self.observer)\n", " self.altitudes_rad.append(sat.alt)\n", " self.azimuth_rad.append(sat.az)\n", " self.eclip.append(sat.eclipsed)\n", "\n", " self.altitudes_rad = np.array(self.altitudes_rad)\n", " self.azimuth_rad = np.array(self.azimuth_rad)\n", " self.eclip = np.array(self.eclip)\n", " # Keep track of the ones that are up and illuminated\n", " self.above_alt_limit = np.where((self.altitudes_rad >= self.alt_limit_rad) & (self.eclip == False))[0]\n", " \n", "\n", "\n", " def check_pointing(self, pointing_alt, pointing_az, mjd, exposure_time, fov_radius=1.75):\n", " \"\"\"Calculates the length of satellite streaks in a pointing. \n", " Parameters\n", " ----------\n", " Param1 : float \n", " the altitude of the pointing (degrees).\n", " Param2 : float\n", " the azimuth of the pointing (degrees).\n", " Param3 : float\n", " the current mjd (days).\n", " Param4: float \n", " the length of exposure (seconds).\n", " fov_radius : float (1.75)\n", " The radius of the field of view (degrees), default 1.75.\n", "\n", " Returns\n", " -------\n", " list\n", " list of streak length in the given pointing\"\"\"\n", " \n", " fov_radius = np.radians(fov_radius)\n", " pointing_alt=np.radians(pointing_alt)\n", " pointing_az=np.radians(pointing_az)\n", " exposure_time=exposure_time/86400\n", " streak_len=[]\n", "\n", " self.update_mjd(mjd)\n", " inAlt_list=self.altitudes_rad + 0\n", " inAz_list=self.azimuth_rad + 0\n", " \n", " self.update_mjd(mjd+exposure_time)\n", " finAlt_list=self.altitudes_rad + 0 \n", " finAz_list=self.azimuth_rad + 0\n", " # print(self.above_alt_limit)\n", " \n", " for index in self.above_alt_limit: \n", " # print(index)\n", " elem_list=list(zip(inAlt_list, inAz_list, finAlt_list, finAz_list))[index]\n", " initial_alt=elem_list[0]\n", " initial_az=elem_list[1]\n", " end_alt=elem_list[2]\n", " end_az=elem_list[3]\n", " # for initial_alt, initial_az, end_alt, end_az in zip(inAlt_list, inAz_list,\n", " # finAlt_list, finAz_list):\n", " # for i in range(40):\n", " distance=pointToLineDistance(initial_alt, initial_az, end_alt, end_az, pointing_alt, pointing_az)\n", " # print(fov_radius,distance)\n", " if distance\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m pointingDec\u001b[39m=\u001b[39mdata\u001b[39m.\u001b[39mloc[i,\u001b[39m'\u001b[39m\u001b[39mfieldDec\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[1;32m 6\u001b[0m mjd\u001b[39m=\u001b[39mdata\u001b[39m.\u001b[39mloc[i,\u001b[39m'\u001b[39m\u001b[39mobservationStartMJD\u001b[39m\u001b[39m'\u001b[39m]\n\u001b[0;32m----> 7\u001b[0m satlist\u001b[39m=\u001b[39mtest_const\u001b[39m.\u001b[39;49mcheck_pointing(pointingRa,pointingDec, mjd, \u001b[39m30\u001b[39;49m)\n\u001b[1;32m 8\u001b[0m res\u001b[39m+\u001b[39m\u001b[39m=\u001b[39msatlist\n\u001b[1;32m 9\u001b[0m \u001b[39mif\u001b[39;00m i\u001b[39m%\u001b[39m\u001b[39m100\u001b[39m\u001b[39m==\u001b[39m\u001b[39m0\u001b[39m:\n", "\u001b[1;32m/Users/apple/Desktop/Rubin/satellite-dodging/test.ipynb Cell 8'\u001b[0m in \u001b[0;36mConstellation.check_pointing\u001b[0;34m(self, pointing_alt, pointing_az, mjd, exposure_time, fov_radius)\u001b[0m\n\u001b[1;32m 138\u001b[0m inAlt_list\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39maltitudes_rad \u001b[39m+\u001b[39m \u001b[39m0\u001b[39m\n\u001b[1;32m 139\u001b[0m inAz_list\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mazimuth_rad \u001b[39m+\u001b[39m \u001b[39m0\u001b[39m\n\u001b[0;32m--> 141\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mupdate_mjd(mjd\u001b[39m+\u001b[39;49mexposure_time)\n\u001b[1;32m 142\u001b[0m finAlt_list\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39maltitudes_rad \u001b[39m+\u001b[39m \u001b[39m0\u001b[39m \n\u001b[1;32m 143\u001b[0m finAz_list\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mazimuth_rad \u001b[39m+\u001b[39m \u001b[39m0\u001b[39m\n", "\u001b[1;32m/Users/apple/Desktop/Rubin/satellite-dodging/test.ipynb Cell 8'\u001b[0m in \u001b[0;36mConstellation.update_mjd\u001b[0;34m(self, mjd, indx)\u001b[0m\n\u001b[1;32m 97\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mset_epoch(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mobserver\u001b[39m.\u001b[39mdate\u001b[39m+\u001b[39mnp\u001b[39m.\u001b[39mrandom\u001b[39m.\u001b[39muniform()\u001b[39m*\u001b[39m\u001b[39m10\u001b[39m)\n\u001b[1;32m 98\u001b[0m sat\u001b[39m.\u001b[39mcompute(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mobserver)\n\u001b[0;32m---> 99\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39maltitudes_rad\u001b[39m.\u001b[39mappend(sat\u001b[39m.\u001b[39;49malt)\n\u001b[1;32m 100\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mazimuth_rad\u001b[39m.\u001b[39mappend(sat\u001b[39m.\u001b[39maz)\n\u001b[1;32m 101\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39meclip\u001b[39m.\u001b[39mappend(sat\u001b[39m.\u001b[39meclipsed)\n", "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "res=[]\n", "for i in range(20000): \n", " exposure=30\n", " pointingRa=data.loc[i,'fieldRA']\n", " pointingDec=data.loc[i,'fieldDec']\n", " mjd=data.loc[i,'observationStartMJD']\n", " satlist=test_const.check_pointing(pointingRa,pointingDec, mjd, 30)\n", " res+=satlist\n", " if i%100==0:\n", " print(i)\n", "print(res) \n" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "310.02448010095446" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.loc[0,'fieldRA']" ] }, { "cell_type": "code", "execution_count": 153, "metadata": {}, "outputs": [], "source": [ "satlist=test_const.check_pointing(310.024480,-60.812928, 60218.004959, 30)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 154, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 154, "metadata": {}, "output_type": "execute_result" } ], "source": [ "satlist" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 117, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 117, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(filter(None, satlist))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "# OK, let's say we have a pointing at Alt,Az= 0,45. Let's test the calculate_length for various cases" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.5\n" ] } ], "source": [ "# I think this is expecting all radians\n", "radius = np.radians(1.75)\n", "pointing_az = 0.\n", "pointing_alt = np.radians(45.)\n", "\n", "sat_init_alt = np.radians(20.)\n", "sat_final_alt = np.radians(60.)\n", "\n", "sat_init_az = 0.\n", "sat_final_az = 0.\n", "\n", "test_val = calculate_length(sat_init_alt, sat_init_az, sat_final_alt, sat_final_az,\n", " pointing_alt, pointing_az, radius=radius)\n", "print(np.degrees(test_val))" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# OK, that worked! the streak did indeed go all the way across the field of view\n" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.5\n" ] } ], "source": [ "# try another.\n", "radius = np.radians(1.75)\n", "pointing_az = np.radians(180.)\n", "pointing_alt = np.radians(45.)\n", "\n", "sat_init_alt = np.radians(45.)\n", "sat_final_alt = np.radians(45.)\n", "\n", "sat_init_az = np.radians(110.)\n", "sat_final_az = np.radians(220.)\n", "\n", "test_val = calculate_length(sat_init_alt, sat_init_az, sat_final_alt, sat_final_az,\n", " pointing_alt, pointing_az, radius=radius)\n", "if test_val is not None:\n", " print(np.degrees(test_val))\n", "else:\n", " print('hmmm')" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.793435724659027\n" ] } ], "source": [ "# OK, again, we got a satellite to cross the entire diameter correctly\n", "\n", "# If I move the satellite alt up a bit, I should get a smaller value because I'm not crossing the center\n", "radius = np.radians(1.75)\n", "pointing_az = np.radians(180.)\n", "pointing_alt = np.radians(45.)\n", "\n", "sat_init_alt = np.radians(46.5)\n", "sat_final_alt = np.radians(46.5)\n", "\n", "sat_init_az = np.radians(110.)\n", "sat_final_az = np.radians(220.)\n", "\n", "test_val = calculate_length(sat_init_alt, sat_init_az, sat_final_alt, sat_final_az,\n", " pointing_alt, pointing_az, radius=radius)\n", "if test_val is not None:\n", " print(np.degrees(test_val))\n", "else:\n", " print('hmmm')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "# Victory, that's a smaller arc length" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.75\n" ] } ], "source": [ "# Now let's break some things\n", "radius = np.radians(1.75)\n", "pointing_az = 0.\n", "pointing_alt = np.radians(45.)\n", "\n", "sat_init_alt = np.radians(45.)\n", "sat_final_alt = np.radians(60.)\n", "\n", "sat_init_az = 0.\n", "sat_final_az = 0.\n", "\n", "test_val = calculate_length(sat_init_alt, sat_init_az, sat_final_alt, sat_final_az,\n", " pointing_alt, pointing_az, radius=radius)\n", "if test_val is not None:\n", " print(np.degrees(test_val))\n", "else:\n", " print('hmmm')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "# Here the satellite starts inside the FoV and moves out. So that's a case that should work but didn't" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.5\n" ] } ], "source": [ "# Test a wrap-around case. \n", "radius = np.radians(1.75)\n", "pointing_az = 0.\n", "pointing_alt = np.radians(45.)\n", "\n", "sat_init_alt = np.radians(45.)\n", "sat_final_alt = np.radians(45)\n", "\n", "sat_init_az = np.radians(350.)\n", "sat_final_az = np.radians(20.)\n", "\n", "test_val = calculate_length(sat_init_alt, sat_init_az, sat_final_alt, sat_final_az,\n", " pointing_alt, pointing_az, radius=radius)\n", "if test_val is not None:\n", " print(np.degrees(test_val))\n", "else:\n", " print('hmmm')" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "# oh good, that worked" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "interpreter": { "hash": "d5b7d53efd5d52579f7822329e538328dffa22138acad02cbbf811937e299d40" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.12" } }, "nbformat": 4, "nbformat_minor": 2 }