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: 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[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

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.

MSEEDMetadata._compute_continuous_seg_sample_metrics()[source]

Computes metrics on the samples within each continuous segment.

MSEEDMetadata._compute_sample_metrics()[source]

Computes metrics on samples contained in the specified time window

MSEEDMetadata._extract_mseed_flags()[source]
MSEEDMetadata._extract_mseed_stream_metadata()[source]

Collect information from the MiniSEED headers.

MSEEDMetadata._extract_mseed_stream_stats()[source]

Small function to collects the mSEED stats

MSEEDMetadata._get_gaps_and_overlaps()[source]

Function to get all gaps and overlaps in the user specified (or forced) window.

MSEEDMetadata._parse_c_stats(tr)[source]
Parameters:

tr – custom dictionary with start, end, data, and sampling_rate of a continuous trace

Special Methods

MSEEDMetadata.__delattr__(name, /)

Implement delattr(self, name).

MSEEDMetadata.__dir__()

Default dir() implementation.

MSEEDMetadata.__eq__(value, /)

Return self==value.

MSEEDMetadata.__format__(format_spec, /)

Default object formatter.

MSEEDMetadata.__ge__(value, /)

Return self>=value.

MSEEDMetadata.__getattribute__(name, /)

Return getattr(self, name).

MSEEDMetadata.__gt__(value, /)

Return self>value.

MSEEDMetadata.__hash__()

Return hash(self).

MSEEDMetadata.__init__(files, id=None, prefix='smi:local/qc', starttime=None, endtime=None, add_c_segments=True, add_flags=False, waveform_type='seismic')[source]

Reads the MiniSEED files and extracts the data quality metrics.

MSEEDMetadata.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

MSEEDMetadata.__le__(value, /)

Return self<=value.

MSEEDMetadata.__lt__(value, /)

Return self<value.

MSEEDMetadata.__ne__(value, /)

Return self!=value.

MSEEDMetadata.__new__(**kwargs)
MSEEDMetadata.__reduce__()

Helper for pickle.

MSEEDMetadata.__reduce_ex__(protocol, /)

Helper for pickle.

MSEEDMetadata.__repr__()

Return repr(self).

MSEEDMetadata.__setattr__(name, value, /)

Implement setattr(self, name, value).

MSEEDMetadata.__sizeof__()

Size of object in memory, in bytes.

MSEEDMetadata.__str__()

Return str(self).

MSEEDMetadata.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).