seismic package¶
Subpackages¶
- seismic.ASDFdatabase package
- Submodules
- seismic.ASDFdatabase.ClientUtils module
- seismic.ASDFdatabase.FederatedASDFDataSet module
- seismic.ASDFdatabase.asdf2mseed module
- seismic.ASDFdatabase.asdf_preprocess module
- seismic.ASDFdatabase.create_small_chunks module
- seismic.ASDFdatabase.plot_data_quality module
- seismic.ASDFdatabase.query_input_yes_no module
- seismic.ASDFdatabase.sc3toasdf module
- seismic.ASDFdatabase.seisds module
- seismic.ASDFdatabase.utils module
- Module contents
- seismic.amb_noise package
- seismic.gps_corrections package
- seismic.inventory package
- Subpackages
- Submodules
- seismic.inventory.add_time_corrections module
- seismic.inventory.engd2stxml module
- seismic.inventory.fdsnxml_convert module
- seismic.inventory.generate_network_plots module
- seismic.inventory.inventory_merge module
- seismic.inventory.inventory_split module
- seismic.inventory.inventory_util module
- seismic.inventory.iris_query module
- seismic.inventory.pdconvert module
- seismic.inventory.plotting module
- seismic.inventory.response module
- seismic.inventory.table_format module
- seismic.inventory.update_iris_inventory module
- Module contents
- seismic.inversion package
- Subpackages
- seismic.inversion.mcmc package
- seismic.inversion.wavefield_decomp package
- Submodules
- seismic.inversion.wavefield_decomp.call_count_decorator module
- seismic.inversion.wavefield_decomp.plot_nd_batch module
- seismic.inversion.wavefield_decomp.runners module
- seismic.inversion.wavefield_decomp.solvers module
- seismic.inversion.wavefield_decomp.wavefield_continuation_tao module
- seismic.inversion.wavefield_decomp.wfd_plot module
- Module contents
- Module contents
- Subpackages
- seismic.pick_harvester package
- Submodules
- seismic.pick_harvester.createEnsembleXML module
- seismic.pick_harvester.pick module
- seismic.pick_harvester.quality module
- seismic.pick_harvester.utils module
- Module contents
- seismic.receiver_fn package
- Submodules
- seismic.receiver_fn.bulk_rf_report module
- seismic.receiver_fn.generate_rf module
- seismic.receiver_fn.plot_ccp module
- seismic.receiver_fn.plot_ccp_batch module
- seismic.receiver_fn.plot_spatial_map module
- seismic.receiver_fn.pointsets2grid module
- seismic.receiver_fn.rf_3dmigrate module
- seismic.receiver_fn.rf_deconvolution module
- seismic.receiver_fn.rf_h5_file_event_iterator module
- seismic.receiver_fn.rf_h5_file_station_iterator module
- seismic.receiver_fn.rf_handpick_tool module
- seismic.receiver_fn.rf_inversion_export module
- seismic.receiver_fn.rf_network_dict module
- seismic.receiver_fn.rf_plot_utils module
- seismic.receiver_fn.rf_plot_vespagram module
- seismic.receiver_fn.rf_process_io module
- seismic.receiver_fn.rf_quality_filter module
- seismic.receiver_fn.rf_stacking module
- seismic.receiver_fn.rf_synthetic module
- seismic.receiver_fn.rf_util module
choose_rf_source_channel()
compute_extra_rf_stats()
compute_rf_snr()
compute_vertical_snr()
filter_by_distance()
filter_crosscorr_coeff()
filter_invalid_radial_component()
filter_station_streams()
filter_station_to_mean_signal()
find_rf_group_ids()
label_rf_quality_simple_amplitude()
phase_weights()
read_h5_rf()
rf_to_dict()
signed_nth_power()
signed_nth_root()
trim_hdf_keys()
- Module contents
- seismic.synthetics package
- seismic.traveltime package
- Submodules
- seismic.traveltime.cluster_grid module
- seismic.traveltime.events_stations_rays_visualization2 module
- seismic.traveltime.gather_events module
- seismic.traveltime.mpiops module
- seismic.traveltime.parametrisation module
- seismic.traveltime.parse_param module
- seismic.traveltime.plotviews module
- seismic.traveltime.pslog module
- seismic.traveltime.sort_rays module
- seismic.traveltime.zone_rays module
- Module contents
- seismic.xcorqc package
- Submodules
- seismic.xcorqc.analytic_plot_utils module
- seismic.xcorqc.client_data module
- seismic.xcorqc.correlator module
- seismic.xcorqc.fft module
- seismic.xcorqc.generate_dispersion_curves module
- seismic.xcorqc.generate_test_data module
- seismic.xcorqc.utils module
- seismic.xcorqc.validate_xcorr_setup module
- seismic.xcorqc.xcorqc module
- seismic.xcorqc.xcorr_station_clock_analysis module
- Module contents
Submodules¶
seismic.analyze_station_orientations module¶
seismic.extract_event_traces module¶
seismic.model_properties module¶
Helper classes to encapsulate model properties.
- class seismic.model_properties.LayerProps(vp, vs, rho, thickness)[source]¶
Bases:
object
Helper class to contain layer bulk material properties
Constructor for given properties
- Parameters:
- property H¶
Get layer thickness
- property Vp¶
Get P-wave body wave velocity
- property Vs¶
Get S-wave body wave velocity
- property rho¶
Get bulk material density
seismic.network_event_dataset module¶
Class encapsulating a collection of event waveforms for stations of one network.
- class seismic.network_event_dataset.NetworkEventDataset(stream_src, network=None, station=None, location='', ordering='ZNE', root='/waveforms')[source]¶
Bases:
object
Collection of 3-channel ZNE streams with traces aligned to a fixed time window about seismic P-wave arrival events, for a given network.
Two indexes are provided. One indexes hierarchically by station code and event ID, yielding a 3-channel ZNE stream per event, so that you can easily gather all traces for a given station by iterating over events.
The other index indexes hierarchically by event ID and station code, yielding a 3-channel ZNE stream per station. Using this index you can easily gather all traces for a given event across multiple stations.
Preferably each input trace will already have an ‘event_id’ attribute in its stats. If not, an event ID will be invented based on station identifiers and time window.
Initialize from data source (file or obspy.Stream). Traces are COPIED into the dataset in order to leave input object intact, since many obspy functions mutate traces in-place.
All streams in the input data source stream_src are expected to belong to the same network. This is checked as the data is ingested. A discrepant network code is an error condition.
- Parameters:
stream_src (str, pathlib.Path or obspy.Stream) – Source of input streams. May be a file name or an Obspy Stream
network (str) – Network code of streams to load. If stream_src is an Obspy Stream, the streams will be filtered to match this network code.
station (str) – Station code of streams to load. If stream_src is an Obspy Stream, the streams will be filtered to match this station code.
location (str) – [OPTIONAL] Location code of streams to load. Leave as default (empty string) if location code is empty in the data source.
ordering (str) – Channel ordering to be applied to the data after loading. The channel labelling must be consistent with the requested ordering - rotation to the coordinate system implied by the ordering is NOT applied.
- Raises:
AssertionError – If discrepant network code is found in input data
- apply(_callable)[source]¶
Apply a callable across all streams. Use to apply uniform processing steps to the whole dataset.
- Parameters:
_callable (Any Callable compatible with the call signature.) – Callable object that takes an obspy Stream as input and applies itself to that Stream. Expect that stream may be mutated in-place by the callable.
- Returns:
None
- by_event()[source]¶
Iterate over event sub-dictionaries.
- Returns:
Iterable over the discrete events, each element consisting of pair containing (event id, station dict).
- Return type:
Iterable(tuple)
- by_station()[source]¶
Iterate over station sub-dictionaries.
- Returns:
Iterable over the stations, each element consisting of pair containing (station code, event dict).
- Return type:
Iterable(tuple)
- curate(curator)[source]¶
Curate the dataset according to a callable curator. Modifies collection in-place to remove streams that do not satisfy the curation criteria of the callable. Curator call signature must be consitent with:
callable(station_code, event_id, stream) -> bool
The callable returns a boolean indicating whether to keep the Stream or not.
- Parameters:
curator (Callable) – Function or callable delegate to adjudicate whether to keep each given stream.
- Returns:
None
- event(event_id)[source]¶
Accessor for stations for a given event.
- Parameters:
event_id (str) – ID of event to look up
- Returns:
Station index for given event, if event ID is found, otherwise None
- Return type:
SortedDict or NoneType
- num_stations()[source]¶
Get number of stations in the dataset.
- Returns:
Number of stations
- Return type:
- prune(items, cull=True)[source]¶
Remove a given sequence of (station, event) pairs from the dataset.
- Parameters:
items (Iterable(tuple)) – Iterable of (station, event) pairs
cull (boolean) – If True, then empty entries in the top level index will be removed.
- Returns:
None
- station(station_code)[source]¶
Accessor for events for a given station.
- Parameters:
station_code (str) – Station to get
- Returns:
Event index for station, if station is found
- Return type:
SortedDict
seismic.plot_network_event_dataset module¶
Bulk plotting helper functions based on NetworkEventDataset
- seismic.plot_network_event_dataset.plot_ned_seismograms(ned, output_file, channel_order='ZNE')[source]¶
Plot seismograms in NetworkEventDataset to PDF file. If dataset is very large, this may take a long time to run.
- Parameters:
ned – NetworkEventDataset containing waveforms.
output_file – Output file name
seismic.stream_io module¶
Helper functions for seismic stream IO.
- seismic.stream_io.get_obspyh5_index(src_file, seeds_only=False, root='/waveforms')[source]¶
Scrape the index (only) from an obspyh5 file.
- Parameters:
src_file (str or pathlib.Path) – Name of file to extract index from
seeds_only (bool) – If True, only get the seed IDs of the traces. Otherwise (default), get full index.
- Returns:
Sorted dictionary with index of waveforms in the file
- Return type:
sortedcontainers.SortedDict
- seismic.stream_io.iter_h5_stream(src_file, headonly=False, root='/waveforms')[source]¶
Iterate over hdf5 file containing streams in obspyh5 format.
- Parameters:
src_file (str or pathlib.Path) – Path to file to read
headonly (bool) – Only read trace stats, do not read actual time series data
- Yield:
obspy.Stream containing traces for a single seismic event.
- seismic.stream_io.read_h5_stream(src_file, network=None, station=None, loc='', root='/waveforms')[source]¶
Helper function to load stream data from hdf5 file saved by obspyh5 HDF5 file IO. Typically the source file is generated using extract_event_traces.py script. For faster loading time, a particular network and station may be specified.
- Parameters:
- Returns:
All the loaded data in an obspy Stream.
- Return type:
obspy.Stream
- seismic.stream_io.sac2hdf5(src_folder, basenames, channels, dest_h5_file, tt_model_id='iasp91')[source]¶
Convert collection of SAC files from a folder into a single HDF5 stream file.
- Parameters:
src_folder (str or Path) – Path to folder containing SAC files
basenames (list of str) – List of base filenames (file name excluding extension) to load.
channels (List of str) – List of channels to load. For each base filename in basenames, there is expected to be a file with each channel as the filename extension.
dest_h5_file (str or Path) – Path to output file. Will be created, or overwritten if already exists.
tt_model_id (str) – Which travel time earth model to use for synthesizing trace metadata. Must be known to obspy.taup.TauPyModel
- Returns:
None
- seismic.stream_io.safe_iter_event_data(events, inventory, get_waveforms, use_rfstats=True, phase='P', request_window=None, pad=10, pbar=None, **kwargs)[source]¶
Return iterator yielding three component streams per station and event.
- Parameters:
events – list of events or ~obspy.core.event.Catalog instance
inventory – ~obspy.core.inventory.inventory.Inventory instance with station and channel information
get_waveforms – Function returning the data. It has to take the arguments network, station, location, channel, starttime, endtime.
phase – Considered phase, e.g. ‘P’, ‘S’, ‘PP’
request_window (tuple (start, end)) – requested time window around the onset of the phase
pad (float) – add specified time in seconds to request window and trim afterwards again
pbar – tqdm instance for displaying a progressbar
kwargs – all other kwargs are passed to ~rf.rfstream.rfstats()
- Returns:
three component streams with raw data
Example usage with progressbar:
from tqdm import tqdm from rf.util import iter_event_data with tqdm() as t: for stream3c in iter_event_data(*args, pbar=t): do_something(stream3c)
- seismic.stream_io.write_h5_event_stream(dest_h5_file, stream, index='waveforms/{network}.{station}.{location}/{event_time.datetime:%Y-%m-%dT%H:%M:%S}/{channel}_{starttime.datetime:%Y-%m-%dT%H:%M:%S}_{endtime.datetime:%Y-%m-%dT%H:%M:%S}', mode='a', ignore=())[source]¶
Write stream to HDF5 file in event indexed format using obspy.
- Parameters:
dest_h5_file (str or pathlib.Path) – File in which to write the stream.
stream (obspy.Stream) – The stream to write
mode (str) – Write mode, such as ‘w’ or ‘a’. Use ‘a’ to iteratively write multiple streams to one file.
ignore (Any iterable of str) – List of headers to ignore when writing attributes to group. Passed on directly to obspyh5.writeh5
seismic.stream_processing module¶
Utility stream processing functions.
- seismic.stream_processing.assert_homogenous_stream(stream, funcname)[source]¶
Verify that the given stream does not contain mixture of stations or channels/components.
- Parameters:
stream (obspy.Stream or rf.RFStream) – Stream containing one or more traces
- Returns:
None
- seismic.stream_processing.back_azimuth_filter(back_azi, back_azi_range)[source]¶
Check if back azimuth back_azi is within range. Inputs must be in the range [0, 360] degrees.
- seismic.stream_processing.correct_back_azimuth(_event_id, stream, baz_correction)[source]¶
Apply modification to the back azimuth value in the stream stats
- Parameters:
_event_id – Ignored
stream (obspy.Stream or rf.RFSTream) – Stream to which correction is applied
baz_correction – Any object with a registered scalarize function for generating an angle correction for a trace in degrees. E.g. could be a numeric value, a dictionary of correction values, or a file produced by script rf_station_orientations.py
- Returns:
Stream with modified back azimuth
- Return type:
Same as type(stream)
- seismic.stream_processing.negate_channel(_event_id, stream, channel)[source]¶
Negate the data in the given channel of the stream
- Parameters:
_event_id – Ignored
stream (obspy.Stream) – Stream containing channel to flip
channel (str) – Single character string indicating which component to flip
- Returns:
Stream with channel data negated
- Return type:
obspy.Stream
- seismic.stream_processing.scalarize(_obj, _stats)[source]¶
- seismic.stream_processing.scalarize(val: Number, _stats)
- seismic.stream_processing.scalarize(d: dict, stats)
- seismic.stream_processing.scalarize(filename: str, stats)
Fallback scalarize function for non-specialized type
- seismic.stream_processing.sinc_resampling(t, y, t_new)[source]¶
Resample signal y for known times t onto new times t_new. Sampling rates do not need to match and time windows do not need to overlap. t_new should not have a lower sampling rate than t.
- Parameters:
t (numpy.array) – 1D array of times
y (numpy.array) – 1D array of sample values
t_new (numpy.array) – 1D array of new times to interpolate onto
- Returns:
1D array of new interpolated sample values
- Return type:
numpy.array
- seismic.stream_processing.swap_ne_channels(_event_id, stream)[source]¶
Swap N and E channels on a stream. Changes the input stream.
- Parameters:
_event_id – Ignored
stream (obspy.Stream) – Stream whose N and E channels are to be swapped
- Returns:
Stream with channel swapping applied
- Return type:
obspy.Stream
seismic.stream_quality_filter module¶
Helper functions for curating and quality controlling stream objects.
- seismic.stream_quality_filter.curate_seismograms(data_all, curation_opts, logger, rotate_to_zrt=True)[source]¶
Curation function to remove bad data from streams. Note that this function will modify the input dataset during curation.
- Parameters:
data_all (seismic.network_event_dataset.NetworkEventDataset) – NetworkEventDataset containing seismograms to curate. Data will be modified by this function.
curation_opts (dict) – Dict containing curation options.
logger (logging.Logger) – Logger for emitting log messages
rotate_to_zrt (bool) – Whether to automatically rotate to ZRT coords.
- Returns:
None, curation operates directly on data_all
- seismic.stream_quality_filter.curate_stream3c(ev_id, stream3c, logger=None)[source]¶
Apply quality curation criteria to a stream. Modifies the stream in-place if required. Traces in stream must be in ZNE order. Each trace in the stream is expected to have metadata with starttime, endtime, channel and inclination.
The following checks are made. If any of these checks fails, the function returns False: * Inclination value is not NaN * The stream has 3 channels * Each trace in the stream has the same number of samples * None of the traces have any NaN values in the time series data * None of the traces have zero variance
The following cleanups are attempted on the stream: * All 3 traces have the same time range
- Parameters:
stream3c (obspy.Stream) – Stream with 3 components of trace data
logger (logging.Logger) – Logger in which to log messages
- Returns:
True if checks pass, False otherwise
- Return type:
seismic.units_utils module¶
Constants and utility functions for unit conversion.