def test_earth_apparent_heliocentric_position(): """Tests the apparent_heliocentric_position() method of Earth class""" epoch = Epoch(1992, 10, 13.0) lon, lat, r = Earth.apparent_heliocentric_position(epoch) assert abs(round(lon.to_positive(), 6) - 19.905986) < TOL, \ "ERROR: 1st apparent_heliocentric_position() test doesn't match" assert lat.dms_str(n_dec=3) == "-0.721''", \ "ERROR: 2nd apparent_heliocentric_position() test doesn't match" assert abs(round(r, 8) - 0.99760852) < TOL, \ "ERROR: 3rd apparent_heliocentric_position() test doesn't match"
def apparent_geocentric_position(epoch, nutation=True): """This method computes the apparent geocentric position of the Sun for a given epoch, using the VSOP87 theory. :param epoch: Epoch to compute Sun position, as an Epoch object :type epoch: :py:class:`Epoch` :param nutation: Whether the nutation correction will be applied :type epoch: bool :returns: A tuple with the heliocentric longitude and latitude (as :py:class:`Angle` objects), and the radius vector (as a float, in astronomical units), in that order :rtype: tuple :raises: TypeError if input values are of wrong type. >>> epoch = Epoch(1992, 10, 13.0) >>> lon, lat, r = Sun.apparent_geocentric_position(epoch) >>> print(lon.to_positive().dms_str(n_dec=3)) 199d 54' 21.548'' >>> print(lat.dms_str(n_dec=3)) 0.721'' >>> print(round(r, 8)) 0.99760852 """ # NOTE: In page 169, Meeus gives a different value for the LONGITUDE # (199d 54' 21.818'') as the one presented above (199d 54' 21.548''). # After many checks and tests, I came to the conclusion that the result # above is the right one, and Meeus' result is wrong. # On the other hand, the difference in LATITUDE may be due to the fact # that this software uses the complete set of VSOP87C terms, instead of # the abridged version in Meeus' book. # First check that input values are of correct types if not isinstance(epoch, Epoch): raise TypeError("Invalid input type") # Use Earth heliocentric position to compute Sun's geocentric position lon, lat, r = Earth.apparent_heliocentric_position(epoch, nutation) lon = lon.to_positive() + 180.0 lat = -lat return lon, lat, r