References¶
richter.link¶
SeedLink and ArcLink client wrapper.
-
class
richter.link.ArcLinkClient(**kwargs)¶ Warning
This class is deprecated and will be removed in future.
ArcLink client wrapper.
This client wrap arclink_fetch command to request time window-based data over ArcLink. It supports single station or multi-stations request.
Note that arclink_fetch only run on Python 2.x. This client use default Python 2.x executable at /usr/bin/python to run arclink_fetch command. See arclink_fetch documentation at the following link: https://www.seiscomp3.org/doc/applications/arclink_fetch.html
-
clear_request()¶ Clear all ArcLink request data.
-
execute(**kwargs)¶ Execute ArcLink request.
-
request(**kwargs)¶ Prepare ArcLink single station request.
-
request_many(stream_list=None, **kwargs)¶ Prepare ArcLink many station request.
-
-
exception
richter.link.LinkError¶ Base link client wrapper error exception.
-
class
richter.link.SeedLinkClient(**kwargs)¶ Warning
This class is deprecated and will be removed in future.
SeedLink client wrapper.
This client is not intended to record data by realtime, but to request time window-based data over SeedLink. If you intend to record realtime data over SeedLink, probably you want to use executable slinktool directly. This client only wrap minimal options of slinktool program. See slinktool documentation at the following link: https://www.seiscomp3.org/doc/applications/slinktool.html
-
clear_request()¶ Clear all SeedLink request data.
-
execute(**kwargs)¶ Execute SeedLink request.
-
request(**kwargs)¶ Prepare SeedLink single station request.
-
request_many(stream_list=None, **kwargs)¶ Prepare SeedLink many stations request.
-
-
richter.link.build_request_file(starttime, endtime, network, station, channel, location='00', request_file=None, mode='a')¶ Build ArcLink request file.
The request file format has the following format:
YYYY,MM,DD,HH,MM,SS YYYY,MM,DD,HH,MM,SS Network Station Channel [Location]
the Channel, Station and Location, can contains wildcards (*) and the Location field is optional although we explicitly define it in the request file. For matching all locations you can use the ‘*’ symbol, if empty it assumes that only empty locations are being requested.
Example:
2010,02,18,12,00,00 2010,02,18,12,10,00 GE WLF BH* 2010,02,18,12,00,00 2010,02,18,12,10,00 GE VSU BH* 00
Note that starttime and endtime for request are in UTC timezone. For more information, see the following ArcLink CLI client documentation at https://www.seiscomp3.org/doc/jakarta/current/apps/arclink_fetch.html.
-
richter.link.stream_manager(**kwargs)¶ Warning
This function is deprecated and will be removed in future releases.
Context manager of ArcLinkClient class.
It yields stream file path if request succeed, and remove request file and stream file on exit.
Example:
from obspy import read from richter import stream_manager with stream_manager(address='192.168.0.25:18001', starttime='2019-01-01 00:00:00', endtime='2019-01-01 01:00:00', network='VG', station='MEPAS', channel='HHZ') as stream_file: stream = read(stream_file) # Then, do something with stream.
richter.ml¶
Utility module for computing Richter magnitude scales, i.e. ML or local magnitude on BPPTKG seismic network.
-
richter.ml.compute_analog_ml(p2p_amplitude)¶ Compute Richter magnitude scales from seismic analog peak-to-peak amplitude.
The peak-to-peak value must be obtained from DEL (Deles) analog station and in mm unit.
Parameters: p2p_amplitude (float) – Peak-to-peak amplitude in mm unit. Returns: BPPTKG Richter magnitude scale. Return type: float Example:
from richter import compute_analog_ml p2p_amplitude = 50 ml = compute_analog_ml(p2p_amplitude) print(ml)
-
richter.ml.compute_app(stream, station, network='VG', component='Z', **kwargs)¶ Compute stream amplitude peak to peak.
Parameters: - stream (
obspy.core.stream.Stream) – ObsPy waveform stream object. - station (str) – Seismic station name, e.g. MEPAS, MEGRA, etc.
- network (str) – Seismic network name, default to VG.
- component (str) – Seismic station component, e.g E, N, Z, default to Z.
Returns: Stream amplitude peak to peak.
Return type: int
Example:
from richter import compute_app from obspy import stream stream = read('/path/to/stream.msd') app = compute_app(stream, 'MEPAS', component='Z') print(app)
- stream (
-
richter.ml.compute_bpptkg_ml(wa_ampl)¶ Compute BPPTKG Richter magnitude scales using Wood-Anderson amplitude.
Note that Wood Anderson zero to peak amplitude (wa_ampl) is in mm. Calibration function log10(A0) for BPPTKG seismic network is -1.4.
Parameters: wa_ampl (float) – Wood-Anderson zero to peak amplitude in mili-meter. Returns: BPPTKG Richter magnitude scale. Return type: float Richter magnitude scale is computed using the following equation:
ml = log10(wa_ampl) - log10(A0)
where log10(A0) equal to -1.4 and ml is Richter local magnitude scale.
Example:
from richter import compute_bpptkg_ml # Wood Anderson zero to peak amplitude in mm wa_ampl = 5 ml = compute_bpptkg_ml(wa_ampl) print(ml)
-
richter.ml.compute_ml(stream, station, network='VG', component='Z', **kwargs)¶ Compute Richter magnitude scales.
Parameters: - stream (
obspy.core.stream.Stream) – ObsPy waveform stream object. - station (str) – Seismic station name, e.g. MEPAS, MEGRA, etc.
- network (str) – Seismic network name, default to VG.
- component (str) – Seismic station component, e.g E, N, Z, default to Z.
Returns: BPPTKG Richter magnitude scale.
Return type: float
Example:
from richter import compute_ml from obspy import read stream = read('/path/to/stream.msd') ml = compute_ml(stream, 'MEPAS', component='Z') print(ml)
- stream (
-
richter.ml.compute_seismic_energy(m)¶ Compute seismic energy using Gutenberg-Richter equation.
\[log E = 11.8 + 1.5M\]where \(M\) is Richter local magnitude and \(E\) is energy in ergs.
Parameters: m (float) – Richter local magnitude. Returns: Seismic energy in factor of \(10^{12}\) ergs. Return type: float Example:
from richter import compute_seismic_energy ml = 1.5 energy = compute_seismic_energy(ml) print(energy)
-
richter.ml.compute_seismic_energy_from_stream(stream, station, network='VG', component='Z', **kwargs)¶ Compute seismic energy using Gutenberg-Richter equation using stream as input.
Seismic energy is computed using the following equation:
\[log E = 11.8 + 1.5M\]where \(M\) is Richter local magnitude and \(E\) is energy in ergs.
Parameters: - stream (
obspy.core.stream.Stream) – ObsPy waveform stream object. - station (str) – Seismic station name, e.g. MEPAS, MEGRA, etc.
- network (str) – Seismic network name, default to VG.
- component (str) – Seismic station component, e.g E, N, Z, default to Z.
Returns: Seismic energy in factor of \(10^{12}\) ergs.
Return type: float
Example:
from richter import compute_seismic_energy_from_stream from obspy import read stream = read('/path/to/stream.msd') energy = compute_energy_from_stream(stream, 'MEPAS', component='Z') print(energy)
- stream (
-
richter.ml.compute_wa(stream, station, network='VG', component='Z', **kwargs)¶ Compute stream Wood-Anderson amplitude in meter.
Parameters: - stream (
obspy.core.stream.Stream) – ObsPy waveform stream object. - station (str) – Seismic station name, e.g. MEPAS, MEGRA, etc.
- network (str) – Seismic network name, default to VG.
- component (str) – Seismic station component, e.g E, N, Z, default to Z.
Returns: Wood-Anderson zero to peak amplitude in meter.
Return type: float
Exampe:
from richter import compute_wa from obspy import read stream = read('/path/to/stream.msd') wa_ampl = compute_wa(stream, 'MEPAS', component='Z') print(wa_ampl)
- stream (
-
richter.ml.filter_stream(stream, **kwargs)¶ Filter ObsPy stream object.
Parameters: stream ( obspy.core.stream.Stream) – ObsPy waveform stream object.Example:
from richter import filter_stream from obspy import read stream = read('/path/to/stream.msd') print(stream) filtered_stream = filter_stream( stream, network='VG', station='MEPAS', component='Z') print(filtered_stream)
richter.paz¶
List poles and zeros constants of BPPTKG seismic stations.
-
richter.paz.get_paz(station, component=None)¶ Get PAZ response for certain station and component. If component is None, it returns PAZ info for all components. Otherwise, it returns info for specific component.
Example:
from richter import paz paz_info = paz.get_paz('MEPAS', component='Z') print(paz_info)
richter.utils¶
Package utility module.
-
richter.utils.find_executable(executable, path=None)¶ Find full path executable command.
-
richter.utils.generate_safe_random_filename(extension='txt')¶ Generate safe random filename based on UUID4.
-
richter.utils.stringify_parameters(items)¶ Convert all items in list to string.
-
richter.utils.to_pydatetime(*args, **kwargs)¶ Convert date string to Python datetime.