database¶
Classes for managing databases and simulating databases.
database.database_manager¶
Tools for managing a database of template information.
- class rt_eqcorrscan.database.database_manager.TemplateBank(base_path='.', path_structure=None, name_structure=None, event_format='quakeml', event_ext='.xml', template_ext='.tgz', executor=None)[source]¶
A database manager for templates. Based on obsplus EventBank.
- Parameters
base_path (
Union
[str
,Path
,EventBank
]) – The path to the directory containing event files. If it does not exist an empty directory will be created.path_structure (
Optional
[str
]) – Define the directory structure used by the event bank. Characters are separated by /, regardless of operating system. The following words can be used in curly braces as data specific variables: year, month, day, julday, hour, minute, second, event_id, event_id_short. If no structure is provided it will be read from the index, if no index exists the default is {year}/{month}/{day}name_structure (str) – The same as path structure but for the event, template and waveform file names. Supports the same variables and a slash cannot be used in a file name on most operating systems. The default extension (.xml, .tgz, .ms) will be added for events, templates and waveforms respectively. The default is {time}_{event_id_short}.
event_format – The anticipated format of the event files. Any format supported by the obspy.read_events function is permitted.
event_ext – The extension on the event files. Can be used to avoid parsing non-event files.
template_ext – The extension on the template files. Can be used to avoid parsing non-template files.
Notes
Supports parallel execution of most methods using concurrent.futures executors. Set the TemplateBank.executor attribute to your required executor.
- get_templates(**kwargs)[source]¶
Get template waveforms from the database
Supports passing an concurrent.futures.Executor using the executor keyword argument for parallel reading.
{get_event_params}
- Return type
Tribe
- make_templates(catalog, stream=None, client=None, download_data_len=90, save_raw=True, update_index=True, rebuild=False, **kwargs)[source]¶
Make templates from data or client based on a given catalog.
Templates will be put in the database. Requires either a stream or a suitable client with a get_waveforms method.
- Parameters
catalog (
Catalog
) – Catalog of events to generate templates from.stream (
Optional
[Stream
]) – Optional: Stream encompassing the events in the catalogclient – Optional: Client with at-least a get_waveforms method, ideally the client should make the data for the events in catalog available.
download_data_len (
float
) – If client is given this is the length of data to download. The raw continuous data will also be saved to disk to allow later processing if save_raw=Truesave_raw (
bool
) – Whether to store raw data on disk as well - defaults to True.update_index (
bool
) – Flag to indicate whether or not to update the event index after writing the new events.rebuild (
bool
) – Flag to indicate whether templates already existing in the TemplateBank should be re-generated. True will overwrite existing templates.kwargs – Keyword arguments supported by EQcorrscan’s Template.construct method. Requires at least: lowcut, highcut, samp_rate, filt_order, prepick, length, swin
- Return type
Tribe of templates
- rt_eqcorrscan.database.database_manager.check_tribe_quality(tribe, seed_ids=None, min_stations=None, lowcut=None, highcut=None, filt_order=None, samp_rate=None, process_len=None, *args, **kwargs)[source]¶
Check that templates in the tribe have channels all the same length.
- Parameters
tribe (
Tribe
) – A Tribe to check the quality of.seed_ids (
Optional
[set
]) – seed-ids of channels to be included in the templates - if None, then all channels will be includedmin_stations (
Optional
[int
]) – Minimum number of stations for a template to be included.lowcut (
Optional
[float
]) – Desired template processing lowcut in Hz, if None, will not checkhighcut (
Optional
[float
]) – Desired template processing highcut in Hz, if None, will not checkfilt_order (
Optional
[int
]) – Desired template filter order, if None, will not checksamp_rate (
Optional
[float
]) – Desired template sampling rate in Hz, if None, will not checkprocess_len (
Optional
[float
]) – Desired template processing length in s, if None, will not check
- Return type
A filtered tribe.
database.client_emulation¶
Utilities for emulating obspy clients using local data. Relies on obsplus