simplemseed.mseed3
Module Contents
Classes
Represents the fixed header section of a mseed3 record. |
|
Represents a mseed3 record. |
Functions
Check if two miniseed3 records are mergable. |
|
CRC as printable string. |
|
Merges two MSeed3Records if possible. |
|
Generator to read miniseed3 records from a file-like object. |
|
Unpacks a fixed header from bytes. |
|
Unpack a miniseed3 record from bytes, optionally verifying the CRC. |
Data
const for offset to crc in record, 28 |
|
const for size of fixed header part of record, 40 |
|
const python struct pack format for fixed header. |
|
MIME type for miniseed3, ‘application/vnd.fdsn.mseed3’. |
|
Format version, Value of 3 |
|
Record header indicator, ASCII ‘MS’ |
|
const for unknown data version, 0 |
API
- simplemseed.mseed3.CRC_OFFSET = 28
const for offset to crc in record, 28
- simplemseed.mseed3.FIXED_HEADER_SIZE = 40
const for size of fixed header part of record, 40
- simplemseed.mseed3.HEADER_PACK_FORMAT = '<ccBBIHHBBBBdIIBBHI'
const python struct pack format for fixed header.
- simplemseed.mseed3.MINISEED_THREE_MIME = 'application/vnd.fdsn.mseed3'
MIME type for miniseed3, ‘application/vnd.fdsn.mseed3’.
- simplemseed.mseed3.MS_FORMAT_VERSION_3 = 3
Format version, Value of 3
- simplemseed.mseed3.MS_RECORD_INDICATOR = 'MS'
Record header indicator, ASCII ‘MS’
- class simplemseed.mseed3.MSeed3Header
Represents the fixed header section of a mseed3 record.
See the [specification](http://docs.fdsn.org/projects/miniseed3/en/latest/).
Fixed header is defined as:
Field
Description
Type
Length
Offset
Content
1
Record header indicator
CHAR
2
0
ASCII ‘MS’
2
Format version
UINT8
1
2
Value of 3
3
Flags
UINT8
1
3
Record start time
4a
Nanosecond (0 - 999999999)
UINT32
4
4
4b
Year (0-65535)
UINT16
2
8
4c
Day-of-year (1 - 366)
UINT16
2
10
4d
Hour (0 - 23)
UINT8
1
12
4e
Minute (0 - 59)
UINT8
1
13
4f
Second (0 - 60)
UINT8
1
14
5
Data payload encoding
UINT8
1
15
6
Sample rate/period
FLOAT64
8
16
7
Number of samples
UINT32
4
24
8
CRC of the record
UINT32
4
28
9
Data publication version
UINT8
1
32
10
Length of identifier
UINT8
1
33
11
Length of extra headers
UINT16
2
34
12
Length of data payload
UINT32
4
36
Initialization
Create a valid but empty fixed header.
See unpackMSeed3FixedHeader() to parse form bytes.
- clone()
- crcAsHex()
String representation of CRC for record.
- property endtime
End time of record, time of last sample.
- pack()
Pack into byte array.
- recordSize()
Total record size in bytes.
- property samplePeriod
Sampling as a period, number of seconds between samples.
- property sampleRate
Sampling as a rate, number of samples per second.
- sanityCheck()
Validation checks.
- property starttime
Start time of record, time of first sample.
- class simplemseed.mseed3.MSeed3Record(header: simplemseed.mseed3.MSeed3Header, identifier: Union[simplemseed.fdsnsourceid.FDSNSourceId, str], data: Union[numpy.ndarray, bytes, bytearray, array.array, list[int], list[float]], extraHeaders: Union[str, dict, None] = None)
Represents a mseed3 record.
See the [specification](http://docs.fdsn.org/projects/miniseed3/en/latest/).
Initialization
- clone()
- decompress() numpy.ndarray
Decompress data to an numpy ndarray.
- decompressedRecord()
Create a new record with decompressed data and the header encoding set to one of the primitive types: short, int, float or double
- details(showExtraHeaders=True, showData=False)
More detailed description of record.
- property eh
Extra headers, from json.
- encodedDataBytes()
Encodes data into bytes.
- encodingName()
Name of encoding, for display.
- property endtime
End time of record, time of last sample.
- getSize()
Calculates the size of the record.
Returns None if any of the identifier, extra headers or data lengths are not yet calculated.
- hasExtraHeaders()
True if record contains extra headers, ie json is not empty.
- header: simplemseed.mseed3.MSeed3Header = None
- identifier: Union[simplemseed.fdsnsourceid.FDSNSourceId, str] = None
- pack()
Pack the record contents into a bytearray.
Header values for the lengths and CRC are updated, so the record header represents the output bytes after packing.
- parseIdentifier() simplemseed.fdsnsourceid.FDSNSourceId
Parse identifier as an FDSNSOurceId.
Identifier must start with ‘FDSN:’ to be parsed.
- property starttime
Start time of record, time of first sample.
- summary()
One line summary of the record.
- exception simplemseed.mseed3.Miniseed3Exception
Bases:
ExceptionException in parsing a miniseed3 record from bytes-like.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- simplemseed.mseed3.UNKNOWN_PUBLICATION_VERSION = 0
const for unknown data version, 0
- simplemseed.mseed3.areCompatible(ms3a: simplemseed.mseed3.MSeed3Record, ms3b: simplemseed.mseed3.MSeed3Record, timeTolFactor=0.5) bool
Check if two miniseed3 records are mergable.
This requires same identifier, sample rate, data encoding and publication version, and that the record times are adjacent.
- simplemseed.mseed3.crcAsHex(crc)
CRC as printable string.
- simplemseed.mseed3.mseed3merge(ms3a: simplemseed.mseed3.MSeed3Record, ms3b: simplemseed.mseed3.MSeed3Record) list[simplemseed.mseed3.MSeed3Record]
Merges two MSeed3Records if possible.
Returned list will have either both original records if merge is not possible, or a single new record if merge was. Note extra headers are taken from the first record and any headers in the second record are ignored. Merging of dict structures just seems to hard to be done automatically, without understanding the meaning of the items.
- simplemseed.mseed3.readMSeed3Records(fileptr, check_crc=True, matchsid=None, merge=False, verbose=False)
Generator to read miniseed3 records from a file-like object.
Optionally filter on matchsid regular expression. Also optionally merge contiguous records.
Example: .. code-block:: python
- for msr in simplemseed.readMSeed3Records(infile):
# do something… pass
- simplemseed.mseed3.unpackMSeed3FixedHeader(recordBytes)
Unpacks a fixed header from bytes.
Returns a MSeed3Header object.
- simplemseed.mseed3.unpackMSeed3Record(recordBytes, check_crc=True)
Unpack a miniseed3 record from bytes, optionally verifying the CRC.
Returns a MSeed3Record object.