Skip to content

pysmo.tools.azdist #

Common distance and azimuth calculations.

Info

For more information see: https://pyproj4.github.io/pyproj/stable

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
>>> sacobj = SAC.from_file('testfile.sac')
>>> # the SAC class provides both event and station
>>> azimuth(sacobj.event, sacobj.station)
181.9199258637492
>>> # Use Clarke 1966 instead of default
>>> azimuth(sacobj.event, sacobj.station, ellps='clrk66')
181.92001941872516
Source code in pysmo/tools/azdist.py
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
72
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:
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import azimuth
        >>> sacobj = SAC.from_file('testfile.sac')
        >>> # the SAC class provides both event and station
        >>> azimuth(sacobj.event, sacobj.station)
        181.9199258637492
        >>> # Use Clarke 1966 instead of default
        >>> azimuth(sacobj.event, sacobj.station, ellps='clrk66')
        181.92001941872516
    """
    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
>>> sacobj = SAC.from_file('testfile.sac')
>>> # the SAC class provides both event and station
>>> backazimuth(sacobj.event, sacobj.station)
2.4677533885335947
>>> # Use Clarke 1966 instead of default
>>> backazimuth(sacobj.event, sacobj.station, ellps='clrk66')
2.467847115319614
Source code in pysmo/tools/azdist.py
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
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:
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import backazimuth
        >>> sacobj = SAC.from_file('testfile.sac')
        >>> # the SAC class provides both event and station
        >>> backazimuth(sacobj.event, sacobj.station)
        2.4677533885335947
        >>> # Use Clarke 1966 instead of default
        >>> backazimuth(sacobj.event, sacobj.station, ellps='clrk66')
        2.467847115319614
    """
    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
>>> sacobj = SAC.from_file('testfile.sac')
>>> # the SAC class provides both event and station
>>> distance(sacobj.event, sacobj.station)
1889154.9940066522
>>> # Use Clarke 1966 instead of default
>>> distance(sacobj.event, sacobj.station, ellps='clrk66')
1889121.778136402
Source code in pysmo/tools/azdist.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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:
        >>> from pysmo.classes import SAC
        >>> from pysmo.tools.azdist import distance
        >>> sacobj = SAC.from_file('testfile.sac')
        >>> # the SAC class provides both event and station
        >>> distance(sacobj.event, sacobj.station)
        1889154.9940066522
        >>> # Use Clarke 1966 instead of default
        >>> distance(sacobj.event, sacobj.station, ellps='clrk66')
        1889121.778136402
    """
    return _azdist(location_1=location_1, location_2=location_2, ellps=ellps)[2]