Exemple #1
0
def main(args):
    if len(args) == 1:
        time = Time.Now()
    elif len(args) == 2:
        time = Time.Parse(args[1])
    else:
        print('USAGE: {} [yyyy-mm-ddThh:mm:ssZ]'.format(args[0]))
        return 1

    # Get the Moon phase at the starting time, so we know what
    # multiple of 12 degrees to search for next.
    phase = MoonPhase(time)
    print("{} : Moon's phase angle = {:0.6f} degrees.".format(time, phase))
    print()
    print('The next 30 lunar days are:')

    target = 12.0 * math.ceil(phase / 12.0)
    for _ in range(30):
        time = SearchMoonPhase(target, time, 2.0)
        if time is None:
            print('SEARCH FAILURE.')
            return 0
        d = 1 + int(target / 12)
        print('{} : Lunar Day {}'.format(time, d))
        target = math.fmod(target + 12.0, 360.0)
    return 0
Exemple #2
0
def main(args):
    if len(args) == 1:
        time = Time.Now()
    elif len(args) == 2:
        time = Time.Parse(args[1])
    else:
        print('USAGE: {} [yyyy-mm-ddThh:mm:ssZ]'.format(args[0]))
        return 1

    count = 0
    e = SearchLunarEclipse(time)
    while count < 10:
        if e.kind != EclipseKind.Penumbral:
            count += 1
            PrintEclipse(e)
        e = NextLunarEclipse(e.peak)
Exemple #3
0
def GraphPairLongitude(body1, body2, t1, t2, npoints):
    xlist = []
    ylist = []
    for i in range(npoints + 1):
        ut = t1.ut + ((i / npoints) * (t2.ut - t1.ut))
        time = Time(ut)
        lon = PairLongitude(body1, body2, time)
        xlist.append(ut)
        ylist.append(lon)
    plt.plot(xlist, ylist, 'b.')
    plt.show()
    plt.close('all')
            tx, cx = FindConstellationChange(body, c1, t1, t2)
            print('{} : {} leaves {} and enters {}.'.format(
                tx, body.name, c1.name, cx.name))
            c1 = cx
            t1 = tx
        else:
            # No constellation change in this time step. Try again on the next time step.
            c1 = c2
            t1 = t2


#------------------------------------------------------------------------------

if __name__ == '__main__':
    if len(sys.argv) == 1:
        startTime = Time.Now()
    elif len(sys.argv) == 2:
        startTime = Time.Parse(sys.argv[1])
    else:
        print('USAGE: {} [yyyy-mm-ddThh:mm:ssZ]'.format(sys.argv[0]))
        sys.exit(1)
    stopTime = startTime.AddDays(30.0)
    # There are 12 zodiac constellations, and the moon takes
    # about 27.3 days in its sidereal period. Therefore, there
    # are roughly 2.2 days per constellation. We will sample
    # the Moon's constellation once every 0.1 days to reduce
    # the chance of missing a brief transition through a small
    # part of a constellation.
    dayIncrement = 0.1
    rc = FindConstellationChanges(Body.Moon, startTime, stopTime, dayIncrement)
    sys.exit(rc)
Exemple #5
0
def GraphPairLongitude(body1, body2, t1, t2, npoints):
    xlist = []
    ylist = []
    for i in range(npoints + 1):
        ut = t1.ut + ((i / npoints) * (t2.ut - t1.ut))
        time = Time(ut)
        lon = PairLongitude(body1, body2, time)
        xlist.append(ut)
        ylist.append(lon)
    plt.plot(xlist, ylist, 'b.')
    plt.show()
    plt.close('all')


if __name__ == '__main__':
    if not (5 <= len(sys.argv) <= 6):
        print(
            'USAGE:  pairlon.py body1 body2 yyyy-mm-ddThh:mm:ssZ yyyy-mm-ddThh:mm:ssZ [npoints]'
        )
        sys.exit(1)
    body1 = Body[sys.argv[1]]
    body2 = Body[sys.argv[2]]
    time1 = Time.Parse(sys.argv[3])
    time2 = Time.Parse(sys.argv[4])
    if len(sys.argv) > 5:
        npoints = int(sys.argv[5])
    else:
        npoints = 1200
    GraphPairLongitude(body1, body2, time1, time2, npoints)
    sys.exit(0)
#   the Earth from the Jupiter system.
#
import sys
from astronomy import Time, JupiterMoons, GeoVector, EquatorFromVector, Body, C_AUDAY

