obspy.io.mseed.util.get_timing_and_data_quality¶

get_timing_and_data_quality(file_or_file_object)[source]

Counts all data quality flags of the given Mini-SEED file and returns statistics about the timing quality if applicable.

Parameters: file_or_file_object (str or file) Mini-SEED file name or open file-like object containing a Mini-SEED record. Dictionary with information about the timing quality and the data quality flags.

Data quality

This method will count all set data quality flag bits in the fixed section of the data header in a Mini-SEED file and returns the total count for each flag type.

Bit Description
[Bit 0] Amplifier saturation detected (station dependent)
[Bit 1] Digitizer clipping detected
[Bit 2] Spikes detected
[Bit 3] Glitches detected
[Bit 5] Telemetry synchronization error
[Bit 6] A digital filter may be charging
[Bit 7] Time tag is questionable

Timing quality

If the file has a Blockette 1001 statistics about the timing quality will also be returned. See the doctests for more information.

This method will read the timing quality in Blockette 1001 for each record in the file if available and return the following statistics: Minima, maxima, average, median and upper and lower quantile. Quantiles are calculated using a integer round outwards policy: lower quantiles are rounded down (probability < 0.5), and upper quantiles (probability > 0.5) are rounded up. This gives no more than the requested probability in the tails, and at least the requested probability in the central area. The median is calculating by either taking the middle value or, with an even numbers of values, the average between the two middle values.

Example

>>> from obspy.core.util import get_example_file
>>> filename = get_example_file("qualityflags.mseed")
>>> tq = get_timing_and_data_quality(filename)
>>> for k, v in tq.items():
...     print(k, v)
data_quality_flags [9, 8, 7, 6, 5, 4, 3, 2]


Also works with file pointers and BytesIOs.

>>> f = open(filename, 'rb')
>>> tq = get_timing_and_data_quality(f)
>>> for k, v in tq.items():
...     print(k, v)
data_quality_flags [9, 8, 7, 6, 5, 4, 3, 2]

>>> import io
>>> f.close()
>>> tq = get_timing_and_data_quality(file_object)
>>> for k, v in tq.items():
...     print(k, v)
data_quality_flags [9, 8, 7, 6, 5, 4, 3, 2]


If the file pointer or BytesIO position does not correspond to the first record the omitted records will be skipped.

>>> _ = file_object.seek(1024, 1)
>>> tq = get_timing_and_data_quality(file_object)
>>> for k, v in tq.items():
...     print(k, v)
data_quality_flags [8, 8, 7, 6, 5, 4, 3, 2]
>>> file_object.close()


Reading a file with Blockette 1001 will return timing quality statistics. The data quality flags will always exists because they are part of the fixed Mini-SEED header and therefore need to be in every Mini-SEED file.

>>> filename = get_example_file("timingquality.mseed")
>>> tq = get_timing_and_data_quality(filename)
>>> for k, v in sorted(tq.items()):
...     print(k, v)
data_quality_flags [0, 0, 0, 0, 0, 0, 0, 0]
timing_quality_average 50.0
timing_quality_lower_quantile 25.0
timing_quality_max 100.0
timing_quality_median 50.0
timing_quality_min 0.0
timing_quality_upper_quantile 75.0


Also works with file pointers and BytesIOs.

>>> f = open(filename, 'rb')
>>> tq = get_timing_and_data_quality(f)
>>> for k, v in sorted(tq.items()):
...     print(k, v)
data_quality_flags [0, 0, 0, 0, 0, 0, 0, 0]
timing_quality_average 50.0
timing_quality_lower_quantile 25.0
timing_quality_max 100.0
timing_quality_median 50.0
timing_quality_min 0.0
timing_quality_upper_quantile 75.0

>>> file_object = io.BytesIO(f.read())
>>> f.close()
>>> tq = get_timing_and_data_quality(file_object)
>>> for k, v in sorted(tq.items()):
...     print(k, v)
data_quality_flags [0, 0, 0, 0, 0, 0, 0, 0]
timing_quality_average 50.0
timing_quality_lower_quantile 25.0
timing_quality_max 100.0
timing_quality_median 50.0
timing_quality_min 0.0
timing_quality_upper_quantile 75.0
>>> file_object.close()