Lunar phase and position¶
- PyAstronomy.pyasl.moonpos(jd, radian=False)¶
Computes RA and DEC of the Moon at given Julian date(s).
- Parameters
- jdfloat or array
The Julian date.
- radianboolean, optional
If True, results are returned in RADIAN instead of DEGREES. Default is False.
- Returns
- RAfloat or array
Right ascension of the moon for given JD(s) in DEGREES.
- DECfloat or array
Declination of the moon for given JD(s) in DEGREES.
- DISTANCEfloat or array
Distance of the moon from the Earth for given JD(s) in KILOMETERS.
- GEOLONGITUDEfloat or array
Apparent longitude of the moon for given JD(s) in DEGREES.
- GEOLATITUDEfloat or array
Apparent latitude of the moon for given JD(s) in DEGREES.
Notes
Note
This function was ported from the IDL Astronomy User’s Library.
- IDL - Documentation
PRO MOONPOS, jd, ra, dec, dis, geolong, geolat, RADIAN = radian
- NAME:
MOONPOS
- PURPOSE:
To compute the RA and Dec of the Moon at specified Julian date(s).
- CALLING SEQUENCE:
MOONPOS, jd, ra, dec, dis, geolong, geolat, [/RADIAN ]
- INPUTS:
JD - Julian ephemeris date, scalar or vector, double precision suggested
- OUTPUTS:
- Ra - Apparent right ascension of the moon in DEGREES, referred to the
true equator of the specified date(s)
Dec - The declination of the moon in DEGREES Dis - The Earth-moon distance in kilometers (between the center of the
Earth and the center of the Moon).
- Geolong - Apparent longitude of the moon in DEGREES, referred to the
ecliptic of the specified date(s)
- Geolat - Apparent longitude of the moon in DEGREES, referred to the
ecliptic of the specified date(s)
The output variables will all have the same number of elements as the input Julian date vector, JD. If JD is a scalar then the output variables will be also.
- OPTIONAL INPUT KEYWORD:
- /RADIAN - If this keyword is set and non-zero, then all output variables
are given in Radians rather than Degrees
- EXAMPLES:
Find the position of the moon on April 12, 1992
IDL> jdcnv,1992,4,12,0,jd ;Get Julian date IDL> moonpos, jd, ra ,dec ;Get RA and Dec of moon IDL> print,adstring(ra,dec,1)
==> 08 58 45.23 +13 46 6.1
This is within 1” from the position given in the Astronomical Almanac
Plot the Earth-moon distance for every day at 0 TD in July, 1996
IDL> jdcnv,1996,7,1,0,jd ;Get Julian date of July 1 IDL> moonpos,jd+dindgen(31), ra, dec, dis ;Position at all 31 days IDL> plot,indgen(31),dis, /YNOZ
- METHOD:
Derived from the Chapront ELP2000/82 Lunar Theory (Chapront-Touze’ and Chapront, 1983, 124, 50), as described by Jean Meeus in Chapter 47 of ``Astronomical Algorithms’’ (Willmann-Bell, Richmond), 2nd edition, 1998. Meeus quotes an approximate accuracy of 10” in longitude and 4” in latitude, but he does not give the time range for this accuracy.
Comparison of this IDL procedure with the example in ``Astronomical Algorithms’’ reveals a very small discrepancy (~1 km) in the distance computation, but no difference in the position calculation.
This procedure underwent a major rewrite in June 1996, and the new calling sequence is incompatible with the old (e.g. angles now returned in degrees instead of radians).
- PROCEDURES CALLED:
CIRRANGE, ISARRAY(), NUTATE, TEN() - from IDL Astronomy Library POLY() - from IDL User’s Library
- MODIFICATION HISTORY:
Written by Michael R. Greason, STX, 31 October 1988. Major rewrite, new (incompatible) calling sequence, much improved
accuracy, W. Landsman Hughes STX June 1996
Added /RADIAN keyword W. Landsman August 1997 Converted to IDL V5.0 W. Landsman September 1997 Use improved expressions for L’,D,M,M’, and F given in 2nd edition of
Meeus (very slight change), W. Landsman November 2000
Avoid 32767 overflow W. Landsman January 2005
Example: Finding the position of the Moon¶
from __future__ import print_function, division
import datetime
from PyAstronomy import pyasl
import numpy as np
# Convert calendar date to JD
# using the datetime package
jd = datetime.datetime(2013, 4, 16)
jd = pyasl.jdcnv(jd)
jd = np.arange(jd, jd + 20, 1)
# Calculate Moon positions
res = pyasl.moonpos(jd)
print("%15s %8s %8s %11s %8s %8s" %
("JD", "RA", "DEC", "DIST", "GEOLON", "GEOLAT"))
print("%15s %8s %8s %11s %8s %8s" %
("[d]", "[deg]", "[deg]", "[km]", "[deg]", "[deg]"))
for i in range(jd.size):
print("%15.4f %8.4f %8.4f %11.4f %8.4f %8.4f" %
(jd[i], res[0][i], res[1][i], res[2][i], res[3][i], res[4][i]))
- PyAstronomy.pyasl.moonphase(jd)¶
Computes the illuminated fraction of the Moon at given Julian date(s).
- Parameters
- jdfloat or array
The Julian date.
- Returns
- Fractionfloat or array
The illuminated fraction [0 - 1] of the Moon. Has the same size as jd.
Notes
Note
This function was ported from the IDL Astronomy User’s Library.
- IDL - Documentation
- NAME:
MPHASE
- PURPOSE:
Return the illuminated fraction of the Moon at given Julian date(s)
- CALLING SEQUENCE:
MPHASE, jd, k
- INPUT:
JD - Julian date, scalar or vector, double precision recommended
- OUTPUT:
- k - illuminated fraction of Moon’s disk (0.0 < k < 1.0), same number
of elements as jd. k = 0 indicates a new moon, while k = 1 for a full moon.
- EXAMPLE:
Plot the illuminated fraction of the moon for every day in July 1996 at 0 TD (~Greenwich noon).
IDL> jdcnv, 1996, 7, 1, 0, jd ;Get Julian date of July 1 IDL> mphase, jd+dindgen(31), k ;Moon phase for all 31 days IDL> plot, indgen(31),k ;Plot phase vs. July day number
Example: Find the Moon’s illuminated fraction¶
from __future__ import print_function, division
import datetime
from PyAstronomy import pyasl
import numpy as np
# Convert calendar date to JD
# using the datetime package
jd = datetime.datetime(2013, 4, 16)
jd = pyasl.jdcnv(jd)
jd = np.arange(jd, jd+20, 1)
mp = pyasl.moonphase(jd)
print("%15s %3s" % ("JD", "Phase"))
for i in range(jd.size):
print("%15.4f %3d%%" % (jd[i], mp[i]*100.))