pythonastronomypyephem

.parallactic_angle() method in PyEphem


Changelog for Version 3.7.5.3 (2014 May 29) of PyEphem mentions that all bodies have been given a .parallactic_angle() method but I couldn't find it in quick references or tutorial. What are the argument(s) it need?


Solution

  • # Compute parallactic angle using PyEphem.
    city = ephem.city( ... )
    moon = ephem.moon( city )
    parallacticAngle = moon.parallactic_angle()
    

    The code below is ripped from indicator-lunar and computes the parallactic angle, used to further calculate the bright limb angle.

    # Compute the bright limb angle (relative to zenith) between the sun moon.
    # Measured in degrees counter clockwise from a positive y axis.
    # 'Astronomical Algorithms' Second Edition by Jean Meeus (chapters 14 and 48).
    # 'Practical Astronomy with Your Calculator' by Peter Duffett-Smith (chapters 59 and 68).
    city = ephem.city( ... )
    moon = ephem.moon( city )
    sun = ephem.Sun( city )
    
    y = math.cos( sun.dec ) * math.sin( sun.ra - moon.ra )
    x = math.cos( moon.dec ) * math.sin( sun.dec ) - math.sin( body.dec ) * math.cos( sun.dec ) * math.cos( sun.ra - moon.ra )
    positionAngleOfBrightLimb = math.atan2( y, x )
    
    hourAngle = city.sidereal_time() - moon.ra
    y = math.sin( hourAngle )
    x = math.tan( city.lat ) * math.cos( moon.dec ) - math.sin( moon.dec ) * math.cos( hourAngle )
    parallacticAngle = math.atan2( y, x )
    brightLimbAngle = math.degrees( ( positionAngleOfBrightLimb - parallacticAngle ) % ( 2.0 * math.pi ) )
    

    Comparing my computed value to that of the PyEphem's, they both match (one is a float radians and the other prints as decimal degrees).