Convert azimuth into cardinal point

The cardinal points or cardinal directions are North, East, South, and West.


Get the cardinal point (North, East, South, or West) for a given azimuth.

Here, the azimuth is measured from North to East. N = (315, 45] deg E = (45, 135] deg S = (135, 225] deg W = (225, 315] deg


Azimuth of an object in deg (0-360).

Cardinal pointstring, {N,E,S,W}

Returns the cardinal point (N, E, S, W) corresponding to the given azimuth of the object.


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

# Get the cardinal point for 10 azimuth angles
azimuths = np.random.random(10) * 360.
for azimuth in azimuths:
  cp = pyasl.getCardinalPoint(azimuth)
  print("Azimuth: {0:6.2f} deg, Cardinal point: {1:1s}".format(azimuth, cp))