kbws.formats module#
Utilities in support of FDSN formats.
- class kbws.formats.WaveformFormat(name, obspy_format, mimetype, extension, convert_stream)#
Bases:
tuple- convert_stream#
Alias for field number 4
- extension#
Alias for field number 3
- mimetype#
Alias for field number 2
- name#
Alias for field number 0
- obspy_format#
Alias for field number 1
- kbws.formats.event_text(catalog: Catalog) str[source]#
Serialize an ObsPy Catalog using the FDSN event text format.
- kbws.formats.mseed_bytes(stream: Stream) bytes[source]#
Produce an in-memory miniSEED archive from a Stream object.
- Return type:
bytes
Notes
This may start to fail with large requests, as both the Stream and the output bytes will be in-memory during the lifetime of the request.
- kbws.formats.post_parse(body: Iterable[str])[source]#
Params#
- body
Lines of a station POST query.
- returns:
params (dict[str, str]) – string keys, string values
bulk (list[list[str]]) – network, station, location, channel, starttime, endtime
- raises ValueError:
bulk lines don’t have the right number of values in a line
Notes
POST looks like this:
level=channel format=text TA A25A – BH? 2010-03-25T00:00:00 2010-04-01T00:00:00 IU ANMO * BH? 2010-03-25T00:00:00 2010-04-01T00:00:00 IU ANMO 10 HHZ 2010-03-25T00:00:00 2010-04-01T00:00:00 II KURK 00 BH? 2010-03-25T00:00:00 2010-04-01T00:00:00
Output looks like:
- ({‘level’: ‘channel’, ‘format’: ‘text’},
- [[‘TA’, ‘A25A’, ‘–’, ‘BH?’, ‘2010-03-25T00:00:00’, ‘2010-04-01T00:00:00’],
[‘IU’, ‘ANMO’, ‘*’, ‘BH?’, ‘2010-03-25T00:00:00’, ‘2010-04-01T00:00:00’], [‘IU’, ‘ANMO’, ‘10’, ‘HHZ’, ‘2010-03-25T00:00:00’, ‘2010-04-01T00:00:00’], [‘II’, ‘KURK’, ‘00’, ‘BH?’, ‘2010-03-25T00:00:00’, ‘2010-04-01T00:00:00’]])
- kbws.formats.saczip_bytes(stream: Stream) bytes[source]#
Produce an in-memory zip archive of sac files from _a Stream object.
Names the files inside the archive following the IRIS FDSN-WS convention, with SAC traces named according to trace ID and first sample time, like:
- <archive_name>
NETWORK.STATION.LOCATION.CHANNEL.QUALITY.YYYY.JJJ.HHMMSS.SAC
Example
- fdsnws-dataselect_2023-04-24t19 01 31z.sac.zip (request time)
IU.TUC.00.BHZ.M.2010.058.063000.SAC (first sample time)
- Return type:
bytes
Notes
This may start to fail with large requests, as both the Stream and the output bytes will be in-memory during the lifetime of the request.