pyrocko.squirrel.model¶
Data model and content types handled by the Squirrel framework.
Squirrel uses flat content types to represent waveform, station, channel,
response, event, and a few other objects. A common subset of the information in
these objects is indexed in the database, currently: kind, codes, time interval
and sampling rate. The Nut objects encapsulate this information
together with information about where and how to get the associated bulk data.
Further content types are defined here to handle waveform orders, waveform promises, data coverage and sensor information.
Functions
|
Convert codes patterns to a normalized list of query patterns. |
Get the default earth model for ray computations. |
|
|
Combine several coverages into one, merging their change points. |
|
Combine several coverages of the same codes but different content kinds into one, encoding each kind's coverage state in separate bits of the combined |
|
Join a full-seconds/fractional-offset pair back into a single time value (inverse of |
|
Convert an object to a codes object of the class appropriate for a given content kind. |
Convert a dot-separated string to a codes object, guessing the appropriate codes class from its number of dots. |
|
|
Convert a safe-string representation of codes to a codes object. |
|
Get content kind name for a content kind id. |
|
Get content kind id for a content kind name. |
|
Get content kind ids for a list of content kind names, see |
|
Get content kind names for a list of content kind ids, see |
|
Split time into full-seconds and fractional-offset parts, for compact, fast-comparable database storage. |
Classes
|
A channel of a seismic station. |
|
Base class for |
|
Information about times covered by a waveform or other time series data. |
|
Lightweight, meta-information-only stand-in for a |
|
Index entry referencing an elementary piece of content. |
|
Choice of observational or technical quantity. |
|
The instrument response of a seismic station channel. |
|
Representation of a response stage. |
|
Representation of a channel group. |
|
A seismic station. |
|
Waveform request information. |
|
Information about a waveform potentially downloadable from a remote site. |
Exceptions
Raised when a downloaded waveform fails validation, see |
|
Raised when a sensor's components cannot be rotated to the requested coordinate system, e.g. because the source geometry is missing or the given arguments conflict. |
- to_codes_simple(kind_id, codes_safe_str)[source]¶
Convert a safe-string representation of codes to a codes object.
- to_codes(kind_id, obj)[source]¶
Convert an object to a codes object of the class appropriate for a given content kind.
- Parameters:
kind_id (int) – Content kind determining the target codes class, one of the ids given in
g_content_kind_ids.obj – Value to be converted, anything accepted by the target codes class’s constructor (e.g. a dot-separated string or a tuple).
- Return type:
Codes(subclass appropriate forkind_id)
- to_codes_guess(s)[source]¶
Convert a dot-separated string to a codes object, guessing the appropriate codes class from its number of dots.
STA(no dots) givesCodesX, which matches the station code when used for channel or station queries, and the name for other content kinds.NET.STAgivesCodesNSLwith any location code.
- codes_patterns_for_kind(kind_id, codes)[source]¶
Convert codes patterns to a normalized list of query patterns.
- Parameters:
kind_id (int) – Content kind determining the target codes class, one of the ids given in
g_content_kind_ids.codes (anything accepted by
to_codes(), orlistthereof) – Single codes pattern, or list thereof, in any form accepted byto_codes(). Already-normalized input (as returned by this function) is passed through unchanged.
- Returns:
Normalized list of codes patterns, appropriate for the queried content kind. For station queries, an additional pattern matching any location code is added, since SEED/StationXML conventions treat the location code as part of the channel rather than the station, unlike
CodesNSL(see its docstring).- Return type:
codes_patterns_list
- to_kind_ids(kinds)[source]¶
Get content kind ids for a list of content kind names, see
to_kind_id().
- tsplit(t)[source]¶
Split time into full-seconds and fractional-offset parts, for compact, fast-comparable database storage.
- Parameters:
t (
get_time_float()) – Time to be split, orNone.- Returns:
(seconds, offset), wheresecondsis the floored full seconds part andoffsetthe remaining fractional part, in integer units ofg_offset_time_unitseconds. Returns(None, 0)iftisNone.- Return type:
- tjoin(seconds, offset)[source]¶
Join a full-seconds/fractional-offset pair back into a single time value (inverse of
tsplit()).- Parameters:
- Returns:
Joined time, or
NoneifsecondsisNone.- Return type:
- class Station(**kwargs)[source]¶
Bases:
LocationA seismic station.
- ♦ codes¶
-
Codes identifying the station (NET.STA.LOC).
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalStart time of station epoch.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalEnd time of station epoch.
- ♦ description¶
str, optionalAdditional description of the station.
- property time_span¶
Get station’s epoch as
(tmin, tmax)tuple.
- class ChannelBase(**kwargs)[source]¶
Bases:
LocationBase class for
ChannelandSensor, providing the common properties of a single seismic recording channel or a group of channels forming a sensor.- ♦ codes¶
pyrocko.model.codes.CodesNSLCECodes identifying the channel (NET.STA.LOC.CHA.EXTRA).
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalStart time of channel epoch.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalEnd time of channel epoch.
- ♦ deltat¶
float, optionalSampling interval [s].
- property time_span¶
Get channel’s epoch as
(tmin, tmax)tuple.
- overlaps(tmin, tmax)[source]¶
Check if channel’s epoch overlaps with a given time span.
- Parameters:
tmin (
get_time_float()) – Start time of query interval.tmax (
get_time_float()) – End time of query interval.
- Returns:
Trueif the channel’s epoch (tmin,tmax) has any overlap with the given interval.- Return type:
- class Channel(**kwargs)[source]¶
Bases:
ChannelBaseA channel of a seismic station.
- get_pyrocko_channel()[source]¶
Get channel as a classic Pyrocko channel object.
- Returns:
Converted channel object.
- Return type:
- property orientation_enz¶
Get sensor orientation as unit vector in East-North-Up coordinates, or
Noneif azimuth or dip are not set.
- exception ProjectionError[source]¶
Bases:
ExceptionRaised when a sensor’s components cannot be rotated to the requested coordinate system, e.g. because the source geometry is missing or the given arguments conflict.
- get_default_earthmodel()[source]¶
Get the default earth model for ray computations.
The model is
pyrocko.cake.load_model()’s default, loaded once and cached.- Return type:
- class Sensor(**kwargs)[source]¶
Bases:
ChannelBaseRepresentation of a channel group.
- classmethod from_channels(channels)[source]¶
Group channels into sensors.
- Parameters:
channels (iterable of
Channelobjects) – Channels to be grouped.- Returns:
Sensors formed by grouping the given channels by matching station/location codes, orientation-independent channel code (i.e. NET.STA.LOC.BI, where B and I are the SEED band and instrument codes, e.g.
'HH', omitting the component character) and time span, splitting groups where the individual channels’ time spans don’t fully align.- Return type:
- channel_vectors()[source]¶
Get orientation unit vectors of member channels.
- Returns:
Orientation vectors of the member channels in East-North-Up coordinates, stacked into a
(nchannels, 3)array, in the order ofchannels.- Return type:
- projected_channels(system, component_names)[source]¶
Get synthetic channel definitions for a given target coordinate system.
- Parameters:
system (
numpy.ndarray) – Target coordinate system as a(3, 3)rotation matrix, rows giving the new component directions in East-North-Up coordinates.component_names (
strorlistofstr) – Component codes to be used for the three output channels, e.g.'ENZ'.
- Returns:
Synthetic channel definitions for the projected components.
- Return type:
- matrix_to(system, epsilon=1e-07)[source]¶
Get rotation matrix from member channels to a given coordinate system.
- Parameters:
system (
numpy.ndarray) – Target coordinate system as a(3, 3)rotation matrix, rows giving the new component directions in East-North-Up coordinates.epsilon (float) – Absolute values below this threshold are set to zero in the returned matrix, to clean up numerical noise.
- Returns:
Rotation matrix mapping from the member channels’ orientations to the given target system.
- Return type:
- projection_to(system, component_names)[source]¶
Get projection to a given coordinate system.
- Parameters:
system (
numpy.ndarray) – Target coordinate system as a(3, 3)rotation matrix, rows giving the new component directions in East-North-Up coordinates.component_names (
strorlistofstr) – Component codes to be used for the three output channels, e.g.'ENZ'.
- Returns:
A tuple
(matrix, in_channels, out_channels)as expected bypyrocko.trace.project().- Return type:
- projection_to_enz()[source]¶
Get projection to East-North-Up coordinates.
- Returns:
A tuple
(matrix, in_channels, out_channels)as expected bypyrocko.trace.project().- Return type:
- projection_to_trz(source, azimuth=None, backazimuth=None)[source]¶
Get projection to Transverse-Radial-Up coordinates.
- Parameters:
source (
Location) – Source location to compute the backazimuth from, orNoneifbackazimuthorazimuthis given directly.azimuth (float) – Direction of propagation at the sensor [deg], i.e.
backazimuth + 180, overriding the automatic computation fromsource.backazimuth (float) – Backazimuth [deg], i.e. direction from the sensor towards the source, overriding the automatic computation from
source.
- Returns:
A tuple
(matrix, in_channels, out_channels)as expected bypyrocko.trace.project().- Return type:
- incidence_angle(source=None, earthmodel=None, phases=None, distance=None, source_depth=None)[source]¶
Get the incidence angle of a ray from a source at the sensor.
- Parameters:
source (
Location) – Source location, used for the distance and source depth if these are not given directly.earthmodel (
pyrocko.cake.LayeredModel) – Earth model. Default: seeget_default_earthmodel().phases (
listofpyrocko.cake.PhaseDef) – Candidate phases, the first arrival is used. Default:pandP.distance (float) – Source-sensor distance [deg].
source_depth (float) – Source depth [m].
- Returns:
Incidence angle [deg], as given by
pyrocko.cake.Ray.incidence_angle().- Return type:
- Raises:
ProjectionErrorif the geometry is incomplete or no ray connects source and sensor.
- projection_to_lqt(source=None, earthmodel=None, phases=None, distance=None, source_depth=None, backazimuth=None, incidence=None)[source]¶
Get projection to Longitudinal-Transverse-SH (ray-based) coordinates, after Plesinger et al. (1986).
- Parameters:
source (
Location) – Source location to compute backazimuth and incidence angle from, orNoneif these are given directly.earthmodel – Earth model for the incidence angle computation, see
incidence_angle().phases – Candidate phases for the incidence angle computation, see
incidence_angle().distance – Source-sensor distance [deg], see
incidence_angle().source_depth – Source depth [m], see
incidence_angle().backazimuth (float) – Backazimuth [deg], i.e. direction from the sensor towards the source, overriding the automatic computation from
source.incidence (float) – Incidence angle [deg], measured from vertical, overriding the automatic computation.
- Returns:
A tuple
(matrix, in_channels, out_channels)as expected bypyrocko.trace.project().- Return type:
- project_to_trz(source, traces, azimuth=None, backazimuth=None)[source]¶
Rotate traces to Transverse-Radial-Up coordinates.
- Parameters:
source (
Location) – Source location to compute the backazimuth from, orNoneifbackazimuthorazimuthis given directly.traces (
listofTraceobjects) – Traces to be rotated, matching this sensor’s member channels.azimuth (float) – Direction of propagation at the sensor [deg], see
projection_to_trz().backazimuth (float) – Backazimuth [deg], see
projection_to_trz().
- Returns:
Rotated traces.
- Return type:
- project_to_lqt(source, traces, earthmodel=None, phases=None, distance=None, source_depth=None, backazimuth=None, incidence=None)[source]¶
Rotate traces to Longitudinal-Transverse-SH (ray-based) coordinates, see
projection_to_lqt().- Parameters:
traces (
listofTraceobjects) – Traces to be rotated, matching this sensor’s member channels.
Other parameters as for
projection_to_lqt().
- class QuantityType(...) str[source]¶
Bases:
StringChoiceChoice of observational or technical quantity.
SI units are used for all quantities, where applicable.
- class ResponseStage(**kwargs)[source]¶
Bases:
ObjectRepresentation of a response stage.
Components of a seismic recording system are represented as a sequence of response stages, e.g. sensor, pre-amplifier, digitizer, digital downsampling.
- ♦ input_quantity¶
str(QuantityType), optionalPhysical quantity accepted at input of stage.
- ♦ input_sample_rate¶
float, optionalSampling rate at input of stage [Hz].
- ♦ output_quantity¶
str(QuantityType), optionalPhysical quantity produced at output of stage.
- ♦ output_sample_rate¶
float, optionalSampling rate at output of stage [Hz].
- ♦ elements¶
listofpyrocko.response.FrequencyResponseobjects, default:[]Sequence of frequency responses combined (multiplied) to form this stage.
- ♦ log¶
listoftupleof 3strobjects objects, default:[]Log messages noting problems encountered or simplifications made while converting response information from its source format, with entries of the form
(level, context, message).
- property stage_type¶
Attempt to classify the stage as
'sensor','electronics','digitizer','decimation','conversion','combination'or'unknown', based on its input/output quantities and decimation factor.
- property decimation_factor¶
Get decimation factor of stage, or
Noneif it cannot be determined frominput_sample_rateandoutput_sample_rate.
- property summary_quantities¶
One-line summary of input/output quantities.
- property summary_rates¶
One-line summary of input/output sampling rates.
- property summary_entries¶
Get tuple of one-line summary values, for use with
fmt_summary().
- property summary¶
One-line summary of the response stage.
- class Response(**kwargs)[source]¶
Bases:
ObjectThe instrument response of a seismic station channel.
- ♦ codes¶
pyrocko.model.codes.CodesNSLCECodes identifying the channel (NET.STA.LOC.CHA.EXTRA) this response applies to.
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalStart time of response epoch.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalEnd time of response epoch.
- ♦ stages¶
listofResponseStageobjects, default:[]Sequence of response stages, from sensor to digitizer output.
- ♦ checkpoints¶
listofpyrocko.response.FrequencyResponseCheckpointobjects, default:[]Gain checkpoints to be honoured, e.g. from a dataless SEED volume or a StationXML file, used to sanity-check the combined response computed from
stages.
- ♦ deltat¶
float, optionalSampling interval at output of response [s].
- ♦ log¶
listoftupleof 3strobjects objects, default:[]Log messages noting problems encountered or simplifications made while converting response information from its source format, with entries of the form
(level, context, message).
- property time_span¶
Get response’s epoch as
(tmin, tmax)tuple.
- property nstages¶
Number of response stages.
- property input_quantity¶
Physical quantity accepted at input of first stage, or
Noneif no stages are present.
- property output_quantity¶
Physical quantity produced at output of last stage, or
Noneif no stages are present.
- property output_sample_rate¶
Sampling rate at output of last stage [Hz], or
Noneif no stages are present.
- property summary_quantities¶
One-line summary of input/output quantities and output sample rate.
- property summary_entries¶
Get tuple of one-line summary values, for use with
fmt_summary().
- property summary¶
One-line summary of the response.
- get_effective(input_quantity=None, stages=(None, None), mode='complete', gain_frequency=None)[source]¶
Get effective combined frequency response.
- Parameters:
input_quantity (str) – If given, prepend a conversion from the given physical quantity to the response’s native
input_quantity.stages (
tupleof 2intorNone) – Restrict combination to a sub-range ofstages, given as(start, stop)index tuple, following Python slicing conventions. UseNonefor an open end.mode (str) –
'complete'to combine all selected stages, or'sensor'to instead replace non-sensor stages with a constant gain evaluated atgain_frequency(useful to inspect the sensor’s response in isolation while still accounting for the overall system gain).gain_frequency (float) – Frequency [Hz] at which to evaluate the constant gain used to replace non-sensor stages when
mode='sensor'. Required in that case.
- Returns:
Combined response.
- Return type:
Results are cached per
(input_quantity, stages)combination.
- class WaveformPromise(**kwargs)[source]¶
Bases:
ObjectInformation about a waveform potentially downloadable from a remote site.
In the Squirrel framework, waveform promises are used to permit download of selected waveforms from a remote site. They are typically generated by calls to
update_waveform_promises(). Waveform promises are inserted and indexed in the database similar to normal waveforms. When processing a waveform query, e.g. fromget_waveforms(), and no local waveform is available for the queried time span, a matching promise can be resolved, i.e. an attempt is made to download the waveform from the remote site. The promise is removed after the download attempt (except when a network error occurs). This prevents Squirrel from making unnecessary queries for waveforms missing at the remote site.- ♦ codes¶
pyrocko.model.codes.CodesNSLCECodes identifying the channel (NET.STA.LOC.CHA.EXTRA) of the promised waveform.
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp)Start time of promised waveform.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp)End time of promised waveform.
- ♦ deltat¶
float, optionalSampling interval of promised waveform [s].
- ♦ source_hash¶
strHash identifying the remote source client providing this promise.
- property time_span¶
Get promise’s temporal span as
(tmin, tmax)tuple.
- exception InvalidWaveform[source]¶
Bases:
ExceptionRaised when a downloaded waveform fails validation, see
WaveformOrder.validate().
- class WaveformOrder(**kwargs)[source]¶
Bases:
ObjectWaveform request information.
- ♦ source_id¶
strId of remote source client to query, of the form
'client:<client-type>:<hash>', e.g.'client:fdsn:<hash>'.
- ♦ codes¶
pyrocko.model.codes.CodesNSLCECodes identifying the channel (NET.STA.LOC.CHA.EXTRA) to be downloaded.
- ♦ deltat¶
floatExpected sampling interval of the waveform to be downloaded [s].
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp)Start time of waveform to be downloaded.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp)End time of waveform to be downloaded.
- ♦ gaps¶
listoftupleof 2 pyrocko.util.get_time_float (pyrocko.guts.Timestamp) objects objects, default:[]List of
(tmin, tmax)time spans already locally available, to be excluded from the request when possible.
- ♦ time_created¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp)Time at which the order was created.
- ♦ anxious¶
float(pyrocko.guts.Duration), default:600.0Time span [s] before
tmaxwithin which the order is still considered to concern near-real-time data, seeis_near_real_time().
- key1()[source]¶
Get key identifying the order, including its source, for duplicate/repeat-order detection.
- key2()[source]¶
Get key identifying the order, without its source, e.g. for cross-client bookkeeping of already-satisfied requests.
- validate(tr)[source]¶
Check that a downloaded trace matches this order.
- Parameters:
tr (
Trace) – Downloaded waveform to be checked.- Raises:
InvalidWaveform – If the trace has no data samples, a sampling interval not matching
deltat, or non-finite data values.
- class Nut(file_path=None, file_format=None, file_mtime=None, file_size=None, file_segment=None, file_element=None, kind_id=0, codes=('',), tmin_seconds=None, tmin_offset=0, tmax_seconds=None, tmax_offset=0, deltat=None, content=None, raw_content=None, tmin=None, tmax=None, values_nocheck=None)[source]¶
Bases:
ObjectIndex entry referencing an elementary piece of content.
So-called nuts are used in Pyrocko’s Squirrel framework to hold common meta-information about individual pieces of waveforms, stations, channels, etc. together with the information where it was found or generated.
- ♦ file_path¶
str, optionalPath of file containing the referenced content.
- ♦ file_format¶
str, optionalContent type of file, as used by the Squirrel IO backends (e.g.
'mseed','stationxml','yaml').
- ♦ file_mtime¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalModification time of file, for change detection.
- ♦ file_size¶
int, optionalSize of file [bytes], for change detection.
- ♦ file_segment¶
int, optionalIndex of segment within file, for file formats where a single file can contain multiple segments.
- ♦ file_element¶
int, optionalIndex of content element within its segment, for content types where a segment may hold more than one element.
- ♦ kind_id¶
intContent type, one of the ids given in
g_content_kind_ids.
- ♦ codes¶
-
Codes identifying the content, of a subclass appropriate for the given content kind.
- ♦ tmin_seconds¶
int, default:0Full seconds part of start time of content, needed for fast database queries.
- ♦ tmin_offset¶
int, optional, default:0Fractional/high-precision part of start time of content (see
tsplit()).
- ♦ tmax_seconds¶
int, default:0Full seconds part of end time of content, needed for fast database queries.
- ♦ tmax_offset¶
int, optional, default:0Fractional/high-precision part of end time of content (see
tsplit()).
- ♦ deltat¶
float, default:0.0Sampling interval of content, if applicable, else
0.0[s].
- ♦ content¶
pyrocko.guts.Any, optionalThe actual content object represented by this nut, if attached.
- ♦ raw_content¶
dictofpyrocko.guts.Anyobjects, default:{}Additional, backend-specific raw content, keyed by content kind.
- get_io_backend()[source]¶
Get the Squirrel IO backend module responsible for
file_format.
- file_modified()[source]¶
Check if the referenced file appears to have changed since indexing, by comparing current vs. indexed modification time and size.
- Return type:
- property dkey¶
Get key used to index this nut in the database’s content table, as
(kind_id, tmin_seconds, tmin_offset, codes).
- property key¶
Get key identifying this nut’s file origin, as
(file_path, file_segment, file_element, file_mtime).
- property equality_values¶
Get values determining content equality (used by
__eq__), as(file_segment, file_element, kind_id, codes, tmin_seconds, tmin_offset, tmax_seconds, tmax_offset, deltat).
- diff(other)[source]¶
Get list of differing
equality_valuesfields between this and another nut.
- property tmin¶
Start time of content, joined from
tmin_seconds/tmin_offset(seetjoin()). Settable, splitting into those two fields (seetsplit()).
- property tmax¶
End time of content, joined from
tmax_seconds/tmax_offset(seetjoin()). Settable, splitting into those two fields (seetsplit()).
- property kscale¶
Time-block granularity index for this nut’s time span, used for indexing content at multiple scales (see
tscale_edgesanditer_nuts()’stscale_minparameter).
- property waveform_promise_kwargs¶
Get keyword arguments usable to create a
WaveformPromisefrom this nut’s meta-information.
- property station_kwargs¶
Get keyword arguments usable to create a
Stationfrom this nut’s meta-information.
- property channel_kwargs¶
Get keyword arguments usable to create a
Channelfrom this nut’s meta-information.
- property response_kwargs¶
Get keyword arguments usable to create a
Responsefrom this nut’s meta-information.
- property event_kwargs¶
Get keyword arguments usable to create a
Eventfrom this nut’s meta-information.
- property trace_kwargs¶
Get keyword arguments usable to create a
Tracematching this nut’s meta- information.Trace’stmaxis the time of the last sample whileNut’stmaxis one delta more to simplify continuity checks.
- property summary_entries¶
Get tuple of one-line summary values, for use with
fmt_summary().
- property summary¶
One-line summary of the nut.
- class DummyTrace(nut)[source]¶
Bases:
objectLightweight, meta-information-only stand-in for a
Trace, backed by aNut.Exposes the subset of
Trace’s interface (tmin,tmax,deltat,network/station/location/channel/extra,nslc_id,overlaps()) needed where a trace-like object is expected but no waveform data has been loaded, seeNut.dummy_trace.- overlaps(tmin, tmax)[source]¶
Check if the represented nut’s time span overlaps with a given time span.
- Parameters:
tmin (
get_time_float()) – Start time of query interval.tmax (
get_time_float()) – End time of query interval.
- Return type:
- class Coverage(**kwargs)[source]¶
Bases:
ObjectInformation about times covered by a waveform or other time series data.
- ♦ kind_id¶
int, optionalContent type.
- ♦ pattern¶
pyrocko.model.codes.Codes, optionalThe codes pattern in the request, which caused this entry to match.
- ♦ codes¶
pyrocko.model.codes.Codes, optionalNSLCE or NSL codes identifier of the time series.
- ♦ deltat¶
float, optionalSampling interval [s]
- ♦ tmin¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalGlobal start time of time series.
- ♦ tmax¶
pyrocko.util.get_time_float (
pyrocko.guts.Timestamp), optionalGlobal end time of time series.
- ♦ changes¶
listoftupleof 2pyrocko.guts.Anyobjects objects, optionalList of change points, with entries of the form
(time, count), where acountof zero indicates start of a gap, a value of 1 start of normal data coverage and a higher value duplicate or redundant data coverage.
- classmethod from_values(args)[source]¶
Create coverage object from a
(pattern, codes, deltat, tmin, tmax, changes, kind_id)tuple (internal use).
- property summary_entries¶
Get tuple of one-line summary values, for use with
fmt_summary().
- property summary¶
One-line summary of the coverage.
- property labels¶
Get
(codes, sample_rate)tuple of display labels, e.g. for use as plot annotations.
- iter_spans()[source]¶
Iterate over covered time spans.
- Yields:
(tmin, tmax, count)tuples, wherecountis the number of overlapping/redundant data pieces covering the span (1 for normal coverage, higher for duplicate/redundant data).
- iter_uncovered_by_combined(other)[source]¶
Like
iter_uncovered_by(), but merging adjacent spans belonging to the same gap inother.- Parameters:
other (
Coverage) – Coverage to compare against.- Yields:
(tmin, tmax)tuples.
- changes_as_arrays()[source]¶
Get
changesas a pair of NumPy arrays.- Returns:
(times, counts), or(None, None)ifchangesis unset.- Return type:
tupleof 2numpy.ndarray
- contiguous(tmin, tmax)[source]¶
Get coverage count for a time span, if constant throughout.
- Parameters:
tmin (
get_time_float()) – Start of time span to check.tmax (
get_time_float()) – End of time span to check.
- Returns:
The coverage count if it is constant across
[tmin, tmax], or-1if it changes within the span or is unknown.- Return type:
- get(time)[source]¶
Get coverage count at a given time instant.
- Parameters:
time (
get_time_float()) – Time instant to query.- Return type:
- join_coverages(coverages, tbleed=0.0)[source]¶
Combine several coverages into one, merging their change points.
- Parameters:
coverages (iterable of
Coverageobjects) – Coverages to be combined, e.g. of several channels belonging to the same sensor, for which overall combined data availability is of interest.tbleed (float) – Time interval to be removed at coverage edges and gaps [s]. This can be used, e.g. to track edge effect propagation through processing steps.
- Returns:
Combined coverage. Its
kind_id/deltatare set only if all input coverages agree on them, else left unset (None); itspattern/codesare always left unset.- Return type:
- Raises:
pyrocko.trace.NoData – If
coveragesis empty, or the combined time span is empty.
- make_rich_coverage(kinds, coverages)[source]¶
Combine several coverages of the same codes but different content kinds into one, encoding each kind’s coverage state in separate bits of the combined
changescounts.- Parameters:
kinds (
listofstr) – Content kinds to encode, in the order their coverage states are packed into the combined counts (2 bits per kind, low bit first, seeget_rich_coverage()for the kinds and their order used there).coverages (iterable of
Coverageobjects) – Coverages to be combined, all sharing the samecodes, of the content kinds given inkinds(any kind may be represented multiple times, or not at all).
- Returns:
Combined coverage with
kind_id=Noneand each change point’s count encoding, per kind,0for no coverage,1for normal coverage,2for duplicate/redundant coverage or3if the coverage state could not be determined (seechanges).- Return type: