Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
the moon illumination for those times.
"""
if not hasattr(observer, '_moon_cache'):
observer._moon_cache = {}
# convert times to tuple for hashing
aakey = _make_cache_key(times, 'moon')
if aakey not in observer._moon_cache:
try:
if force_zero_pressure:
observer_old_pressure = observer.pressure
observer.pressure = 0
altaz = observer.moon_altaz(times)
illumination = np.array(moon_illumination(times))
observer._moon_cache[aakey] = dict(times=times,
illum=illumination,
altaz=altaz)
finally:
if force_zero_pressure:
observer.pressure = observer_old_pressure
return observer._moon_cache[aakey]
Examples
--------
How much of the lunar surface is illuminated at 2015-08-29 18:35 UTC,
which we happen to know is the time of a full moon?
>>> from astroplan import Observer
>>> from astropy.time import Time
>>> apo = Observer.at_site("APO")
>>> time = Time("2015-08-29 18:35")
>>> apo.moon_illumination(time) # doctest: +SKIP
array([ 0.99972487])
"""
if not isinstance(time, Time):
time = Time(time)
return moon_illumination(time)
def get_moon_illumination(self) -> float:
"""
Calculates the illumination of the moon based on the positions of the
moon and the sun on the sky.
Returns:
A float percentage value between 0 and 100.
"""
astropytime = Time(self.datetime)
illumination = astroplan.moon.moon_illumination(astropytime)
return illumination*100.