File: ellipse.py

package info (click to toggle)
astroml 1.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 932 kB
  • sloc: python: 5,731; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np


def plot_tissot_ellipse(longitude, latitude, radius, ax=None, **kwargs):
    """Plot Tissot Ellipse/Tissot Indicatrix

    Parameters
    ----------
    longitude : float or array_like
        longitude of ellipse centers (radians)
    latitude : float or array_like
        latitude of ellipse centers (radians)
    radius : float or array_like
        radius of ellipses
    ax : Axes object (optional)
        matplotlib axes instance on which to draw ellipses.

    Other Parameters
    ----------------
    other keyword arguments will be passed to matplotlib.patches.Ellipse.
    """
    # Import here so that testing with Agg will work
    from matplotlib import pyplot as plt
    from matplotlib.patches import Ellipse

    if ax is None:
        ax = plt.gca()

    for long, lat, rad in np.broadcast(longitude, latitude, radius):
        el = Ellipse((long, lat), radius / np.cos(lat), radius, **kwargs)
        ax.add_patch(el)