def test_duration_veto(observer): dc = Duration(30 * u.degree) time = Time('2016-08-13 17:42:00.034059') sunrise = observer.tonight(time=time, horizon=18 * u.degree)[-1] hd189733 = field_list[0] observation = Observation(Field(**hd189733), **hd189733) veto, score = dc.get_score(time, observer, observation, sunrise=sunrise) assert veto is True wasp33 = field_list[-3] observation = Observation(Field(**wasp33), **wasp33) veto, score = dc.get_score(time, observer, observation, sunrise=sunrise) assert veto is False
def test_duration_score(observer): dc = Duration(30 * u.degree) time = Time('2016-08-13 10:00:00') sunrise = observer.tonight(time=time, horizon=18 * u.degree)[-1] observation1 = Observation( Field('HD189733', '20h00m43.7135s +22d42m39.0645s')) # HD189733 observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 veto1, score1 = dc.get_score(time, observer, observation1, sunrise=sunrise) veto2, score2 = dc.get_score(time, observer, observation2, sunrise=sunrise) assert veto1 is False and veto2 is False assert score2 > score1
def add_observation(self, field_config): """Adds an `Observation` to the scheduler Args: field_config (dict): Configuration items for `Observation` """ assert field_config['name'] not in self._observations.keys(), \ self.logger.error("Cannot add duplicate field name") if 'exp_time' in field_config: field_config['exp_time'] = float( field_config['exp_time']) * u.second field = Field(field_config['name'], field_config['position']) try: if 'hdr_mode' in field_config: obs = DitheredObservation(field, **field_config) else: obs = Observation(field, **field_config) except Exception as e: self.logger.warning( "Skipping invalid field config: {}".format(field_config)) self.logger.warning(e) else: self._observations[field.name] = obs
def test_moon_avoidance(observer): mac = MoonAvoidance() time = Time('2016-08-13 10:00:00') moon = get_moon(time, observer.location) observation1 = Observation( Field('HD189733', '20h00m43.7135s +22d42m39.0645s')) # HD189733 observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 veto1, score1 = mac.get_score(time, observer, observation1, moon=moon) veto2, score2 = mac.get_score(time, observer, observation2, moon=moon) assert veto1 is False and veto2 is False assert score2 > score1
def test_observation(camera): """ Tests functionality of take_observation() """ field = Field('Test Observation', '20h00m43.7135s +22d42m39.0645s') observation = Observation(field, exp_time=1.5 * u.second) camera.take_observation(observation, headers={}) time.sleep(7)
def test_moon_veto(observer): mac = MoonAvoidance() time = Time('2016-08-13 10:00:00') moon = get_moon(time, observer.location) observation1 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik veto1, score1 = mac.get_score(time, observer, observation1, moon=moon) assert veto1 is True
def field(): return Field('Test Observation', '20h00m43.7135s +22d42m39.0645s')
def test_create_field_no_params(): with pytest.raises(TypeError): Field()
def test_create_field_Observation_name(): field = Field('Test Field - 32b', '20h00m43.7135s +22d42m39.0645s') assert field.field_name == 'TestField32B'
def test_create_field_bad_position(): with pytest.raises(ValueError): Field("TestObservation", "Bad Position")