Example #1
0
    def test_angular_separation(self):
        time = sunset_and_rise_for_date(self.data, 2020, 12, 17)[0]

        moon = self.data.ephemeris['moon']
        mercury = self.data.get_body("Mercury")

        sep, pos = angular_separation(self.data, moon, mercury, time)
        self.assertLessEqual(abs(sep.degrees - 39.1), 1.0)
        self.assertEqual(pos, EclipticPosition.BEHIND)

        sep, pos = angular_separation(self.data, mercury, moon, time)
        self.assertEqual(pos, EclipticPosition.AHEAD)
        self.assertLessEqual(abs(sep.degrees - 39.1), 1.0)

        dablin = Star.from_dataframe(self.data.stars.loc[100345])
        sep, pos = angular_separation(self.data, moon, dablin, time)
        self.assertEqual(pos, EclipticPosition.BELOW)
        self.assertLessEqual(abs(sep.degrees - 8.9), 1.0)

        sep, pos = angular_separation(self.data, dablin, moon, time)
        self.assertEqual(pos, EclipticPosition.ABOVE)
        self.assertLessEqual(abs(sep.degrees - 8.9), 1.0)

        fomalhaut = Star.from_dataframe(self.data.stars.loc[113368])
        sep, pos = angular_separation(self.data, fomalhaut, mercury, time)
        self.assertEqual(pos, EclipticPosition.BEHIND)
        self.assertLessEqual(abs(sep.degrees - 70.45), 1.0)

        sep, pos = angular_separation(self.data, mercury, fomalhaut, time)
        self.assertEqual(pos, EclipticPosition.AHEAD)
        self.assertLessEqual(abs(sep.degrees - 70.45), 1.0)
Example #2
0
    def star(self,
             ref: Union[str, int],
             culture: Optional[str] = None) -> CelestialObject:
        """Fetch a star by its name or Hipparcos catalogue number.

        Args:
            ref: Either the string common name, or the int catalogue number, e.g. 87937 for
                Barnard's Star.
            culture: If given, use as a hint to understand the common name.
        """
        number = ref if isinstance(ref, int) else self.starNumber(ref)
        data = self._stars.loc[number]
        names = self._starNames.allNames(number)
        primaryName = (ref if isinstance(ref, str) else names["western"]
                       if "western" in names else names["hip"])
        star = Star.from_dataframe(data)
        return makeObject(
            type=ObjectType.STAR,
            name=primaryName,
            position=star,
            dataFrame=data,
            names=names,
        )
Example #3
0
    def get_body(self, name: str):
        name = name.lower()

        if name == MERCURY.name:
            return self.ephemeris["MERCURY BARYCENTER"]
        if name == VENUS.name:
            return self.ephemeris["VENUS BARYCENTER"]
        if name == EARTH:
            return self.ephemeris["EARTH"]
        if name == MARS.name:
            return self.ephemeris["MARS BARYCENTER"]
        if name == SATURN.name:
            return self.ephemeris["SATURN BARYCENTER"]
        if name == JUPITER.name:
            return self.ephemeris["JUPITER BARYCENTER"]
        if name == MOON:
            return self.ephemeris["MOON"]
        if name == SUN:
            return self.ephemeris["SUN"]

        if name == ALCYONE:
            return Star.from_dataframe(self.stars.loc[17702])
        if name == ANTARES:
            return Star.from_dataframe(self.stars.loc[80763])
        if name == BETA_CAPRICORNI:
            return Star.from_dataframe(self.stars.loc[100345])
        if name == BETA_GEMINORUM:
            return Star.from_dataframe(self.stars.loc[37826])
        if name == BETA_LIBRAE:
            return Star.from_dataframe(self.stars.loc[74785])
        if name == BETA_VIRGINIS:
            return Star.from_dataframe(self.stars.loc[57757])
        if name == EPSILON_LEONIS:
            return Star.from_dataframe(self.stars.loc[47908])
        if name == EPSILON_PISCIUM:
            return Star.from_dataframe(self.stars.loc[4906])
        if name == FORTY_TWO_CANCRI:
            return Star.from_dataframe(self.stars.loc[42578])
        if name == REGULUS:
            return Star.from_dataframe(self.stars.loc[49669])
        if name == THETA_LEONIS:
            return Star.from_dataframe(self.stars.loc[54879])
        if name == SHERATAN:
            return Star.from_dataframe(self.stars.loc[8903])

        if name == NU_ARIETIS:
            return Star.from_dataframe(self.stars.loc[12332])
        if name == NU_AURIGAE:
            return Star.from_dataframe(self.stars.loc[27673])
        if name == THETA_CANCRI:
            return Star.from_dataframe(self.stars.loc[41822])
        if name == ETA_CAPRICORNI:
            return Star.from_dataframe(self.stars.loc[104019])
        if name == OMEGA_GEMINORUM:
            return Star.from_dataframe(self.stars.loc[33927])
        if name == FIFTY_TWO_LEONIS:
            return Star.from_dataframe(self.stars.loc[52689])
        if name == NU_LIBRAE:
            return Star.from_dataframe(self.stars.loc[73945])
        if name == THIRTY_SIX_PERSEI:
            return Star.from_dataframe(self.stars.loc[16499])
        if name == FIFTY_EIGHT_PISCIUM:
            return Star.from_dataframe(self.stars.loc[3675])
        if name == ASCELLA:
            return Star.from_dataframe(self.stars.loc[93506])
        if name == EPSILON_TAURI:
            return Star.from_dataframe(self.stars.loc[20889])
        if name == THETA_VIRGINIS:
            return Star.from_dataframe(self.stars.loc[64238])

        raise ValueError