def PrintBody(name, geovec):
    # Convert the geocentric vector into equatorial coordinates.
    equ = EquatorFromVector(geovec)
    print('{:<8s}   RA {:10.6f}   DEC {:10.6f}  {:10.6f} AU'.format(name, equ.ra, equ.dec, equ.dist))


if __name__ == '__main__':
    # If date/time is provided on the command line, use it.
    # Otherwise, use the current date and time.
    if len(sys.argv) == 2:
        time = Time.Parse(sys.argv[1])
    else:
        time = Time.Now()
    print('Calculations for:', time)

    # Call GeoVector to calculate the geocentric position of Jupiter.
    # GeoVector corrects for light travel time.
    # That means it returns a vector to where Jupiter appears to be
    # in the sky, when the light left Jupiter to travel toward the
    # Earth to arrive here at the specified time. This is different from
    # where Jupiter is at that time.

    jv = GeoVector(Body.Jupiter, time, True)

    # Calculate the amount of time it took light to reach the Earth from Jupiter.
    # The distance to Jupiter (AU) divided by the speed of light (AU/day) = time in days.
def PrintRot(rot):
    for i in range(3):
        print('{:20.16f} {:20.16f} {:20.16f}'.format(rot.rot[i][0], rot.rot[i][1], rot.rot[i][2]))

if __name__ == '__main__':
    # This program is a sanity check that I understand galactic coordinates.
    # Compute the GAL/EQJ rotation matrix from
    # the original paper at:
    # https://watermark.silverchair.com/mnras121-0123.pdf?token=AQECAHi208BE49Ooan9kkhW_Ercy7Dm3ZL_9Cf3qfKAc485ysgAAAqowggKmBgkqhkiG9w0BBwagggKXMIICkwIBADCCAowGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM-h6li-3fYbw16GYKAgEQgIICXRrk54M4D9ltWJzbTRkLJ4Hb3fA4I1rbZZY7AWQlxDU7rZapZ0X7GfQWFlpffxZ-n1MULG121w6MHMZZuugksNGCqhU_8tBrNh3J1WDdLT0kig__6h72D-2ceJwydiARM-6bYd6S-z_CqScXBH6QsU8LflzPnpLz7OtfgEQQVN28ePPO2Box00NC5Sthh0Ouv06e-CyRb3ig2xP-WWP2QeGElCxJicnaDew8BUyofEHKpebe3d-Io_gXZeV7NHV1gIDTXLEp0UpM_KB9nmh39pCr4AW9zd-0j5qUlkC3TqNRlt40WuwDJn-cxFpY4O3hPtBvPmUKqspvtRP6YiqXeuCbQ6uw4OG9xcf7G39D387TeSjgGoeZRPkc0ZhpryawudLiHpXualt_uw8ws8--tAO5aUWVGL_oM2jzLEl7WVvS8jbYxXFY6GRPNBGZeDpYCP0hfXgogG305sLSWYtejlBdYECf1oJ1h_jC7HHfxI2xykD7EwI5tlRPKmNKcADJWS8Wf8zbwIE50ZB-eV1miTpBEFa6KnpD-m34k4-6dNOX9k0ALSMPOOag3o3-RGoeLdMrvqFtENM84Blo-OOADNMU5Mmo2UCjl83onZ83TdlJvSy-e2Z49i1vLScvFZlePdwJArcitb44dR1xfsbsLIR7ApcDCuF_ke96Sc3FkOOkFqM1waQZP2zuiyOr4Jg_6IFyLV5aO-2ocGoY4UkED5RzeNVSIiVC3r2QyhG51lD90ABO7LQ7RWXnsZV915Bkohh5fKIjvNM0ejAm87uMzsYhlzIIind9U6DqnCde

    # Equatorial B1950.0 coordinates of the Galactic North Pole:
    ra = 12.0 + 49.0/60.0
    dec = +27.4

    # Orientation angle for the zero lon/lat point in galactic coordinates:
    theta = 123.0

    # Calculate the B1950.0 epoch based on:
    # https://en.wikipedia.org/wiki/Epoch_(astronomy)
    b1950 = Time.FromTerrestrialTime(2433282.4235 - 2451545.0)
    print('B1950 = {}'.format(b1950))

    # Create a rotation matrix to convert from J2000 equatorial to B1950 equatorial.
    rot = Rotation_EQJ_EQD(b1950)

    # Pivot using the ra/dec angles for the galactic north pole.
    rot = Pivot(rot, 2, -15*ra)
    rot = Pivot(rot, 1, -(90-dec))
    rot = Pivot(rot, 2, theta-180)
    PrintRot(rot)