pysmo.tools.azdist
Distance and azimuth calculations between Location points.
distance,
azimuth, and
backazimuth use pyproj.Geod on a
reference ellipsoid. haversine uses the
haversine formula on a spherical Earth, the conventional model for
seismological epicentral distance.
Functions:
| Name | Description |
|---|---|
azimuth |
Calculate the azimuth between two locations. |
backazimuth |
Calculate the backazimuth between two locations. |
distance |
Calculate the great-circle distance in metres between two locations. |
haversine |
Calculate the great-circle distance in degrees between two locations. |
DEFAULT_ELLPS
module-attribute
Default reference ellipsoid for distance and azimuth calculations.
azimuth
azimuth(
location_1: Location,
location_2: Location,
ellps: str = DEFAULT_ELLPS,
) -> float
Calculate the azimuth between two locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location_1
|
Location
|
Origin location. |
required |
location_2
|
Location
|
Target location. |
required |
ellps
|
str
|
Ellipsoid to use for the calculation. |
DEFAULT_ELLPS
|
Returns:
| Type | Description |
|---|---|
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)
332.23754
>>> # Use Clarke 1966 instead of default
>>> azimuth(sac.event, sac.station, ellps='clrk66')
332.23615
>>>
Source code in src/pysmo/tools/azdist.py
backazimuth
backazimuth(
location_1: Location,
location_2: Location,
ellps: str = DEFAULT_ELLPS,
) -> float
Calculate the backazimuth between two locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location_1
|
Location
|
Origin location. |
required |
location_2
|
Location
|
Target location. |
required |
ellps
|
str
|
Ellipsoid to use for the calculation. |
DEFAULT_ELLPS
|
Returns:
| Type | Description |
|---|---|
float
|
Backazimuth in degrees from location 2 to location 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)
152.67366
>>> # Use Clarke 1966 instead of default
>>> backazimuth(sac.event, sac.station, ellps='clrk66')
152.672271
>>>
Source code in src/pysmo/tools/azdist.py
distance
distance(
location_1: Location,
location_2: Location,
ellps: str = DEFAULT_ELLPS,
) -> float
Calculate the great-circle distance in metres between two locations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location_1
|
Location
|
Origin location. |
required |
location_2
|
Location
|
Target location. |
required |
ellps
|
str
|
Ellipsoid to use for the calculation. |
DEFAULT_ELLPS
|
Returns:
| Type | Description |
|---|---|
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)
8603325.124
>>> # Use Clarke 1966 instead of default
>>> distance(sac.event, sac.station, ellps='clrk66')
8602982.024
>>>
Source code in src/pysmo/tools/azdist.py
haversine
Calculate the great-circle distance in degrees between two locations.
Uses the haversine formula on a spherical Earth, the conventional model for seismological epicentral distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location_1
|
Location
|
Origin location. |
required |
location_2
|
Location
|
Target location. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Epicentral distance in degrees. |
Examples:
>>> from pysmo.classes import SAC
>>> from pysmo.tools.azdist import haversine
>>> sac = SAC.from_file("example.sac")
>>> # the SAC class provides both event and station
>>> haversine(sac.event, sac.station)
77.638354
>>> # compare with the SAC gcarc header (spherical law of cosines)
>>> float(sac.native.gcarc)
77.638354
>>>