def test_find_moving_object_sets_comet_jform(self, alt_mock, ha_mock, ephem_mock): window = None elements = {'type' : 'MPC_COMET'} site = None find_moving_object_up_intervals(window, elements, site) assert 3 in ephem_mock.call_args[0], 'expected jform=3 not passed to calc_ephemerides'
def test_find_moving_object_sets_asteroid_jform(self, alt_mock, ha_mock, ephem_mock): window = None elements = {'type' : 'MPC_MINOR_PLANET'} site = None find_moving_object_up_intervals(window, elements, site) assert_equal(ephem_mock.call_args[0][4], 2)
def test_find_moving_object_invalid_type_raises_exception(self): window = None elements = {'type' : 'TIMS_CAT'} site = None try: find_moving_object_up_intervals(window, elements, site) except MovingViolation as e: assert_equal(str(e), "Unsupported target type: 'tims_cat'") else: assert False, "Didn't raise expected MovingViolation error"
def test_find_moving_object_up_intervals1(self): window = { 'start' : datetime(2013, 12, 10), 'end' : datetime(2013, 12, 11) } chunksize = timedelta(hours=3) expected_intervals = [ ( datetime(2013, 12, 10, 9), datetime(2013, 12, 10, 12) ), ( datetime(2013, 12, 10, 12), datetime(2013, 12, 10, 15) ) ] expected_altitudes = [ Angle(degrees=42.7537), Angle(degrees=74.9902) ] received_ints, received_alts = find_moving_object_up_intervals(window, self.elements, self.cpt, chunksize) assert_equal(len(expected_intervals), len(received_ints)) assert_equal(len(expected_altitudes), len(received_alts)) for e, r in zip(expected_intervals, received_ints): assert_equal(e, r) for e, r in zip(expected_altitudes, received_alts): assert_almost_equal(e.in_degrees(), r.in_degrees(), places=3)
def _get_moving_object_target_intervals(self, target, effective_horizon): window = { 'start': self.start_date, 'end': self.end_date, } site = self.site.copy() site['horizon'] = Angle(degrees=effective_horizon) intervals, _ = find_moving_object_up_intervals(window, target, site) return intervals
def test_find_moving_object_up_intervals3(self): window = { 'start' : datetime(2013, 12, 10, 7, 30), 'end' : datetime(2013, 12, 10, 8, 31) } chunksize = timedelta(minutes=15) expected_intervals = [ ( datetime(2013, 12, 10, 8, 0), datetime(2013, 12, 10, 8, 15) ), ( datetime(2013, 12, 10, 8, 15), datetime(2013, 12, 10, 8, 30) ), ( datetime(2013, 12, 10, 8, 30), datetime(2013, 12, 10, 8, 31) ), ] expected_altitudes = [ Angle(degrees=30.0814), Angle(degrees=33.2494), Angle(degrees=36.4200) ] received_ints, received_alts = find_moving_object_up_intervals(window, self.elements, self.cpt, chunksize) assert_equal(len(expected_intervals), len(received_ints)) assert_equal(len(expected_altitudes), len(received_alts)) for e, r in zip(expected_intervals, received_ints): assert_equal(e, r) for e, r in zip(expected_altitudes, received_alts): assert_almost_equal(e.in_degrees(), r.in_degrees(), places=3)
def test_moving_objects_respect_negative_hour_angle_limit(self, alt_mock, ha_mock, ephem_mock): window = None elements = {'type' : 'mpc_minor_planet'} site_dict = { 'name' : '1m0a.doma.cpt', 'latitude' : Angle(degrees=-32.38059), 'longitude' : Angle(degrees=20.8101083333), 'horizon' : Angle(degrees=15), 'ha_limit_neg' : Angle(degrees=-5.0*15), 'ha_limit_pos' : Angle(degrees=5.0*15), } ephem = [ { 'start' : 1, 'end' : 2, 'ra_app' : Angle(3), 'dec_app' : Angle(4), }, { 'start' : 5, 'end' : 6, 'ra_app' : Angle(7), 'dec_app' : Angle(8), }, ] chunksize = timedelta(minutes=15) alt_mock.return_value = Angle(degrees=20) ha_mock.return_value = Angle(degrees=-7*15) ephem_mock.return_value = ephem received_ints, received_alts = find_moving_object_up_intervals(window, elements, site_dict, chunksize) assert_equal(received_ints, [])