obspy.signal.quality_control.MSEEDMetadata¶
- class MSEEDMetadata(files, id=None, prefix='smi:local/qc', starttime=None, endtime=None, add_c_segments=True, add_flags=False, waveform_type='seismic')[source]¶
Bases: builtins.object
A container for MiniSEED specific metadata, including quality control parameters.
Reads the MiniSEED files and extracts the data quality metrics. All MiniSEED files must have a matching stream ID and quality.
Parameters: - files (str or list of str) One ore more MiniSEED files.
- id (str, optional) A unique identifier of the to be created QC object. It is not verified, that it actually is unique. The user has to take care of that. If no id is given, uuid.uuid4() will be used to create one which assures uniqueness within one Python run. If no fixed id is provided, the ID will be built from prefix and a random uuid hash.
- prefix (str, optional) An optional identifier that will be put in front of any automatically created id. The prefix will only have an effect if id is not specified (for a fixed ID string).
- starttime (obspy.core.utcdatetime.UTCDateTime) Only use records whose end time is larger then this given time. Also specifies the new official start time of the metadata object.
- endtime (obspy.core.utcdatetime.UTCDateTime) Only use records whose start time is smaller then this given time. Also specifies the new official end time of the metadata object
- add_c_segments (bool) Calculate metrics for each continuous segment.
- add_flags (bool) Include MiniSEED header statistics in result.
- waveform_type (str) The type of waveform data, e.g. "seismic", "infrasound", ...
Example
>>> from obspy.signal.quality_control import ... MSEEDMetadata >>> mseedqc = MSEEDMetadata(['path/to/file', ... 'path/to/file2'])
The class requires a list of files for calculating metrics. Add optional parameters starttime="YYYY-MM-DDThh:mm:ss and endtime="YYYY-MM-DDThh:mm:ss" or obspy.core.utcdatetime.UTCDateTime to limit metric calculation to this window. Continuous segments are returned when add_c_segments=True and MiniSEED header flags information is returned when add_flags=True.
The calculated metrics are then available in the .meta dictionary.
>>> mseedqc.meta
This is intended to be serialized as JSON. Retrieve the JSON string (to for example store it in a database or save to a file) with:
>>> mseedqc.get_json_meta()
Attributes
__dict__ __doc__ str(object=’‘) -> str __module__ str(object=’‘) -> str __weakref__ list of weak references to the object (if defined) number_of_records Number of records across files before slicing. number_of_samples Number of samples across files. Public Methods
get_json_meta Serialize the meta dictionary to JSON. validate_qc_metrics Validate the passed metrics against the JSON schema. Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
_compute_continuous_seg_sample_metrics Computes metrics on the samples within each continuous segment. _compute_sample_metrics Computes metrics on samples contained in the specified time window _extract_mseed_flags _extract_mseed_stream_metadata Collect information from the MiniSEED headers. _extract_mseed_stream_stats Small function to collects the mSEED stats _get_gaps_and_overlaps Function to get all gaps and overlaps in the user _parse_c_stats param tr: custom dictionary with start, end, data, and sampling_rate Special Methods
__dir__ default dir() implementation __format__ default object formatter __init__ Reads the MiniSEED files and extracts the data quality metrics. __new__ Create and return a new object. __reduce__ helper for pickle __reduce_ex__ helper for pickle __sizeof__ size of object in memory, in bytes __subclasshook__ Abstract classes can override this to customize issubclass().