pysmo
#
Pysmo types and corresponding Mini Classes.
The psymo base namespace exposes the protocol classes that are used as type
hints, as well as reference implementations of a generic class for each
protocol. The reference classes are subclasses of their respective protocol
classes that contain exactly the same attributes (though some extra methods may
be defined for convenience). They can be considered minimal implementations of
a class that can be used with pysmo protocols, and are therefore named "Mini" +
"name of protocol" (e.g. MiniSeismogram is an
implementation of the Seismogram type).
Classes, functions and other tools that make use of pysmo types and mini need to be imported from other modules.
- User guide
Modules:
-
classes–Classes that work with pysmo types.
-
functions–Simple operations using pysmo types.
-
lib–Pysmo library module.
-
tools–Extra tools or topics that use pysmo types.
-
types–Custom types for pysmo.
Classes:
-
Seismogram–Protocol class to define the
Seismogramtype. -
Station–Protocol class to define the
Stationtype. -
Event–Protocol class to define the
Eventtype. -
Location–Protocol class to define the
Locationtype. -
LocationWithDepth–Protocol class to define the
LocationWithDepthtype. -
MiniSeismogram–Minimal class for use with the
Seismogramtype. -
MiniStation–Minimal class for use with the Station type.
-
MiniEvent–Minimal class for use with the
Eventtype. -
MiniLocation–Minimal class for use with the
Locationtype. -
MiniLocationWithDepth–Minimal class for use with the
MiniLocationWithDepthtype.
Seismogram
#
Bases: Protocol
flowchart TD
pysmo.Seismogram[Seismogram]
click pysmo.Seismogram href "" "pysmo.Seismogram"
Protocol class to define the Seismogram type.
Examples:
Usage for a function that takes a Seismogram compatible class instance as argument and returns the begin time in isoformat:
>>> from pysmo import Seismogram
>>> from pysmo.classes import SAC # SAC is a class that "speaks" Seismogram
>>>
>>> def example_function(seis_in: Seismogram) -> str:
... return seis_in.begin_time.isoformat()
...
>>> sac = SAC.from_file("example.sac")
>>> seismogram = sac.seismogram
>>> example_function(seismogram)
'2005-03-01T07:23:02.160000+00:00'
>>>
- API reference
- User guide
-
API reference
pysmo.tools
iccsICCSSeismogram
-
API reference
- pysmo.tools
-
pysmo.functions
functionstime2index -
pysmo.lib
libtyping_AnyProto
Methods:
-
__len__–The length of the Seismogram.
Attributes:
-
data(ndarray) –Seismogram data.
-
begin_time(datetime) –Seismogram begin time.
-
end_time(datetime) –Seismogram end time.
-
delta(timedelta) –The sampling interval.
Source code in src/pysmo/_types/_seismogram.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 72 73 74 | |
Station
#
flowchart TD
pysmo.Station[Station]
pysmo._types._location.Location[Location]
pysmo._types._location.Location --> pysmo.Station
click pysmo.Station href "" "pysmo.Station"
click pysmo._types._location.Location href "" "pysmo._types._location.Location"
Protocol class to define the Station type.
- User guide
-
API reference
pysmo.classes
classes
Attributes:
-
latitude(float) –Latitude in degrees.
-
longitude(float) –Longitude in degrees.
-
name(str) –Station name or identifier.
-
network(str) –Network name or identifier.
-
location(str) –Location ID.
-
channel(str) –Channel code.
-
elevation(float | None) –Station elevation in metres.
Source code in src/pysmo/_types/_station.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 | |
name
property
writable
#
name: str
Station name or identifier.
A 1-5 character identifier for the station recording the data.
-
API reference
pysmo
pysmoMiniStationname
network
property
writable
#
network: str
Network name or identifier.
A 1-2 character code identifying the network/owner of the data.
-
API reference
pysmo
pysmoMiniStationnetwork
location
property
writable
#
location: str
Location ID.
A two character code used to uniquely identify different data streams at a single stationa.
-
API reference
pysmo
pysmoMiniStationlocation
channel
property
writable
#
channel: str
Channel code.
A three character combination used to identify:
- Band and general sample rate.
- Instrument type.
- Orientation of the sensor.
-
API reference
pysmo
pysmoMiniStationchannel
Event
#
Bases: LocationWithDepth, Protocol
flowchart TD
pysmo.Event[Event]
pysmo._types._location_with_depth.LocationWithDepth[LocationWithDepth]
pysmo._types._location.Location[Location]
pysmo._types._location_with_depth.LocationWithDepth --> pysmo.Event
pysmo._types._location.Location --> pysmo._types._location_with_depth.LocationWithDepth
click pysmo.Event href "" "pysmo.Event"
click pysmo._types._location_with_depth.LocationWithDepth href "" "pysmo._types._location_with_depth.LocationWithDepth"
click pysmo._types._location.Location href "" "pysmo._types._location.Location"
Protocol class to define the Event type.
Attributes:
-
latitude(float) –Latitude in degrees.
-
longitude(float) –Longitude in degrees.
-
depth(float) –Location depth in metres.
-
time(datetime) –Event origin time.
Source code in src/pysmo/_types/_event.py
10 11 12 13 14 15 16 17 18 19 20 | |
Location
#
Bases: Protocol
flowchart TD
pysmo.Location[Location]
click pysmo.Location href "" "pysmo.Location"
Protocol class to define the Location type.
- User guide
- API reference
-
API reference
pysmo
pysmo
Attributes:
Source code in src/pysmo/_types/_location.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
LocationWithDepth
#
flowchart TD
pysmo.LocationWithDepth[LocationWithDepth]
pysmo._types._location.Location[Location]
pysmo._types._location.Location --> pysmo.LocationWithDepth
click pysmo.LocationWithDepth href "" "pysmo.LocationWithDepth"
click pysmo._types._location.Location href "" "pysmo._types._location.Location"
Protocol class to define the LocationWithDepth type.
Attributes:
-
latitude(float) –Latitude in degrees.
-
longitude(float) –Longitude in degrees.
-
depth(float) –Location depth in metres.
Source code in src/pysmo/_types/_location_with_depth.py
8 9 10 11 12 13 14 15 16 17 18 | |
MiniSeismogram
#
Minimal class for use with the Seismogram type.
The MiniSeismogram class provides a minimal implementation of class that
is compatible with the Seismogram type.
Examples:
>>> from pysmo import MiniSeismogram, Seismogram
>>> from datetime import datetime, timedelta, timezone
>>> import numpy as np
>>> now = datetime.now(timezone.utc)
>>> delta = timedelta(seconds=0.1)
>>> seismogram = MiniSeismogram(begin_time=now, delta=delta, data=np.random.rand(100))
>>> isinstance(seismogram, Seismogram)
True
>>>
- User guide
-
API reference
-
pysmo.functions
functionsclone_to_mini -
pysmo
pysmo
-
pysmo.functions
- API reference pysmo.tools
Methods:
-
__len__–The length of the Seismogram.
Attributes:
-
begin_time(datetime) –Seismogram begin time.
-
delta(PositiveTimedelta) –Seismogram sampling interval.
-
data(ndarray) –Seismogram data.
-
end_time(datetime) –Seismogram end time.
Source code in src/pysmo/_types/_seismogram.py
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
begin_time
class-attribute
instance-attribute
#
begin_time: datetime = field(
default=begin_time.value, validator=datetime_is_utc
)
delta
class-attribute
instance-attribute
#
delta: PositiveTimedelta = delta.value
Seismogram sampling interval.
data
class-attribute
instance-attribute
#
Seismogram data.
__len__
#
__len__() -> int
The length of the Seismogram.
Returns:
-
int–Number of samples in the data array.
Source code in src/pysmo/_types/_seismogram.py
110 111 112 113 114 115 116 | |
MiniStation
#
Minimal class for use with the Station type.
The MiniStation class provides a minimal implementation of class that
is compatible with the Station type.
Examples:
>>> from pysmo import MiniStation, Station, Location
>>> station = MiniStation(latitude=-21.680301, longitude=-46.732601, name="CACB", network="BL", channel="BHZ", location="00")
>>> isinstance(station, Station)
True
>>> isinstance(station, Location)
True
>>>
Attributes:
-
name(str) –Station name.
-
network(str) –Network name.
-
location(str) –Location ID.
-
channel(str) –Channel code.
-
latitude(float) –Station latitude from -90 to 90 degrees.
-
longitude(float) –Station longitude from -180 to 180 degrees.
-
elevation(float | None) –Station elevation.
Source code in src/pysmo/_types/_station.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 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 127 128 129 130 | |
name
class-attribute
instance-attribute
#
Station name.
See Station.name for more details.
network
class-attribute
instance-attribute
#
Network name.
See Station.network for more details.
location
class-attribute
instance-attribute
#
Location ID.
See Station.location for more details.
channel
class-attribute
instance-attribute
#
Channel code.
See Station.channel for more details.
latitude
class-attribute
instance-attribute
#
Station latitude from -90 to 90 degrees.
longitude
class-attribute
instance-attribute
#
Station longitude from -180 to 180 degrees.
MiniEvent
#
Minimal class for use with the Event type.
The MiniEvent class provides a minimal implementation of class that is
compatible with the Event type.
Examples:
>>> from pysmo import MiniEvent, Event, LocationWithDepth, Location
>>> from datetime import datetime, timezone
>>> now = datetime.now(timezone.utc)
>>> event = MiniEvent(latitude=-24.68, longitude=-26.73, depth=15234.0, time=now)
>>> isinstance(event, Event)
True
>>> isinstance(event, Location)
True
>>> isinstance(event, LocationWithDepth)
True
>>>
Attributes:
-
time(datetime) –Event origin time.
-
latitude(float) –Event atitude from -90 to 90 degrees.
-
longitude(float) –Event longitude from -180 to 180 degrees.
-
depth(float) –Event depth in metres.
Source code in src/pysmo/_types/_event.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
MiniLocation
#
Minimal class for use with the Location type.
The MiniLocation class provides a minimal implementation of class that
is compatible with the Location type.
Examples:
>>> from pysmo import MiniLocation, Location
>>> location = MiniLocation(latitude=41.8781, longitude=-87.6298)
>>> isinstance(location, Location)
True
>>>
- User guide Classes Pysmo Mini classes
Attributes:
-
latitude(float) –Latitude from -90 to 90 degrees.
-
longitude(float) –Longitude from -180 to 180 degrees.
Source code in src/pysmo/_types/_location.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
MiniLocationWithDepth
#
Minimal class for use with the MiniLocationWithDepth type.
The MiniLocationWithDepth class provides a minimal implementation of class that
is compatible with the MiniLocationWithDepth type.
Examples:
>>> from pysmo import MiniLocationWithDepth, LocationWithDepth, Location
>>> hypo = MiniLocationWithDepth(latitude=-24.68, longitude=-26.73, depth=15234.0)
>>> isinstance(hypo, LocationWithDepth)
True
>>> isinstance(hypo, Location)
True
>>>
-
API reference
-
pysmo.lib
libtypingmatching_pysmo_types -
pysmo
pysmo
-
pysmo.lib
Attributes:
-
latitude(float) –Location latitude from -90 to 90 degrees.
-
longitude(float) –Location longitude from -180 to 180 degrees.
-
depth(float) –Location depth in metres.
Source code in src/pysmo/_types/_location_with_depth.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |