def test_get_seeing_using_different_start_month(self): seeing1 = SeeingModel(TimeHandler("2020-05-24")) self.assertEqual(seeing1.offset, 12441600) seeing1.initialize(self.environment_config, Filters()) self.assertEqual(seeing1.get_seeing(75400), 0.437314003705978) self.assertEqual(seeing1.get_seeing(76700), 0.510206997394562) self.assertEqual(seeing1.get_seeing(63190400), 0.453994989395142) self.assertEqual(seeing1.get_seeing(189424900), 0.386815994977951)
def test_visit_time(self): self.observatory_configure() target = topic_helpers.target # Make it so initial timestamp is 0 time_handler = TimeHandler("1970-01-01") visit_time = self.observatory.calculate_visit_time( target, time_handler) self.assertEqual(visit_time[0], 34.0)
def __init__(self, options, configuration, database): """Initialize the class. Parameters ---------- options : argparse.Namespace The instance returned by ArgumentParser containing the command-line options. configuration : :class:`.SimulationConfig` The simulation configuration instance. database : :class:`.SocsDatabase` The simulation database instance. """ self.opts = options self.conf = configuration self.db = database if self.opts.frac_duration == -1: self.fractional_duration = self.conf.survey.duration else: self.fractional_duration = self.opts.frac_duration self.conf.survey.duration = self.opts.frac_duration self.time_handler = TimeHandler(self.conf.survey.start_date) self.log = logging.getLogger("kernel.Simulator") self.sal = SalManager() self.seq = Sequencer(self.conf.observing_site, self.conf.survey.idle_delay) self.dh = DowntimeHandler() self.conf_comm = ConfigurationCommunicator() self.sun = Sun() self.cloud_model = CloudModel(self.time_handler) self.seeing_model = SeeingModel(self.time_handler) self.field_database = FieldsDatabase() self.field_selection = FieldSelection() self.obs_site_info = (self.conf.observing_site.longitude, self.conf.observing_site.latitude) self.wait_for_scheduler = not self.opts.no_scheduler self.observation_proposals_counted = 1 self.target_proposals_counted = 1 self.socs_timeout = 180.0 # seconds if self.opts.scheduler_timeout > self.socs_timeout: self.socs_timeout = self.opts.scheduler_timeout
def test_observe(self): self.observatory_configure() target = topic_helpers.target observation = scheduler_observationC() # Make it so initial timestamp is 0 time_handler = TimeHandler("1970-01-01") slew_info, exposures = self.observatory.observe( time_handler, target, observation) self.assertEqual(observation.observationId, 1) self.assertEqual(observation.exposure_times[1], 15.0) self.assertAlmostEqual(observation.observation_start_time, self.truth_slew_time, delta=1e-4) self.assertEqual(len(slew_info), 5) self.assertIsNotNone(slew_info["slew_history"]) self.assertIsNotNone(slew_info["slew_final_state"]) self.assertIsNotNone(slew_info["slew_initial_state"]) self.assertIsNotNone(slew_info["slew_activities"]) self.assertIsNotNone(slew_info["slew_maxspeeds"]) self.assertEqual(self.observatory.exposures_made, 2) self.assertEqual(len(exposures), 2) self.assertEqual(len(exposures["target_exposures"]), 2) self.assertEqual(len(exposures["observation_exposures"]), 2)
def setUp(self): self.th = TimeHandler("2020-01-01") self.seeing = SeeingModel(self.th) self.environment_config = Environment() self.num_original_values = 210384 self.elapsed_time = 8 * 24 * 3600