Name twilight given solar altitude

PyAstronomy.pyasl.twilightName(sunAlt)

Determine the type of twilight for a given altitude of the Sun.

Definitions of twilight:
  • Solar altitude > 0 : day

  • Solar altitude <= 0 : civil twilight

  • Solar altitude <= -6 : nautical twilight

  • Solar altitude <= -12 : astronomical twilight

  • Solar altitude <= -18 : night

Parameters
sunAltfloat

Altitude of the Sun in degrees.

Returns
Twilight flagstring, {“day”, “civil twilight”, “nautical twilight”, “astron. twilight”, “night”}

Specifies the type of twilight corresponding to the given solar altitude.

The twilight flag is either “day”, “civil twilight”, “nautical twilight”, “astron. twilight”, or “night”.

Example

from __future__ import print_function, division
from PyAstronomy import pyasl
import numpy as np

for alt in np.linspace(-20., 5., 15):
  print("Altitude = {0:6.2f}, Twilight is called: ".format(alt), \
        pyasl.twilightName(alt))