def test_is_visible(self): feature1 = LunarFeature("A", 0.1, 0.0, 46.0, 0.01, 0.01, "Crater", "Taruntius", "LAC-61", "Lunar", "Telescope") feature2 = LunarFeature("B", 1.0, 50.0, 46.0, 0.5, 0.5, "Crater", "Endymion", "LAC-14", "Lunar", "Binocular") feature3 = LunarFeature("C", 100.0, -30.0, 46.0, 5.0, 10.0, "Mare", "Fracastorius", "LAC-97", "Lunar", "Naked Eye") self.mi.update(self.date_list[0]) assert self.mi.is_visible(feature1) is False assert self.mi.is_visible(feature2) is False assert self.mi.is_visible(feature3) is False self.mi.update((2013, 10, 8, 6, 15, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is False assert self.mi.is_visible(feature3) is False self.mi.update((2013, 10, 8, 7, 0, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is False self.mi.update((2013, 10, 8, 16, 0, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is True self.mi.update((2013, 10, 9, 12, 0, 0)) assert self.mi.is_visible(feature1) is False assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is True self.mi.update((2013, 10, 10, 5, 0, 0)) assert self.mi.is_visible(feature1) is False assert self.mi.is_visible(feature2) is False assert self.mi.is_visible(feature3) is True self.mi.update((2013, 10, 21, 2, 30, 0)) assert self.mi.is_visible(feature1) is False assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is True self.mi.update((2013, 10, 21, 19, 0, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is True self.mi.update((2013, 10, 22, 15, 0, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is True assert self.mi.is_visible(feature3) is False self.mi.update((2013, 10, 23, 0, 0, 0)) assert self.mi.is_visible(feature1) is True assert self.mi.is_visible(feature2) is False assert self.mi.is_visible(feature3) is False self.mi.update((2013, 10, 23, 1, 0, 0)) assert self.mi.is_visible(feature1) is False assert self.mi.is_visible(feature2) is False assert self.mi.is_visible(feature3) is False
def load(self, moon_info=None, limit=None): """Read the Lunar features from the database. Parameters ---------- moon_info : :class:`.MoonInfo`, optional Instance of the Lunar information class. limit : int, optional Restrict the number of features read to the given value. """ if len(self.features) != 0: self.features = collections.OrderedDict() cur = self.conn.cursor() sql = "select * from Features where Lunar_Code = \"{}\" or "\ "Lunar_Code = \"Both\"".format(self.club_name) if limit is not None: sql += " limit {}".format(limit) cur.execute(sql) for row in cur: feature = LunarFeature.from_row(row) try: is_visible = moon_info.is_visible(feature) except AttributeError: is_visible = True if is_visible: self.features[id(feature)] = feature self.club_type.add(row[11]) self.feature_type.add(row[7]) cur.close()
def test_basic_information_after_creation(self): lf = LunarFeature(*self.feature_info) assert lf.name == self.feature_info[0] assert lf.diameter == self.feature_info[1] assert lf.latitude == self.feature_info[2] assert lf.longitude == self.feature_info[3] assert lf.delta_latitude == self.feature_info[4] assert lf.delta_longitude == self.feature_info[5] assert lf.feature_type == self.feature_info[6] assert lf.quad_name == self.feature_info[7] assert lf.quad_code == self.feature_info[8] assert lf.code_name == self.feature_info[9] assert lf.lunar_club_type == self.feature_info[10] assert lf.latitude_range() == (-62.430559651643, -54.815102116853005) assert lf.longitude_range() == (-22.034792792535, -7.420187842583001) assert lf.feature_angle() == 194.10225514559056 val = str(lf) assert val.startswith("Name")
def test_is_libration_ok(self): feature1 = LunarFeature("A", 374.0, -2.0, 87.0, 12.0, 12.0, "Mare", "Ansgarius", "LAC-81", "LunarII", None) feature2 = LunarFeature("B", 358.0, 13.0, 86.5, 9.0, 12.0, "Mare", "Neper", "LAC-63", "LunarII", None) feature3 = LunarFeature("C", 682.0, -19.5, -95.0, 22.5, 23.0, "Mons", "Mare Orientale", "LAC-108", "LunarII", None) self.mi.update((2017, 5, 27, 12, 21, 0)) assert self.mi.is_libration_ok(feature1) is True assert self.mi.is_libration_ok(feature2) is True assert self.mi.is_libration_ok(feature3) is False assert self.mi.is_visible(feature1) is True self.mi.update((2017, 11, 24, 22, 0, 0)) assert self.mi.is_libration_ok(feature1) is False assert self.mi.is_libration_ok(feature2) is False assert self.mi.is_visible(feature2) is False assert self.mi.is_libration_ok(feature3) is True assert self.mi.is_visible(feature3) is False self.mi.update((2017, 7, 17, 6, 0, 0)) assert self.mi.is_libration_ok(feature1) is False assert self.mi.is_libration_ok(feature2) is False assert self.mi.is_libration_ok(feature3) is True
def test_creation_from_database_row(self): feature_row = (33, "Clavius", 230.77, -58.622830884248, -14.727490317559, 7.61545753479, 14.614604949952, "Crater", "Clavius", "LAC-126", "Both", "Binocular") lf = LunarFeature.from_row(feature_row) assert lf.name == feature_row[1] assert lf.diameter == feature_row[2] assert lf.latitude == feature_row[3] assert lf.longitude == feature_row[4] assert lf.delta_latitude == feature_row[5] assert lf.delta_longitude == feature_row[6] assert lf.feature_type == feature_row[7] assert lf.quad_name == feature_row[8] assert lf.quad_code == feature_row[9] assert lf.code_name == feature_row[10] assert lf.lunar_club_type == feature_row[11]
def test_basic_information_after_creation(self): lf = LunarFeature(*self.feature_info) assert lf.name == self.feature_info[0] assert lf.diameter == self.feature_info[1] assert lf.latitude == self.feature_info[2] assert lf.longitude == self.feature_info[3] assert lf.delta_latitude == self.feature_info[4] assert lf.delta_longitude == self.feature_info[5] assert lf.feature_type == self.feature_info[6] assert lf.quad_name == self.feature_info[7] assert lf.quad_code == self.feature_info[8] assert lf.code_name == self.feature_info[9] assert lf.lunar_club_type == self.feature_info[10] val = str(lf) assert val.startswith("Name")
def test_list_from_feature(self): lf = LunarFeature(*self.feature_info) feature_list = lf.list_from_feature() for value, truth in zip(feature_list, self.feature_info): assert value == truth