Skip to content

pysmo.tools.azdist #

Common distance and azimuth calculations using pyproj.Geod.

Functions:

  • azimuth

    Calculate azimuth between two points.

  • backazimuth

    Calculate backazimuth (in DEG) between two points.

  • distance

    Calculate the great circle distance (in metres) between two locations.

DEFAULT_ELLPS module-attribute #

DEFAULT_ELLPS = 'WGS84'

Default model for distance and azimuth calculations.

azimuth #

azimuth(
    location_1: Location,
    location_2: Location,
    ellps: str = DEFAULT_ELLPS,
) -> float

Calculate azimuth between two points.

Parameters:

  • location_1 (Location) –

    Name of the event object providing coordinates of the origin location.

  • location_2 (Location) –

    Name of the station object providing coordinates of the target location.

  • ellps (str, default: DEFAULT_ELLPS ) –

    Ellipsoid to use for azimuth calculation

Returns:

  • float

    Azimuth in degrees from location 1 to location 2.

Examples:

>>> from pysmo.classes import SAC
>>> from pysmo.tools.azdist import azimuth
>>> sac = SAC.from_file("example.sac")
>>> # the SAC class provides both event and station
>>> azimuth(sac.event, sac.station)
181.91993
>>> # Use Clarke 1966 instead of default
>>> azimuth(sac.event, sac.station, ellps='clrk66')
181.92002
>>>
Source code in pysmo/tools/azdist.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def azimuth(
    location_1: Location, location_2: Location, ellps: str = DEFAULT_ELLPS
) -> float:
    """Calculate azimuth between two points.


    Parameters:
        location_1: Name of the event object providing coordinates of the origin location.
        location_2: Name of the station object providing coordinates of the target location.
        ellps: Ellipsoid to use for azimuth calculation

    Returns:
        Azimuth in degrees from location 1 to location 2.

    Examples:
        ```python
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import azimuth
        >>> sac = SAC.from_file("example.sac")
        >>> # the SAC class provides both event and station
        >>> azimuth(sac.event, sac.station)
        181.91993
        >>> # Use Clarke 1966 instead of default
        >>> azimuth(sac.event, sac.station, ellps='clrk66')
        181.92002
        >>>
        ```
    """
    return _azdist(location_1=location_1, location_2=location_2, ellps=ellps)[0]

backazimuth #

backazimuth(
    location_1: Location,
    location_2: Location,
    ellps: str = DEFAULT_ELLPS,
) -> float

Calculate backazimuth (in DEG) between two points.

Parameters:

  • location_1 (Location) –

    Name of the event object providing coordinates of the origin location.

  • location_2 (Location) –

    Name of the station object providing coordinates of the target location.

  • ellps (str, default: DEFAULT_ELLPS ) –

    Ellipsoid to use for azimuth calculation

Returns:

  • float

    Backzimuth in degrees from point 2 to point 1

Examples:

>>> from pysmo.classes import SAC
>>> from pysmo.tools.azdist import backazimuth
>>> sac = SAC.from_file("example.sac")
>>> # the SAC class provides both event and station
>>> backazimuth(sac.event, sac.station)
2.467753
>>> # Use Clarke 1966 instead of default
>>> backazimuth(sac.event, sac.station, ellps='clrk66')
2.467847
>>>
Source code in pysmo/tools/azdist.py
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def backazimuth(
    location_1: Location, location_2: Location, ellps: str = DEFAULT_ELLPS
) -> float:
    """Calculate backazimuth (in DEG) between two points.

    Parameters:
        location_1: Name of the event object providing coordinates of the origin location.
        location_2: Name of the station object providing coordinates of the target location.
        ellps: Ellipsoid to use for azimuth calculation

    Returns:
        Backzimuth in degrees from point 2 to point 1

    Examples:
        ```python
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import backazimuth
        >>> sac = SAC.from_file("example.sac")
        >>> # the SAC class provides both event and station
        >>> backazimuth(sac.event, sac.station)
        2.467753
        >>> # Use Clarke 1966 instead of default
        >>> backazimuth(sac.event, sac.station, ellps='clrk66')
        2.467847
        >>>
        ```
    """
    return _azdist(location_1=location_1, location_2=location_2, ellps=ellps)[1]

distance #

distance(
    location_1: Location,
    location_2: Location,
    ellps: str = DEFAULT_ELLPS,
) -> float

Calculate the great circle distance (in metres) between two locations.

Parameters:

  • location_1 (Location) –

    Name of the event object providing coordinates of the origin location.

  • location_2 (Location) –

    Name of the station object providing coordinates of the target location.

  • ellps (str, default: DEFAULT_ELLPS ) –

    Ellipsoid to use for distance calculation

Returns:

  • float

    Great Circle Distance in metres.

Examples:

>>> from pysmo.classes import SAC
>>> from pysmo.tools.azdist import distance
>>> sac = SAC.from_file("example.sac")
>>> # the SAC class provides both event and station
>>> distance(sac.event, sac.station)
1889154.994
>>> # Use Clarke 1966 instead of default
>>> distance(sac.event, sac.station, ellps='clrk66')
1889121.778
>>>
Source code in pysmo/tools/azdist.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
def distance(
    location_1: Location, location_2: Location, ellps: str = DEFAULT_ELLPS
) -> float:
    """Calculate the great circle distance (in metres) between two locations.

    Parameters:
        location_1: Name of the event object providing coordinates of the origin location.
        location_2: Name of the station object providing coordinates of the target location.
        ellps: Ellipsoid to use for distance calculation

    Returns:
        Great Circle Distance in metres.

    Examples:
        ```python
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import distance
        >>> sac = SAC.from_file("example.sac")
        >>> # the SAC class provides both event and station
        >>> distance(sac.event, sac.station)
        1889154.994
        >>> # Use Clarke 1966 instead of default
        >>> distance(sac.event, sac.station, ellps='clrk66')
        1889121.778
        >>>
        ```
    """
    return _azdist(location_1=location_1, location_2=location_2, ellps=ellps)[2]