def test_predicted_pass_no_eq(self): aos = datetime.datetime.utcnow() max_elevation_date = datetime.datetime.utcnow() + datetime.timedelta( minutes=5) los = datetime.datetime.utcnow() + datetime.timedelta(minutes=10) max_elevation_position = Position(when_utc=max_elevation_date, position_ecef=(1, 1, 1), velocity_ecef=(1, 1, 1), error_estimate=0) p1 = PredictedPass(sate_id=1, location=ARG, aos=aos, los=los, duration_s=600, max_elevation_date=max_elevation_date, max_elevation_position=max_elevation_position, max_elevation_deg=10) p2 = PredictedPass(sate_id=1, location=ARG, aos=aos, los=los, duration_s=600, max_elevation_date=max_elevation_date, max_elevation_position=max_elevation_position, max_elevation_deg=50) self.assertNotEqual(p1, p2) self.assertNotEqual(p2, p1)
def _build_predicted_pass(self, accuratepass): """Returns a classic predicted pass""" tca_position = self.propagator.get_position(accuratepass.tca) return PredictedPass(self.location, self.propagator.sate_id, max_elevation_deg=accuratepass.max_elevation_deg, aos=accuratepass.aos, los=accuratepass.los, duration_s=accuratepass.duration.total_seconds(), max_elevation_position=tca_position, max_elevation_date=accuratepass.tca, )
def test_midpoint(self): aos = dt.datetime.utcnow() max_elevation_date = aos + dt.timedelta(minutes=5) los = aos + dt.timedelta(minutes=10) pass_ = PredictedPass(sate_id=1, location=ARG, aos=aos, los=los, duration_s=600, max_elevation_date=max_elevation_date, max_elevation_position=None, max_elevation_deg=10) self.assertEqual(pass_.midpoint, aos + dt.timedelta(minutes=5))
def test_off_nadir_satellite_passing_right_means_negative_sign(self): position_ecef = llh_to_ecef(0, 10, 500 * 1000) velocity_ecef = (0, 0, -1) max_elevation_position = Position(None, position_ecef, velocity_ecef, None) pass_ = PredictedPass(sate_id=1, location=self.location, aos=None, los=None, duration_s=None, max_elevation_position=max_elevation_position, max_elevation_deg=None) self.assertLessEqual(pass_.off_nadir_deg, 0)
def _get_next_pass(self, location, when_utc, aos_at_dg=0, limit_date=None): if not isinstance(location, Location): raise TypeError("location must be a Location instance") pass_ = PredictedPass(location=location, sate_id=self.sate_id, aos=None, los=None, max_elevation_date=None, max_elevation_position=None, max_elevation_deg=0, duration_s=0) seconds = 0 self._iterations = 0 while True: # to optimize the increment in seconds must be inverse proportional to # the distance of 0 elevation date = when_utc + datetime.timedelta(seconds=seconds) if limit_date is not None and date > limit_date: raise NotReachable('Propagation limit date exceded') elev_pos = self.get_position(date) _, elev = location.get_azimuth_elev(elev_pos) elev_deg = degrees(elev) if elev_deg > pass_.max_elevation_deg: pass_.max_elevation_position = elev_pos pass_.max_elevation_date = date pass_.max_elevation_deg = elev_deg if elev_deg > aos_at_dg and pass_.aos is None: pass_.aos = date if pass_.aos and elev_deg < aos_at_dg: pass_.los = date pass_.duration_s = (pass_.los - pass_.aos).total_seconds() break if elev_deg < -2: delta_s = abs(elev_deg) * 15 + 10 else: delta_s = 20 seconds += delta_s self._iterations += 1 return pass_
def test_off_nadir_satellite_exactly_over(self): position_ecef = llh_to_ecef(0, 0, 500 * 1000) # A satellite exactly over the point velocity_ecef = (0, 0, 1) max_elevation_position = Position(None, position_ecef, velocity_ecef, None) pass_ = PredictedPass(sate_id=1, location=self.location, aos=None, los=None, duration_s=None, max_elevation_position=max_elevation_position, max_elevation_deg=None) self.assertAlmostEqual(pass_.off_nadir_deg, 0, delta=0.02)
def test_off_nadir_satellite_passing_left_means_positive_sign(self): position_ecef = llh_to_ecef(0, -10, 500 * 1000) # A satellite exactyl over the point velocity_ecef = (0, 0, -1) max_elevation_position = Position(None, position_ecef, velocity_ecef, None) pass_ = PredictedPass(sate_id=1, location=self.location, aos=None, los=None, duration_s=None, max_elevation_position=max_elevation_position, max_elevation_deg=None) self.assertGreaterEqual(pass_.off_nadir_deg, 0)
def get_pass(location, name, aos, los, max_elevation, when_max_elevation = 0.5): duration_s = (los - aos).total_seconds() max_elevation_date = aos + datetime.timedelta(seconds=duration_s * when_max_elevation) return PredictedPass(location, name, max_elevation, aos, los, duration_s, max_elevation_date=max_elevation_date)