How to use the astroplan.moon.moon_illumination function in astroplan

To help you get started, we’ve selected a few astroplan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / astroplan / astroplan / constraints.py View on Github external
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]
github astropy / astroplan / astroplan / observer.py View on Github external
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)
github ojhall94 / stateoftheuniverse / stateoftheuniverse / widgets / moon_phase_widget.py View on Github external
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.