pisces.fdsn.stream#
Conversions between KB Core Wfdisc rows and ObsPy Trace objects.
wfdisc2trace builds a Trace whose .stats always reflects the wfdisc row’s own column values (station/channel/sample rate/start time/etc.), via read_waveform’s dispatch (pisces.io.waveforms.WAVEFORM_READERS). Every registered waveform reader – including the ones that read a real file format internally, like ‘sd’ miniSEED or ‘sc’ SAC – returns only a raw sample array, discarding whatever in-file header ObsPy may have parsed along the way. So there is no file-reported sub-header (.stats.mseed/.stats.sac) to reconcile here: the wfdisc row is the only source of truth for wfdisc2trace’s output. Code that wants a file’s original header (not reconciled against any table) should read that file directly with plain ObsPy instead.
- pisces.fdsn.stream.availability(query, mergegaps=0.0, mergesamplerate=None, show=None, includerestricted=True, restricted_substring=None)[source]#
Get availability spans for the rows represented by
query.The query must already contain all waveform filters, typically through
filter_waveforms(), and must include Wfdisc and Affiliation entities. Site and Network entities are additionally required when restricted rows are excluded. Location is always returned as"--"because KB Core Wfdisc has no location field.- Parameters:
- querysqlalchemy.orm.Query
Pre-filtered query containing Wfdisc and Affiliation.
- mergegapsfloat, optional
Merge spans separated by no more than this many seconds.
- mergesampleratefloat, optional
Treat sample rates within this absolute tolerance as equivalent.
- showstr or None, optional
"latestupdate"orNone. Includeupdatedwith the latest contributing Wfdisc load date.- includerestrictedbool, optional
Include restricted rows (default) or exclude them.
- restricted_substringstr, optional
Substring identifying restricted rows in Site.staname or Network.netname. Required when
includerestricted=False.
- Returns:
- iterable
Named result rows with FDSN-style attributes:
network,station,location,channel,samplerate,earliest, andlatest;updatedis included when requested.
- pisces.fdsn.stream.extent(query, includerestricted=True, restricted_substring=None)[source]#
Get earliest/latest extents for the rows represented by
query.The query must already contain all waveform filters, typically through
filter_waveforms(), and include Wfdisc and Affiliation entities. Extents are grouped by network, station, channel, and exact sample rate.timespansis the number of contributing Wfdisc records, not merged continuous spans. Location is always"--"and restriction is reported as"PARTIAL"because KB Core does not provide restriction metadata.
- pisces.fdsn.stream.spans_interval(st, starttime, endtime, tolerance=None)[source]#
Return whether a stream spans a requested interval within tolerance.
- Parameters:
- stobspy.Stream
Stream to validate.
- starttime, endtimeobspy.UTCDateTime
Requested interval.
- tolerancefloat, optional
Allowed difference between the requested and observed stream bounds.
Noneskips validation and returnsTrue.
- Returns:
- bool
Truewhen the interval is valid, otherwiseFalse.
- pisces.fdsn.stream.stream(q, headonly=False)[source]#
Convert Wfdisc rows to an ObsPy Stream.
- Parameters:
- qsqlalchemy.orm.Query
Query containing a Wfdisc entity.
- headonlybool, optional
If true, return dataless traces built from Wfdisc headers without reading waveform files. Default is false.
- Raises:
- OSError
If a waveform file cannot be read when
headonlyis false.