pyrocko.squirrel.storage

Waveform data storage utilities.

Functions

get_storage_scheme([name])

Get a fresh copy of a named built-in storage scheme.

iter_windows(tmin, tmax, tinc, tinc_nonuniform)

Iterate over time windows covering a given time span.

time_to_template_vars(prefix, t)

Get dict of path-template substitution variables for a time instant.

Classes

StorageScheme(**kwargs)

Storage scheme for waveform archive data.

StorageSchemeChoice(...)

Name of a supported storage scheme.

StorageSchemeLayout(**kwargs)

Specific directory layout within a storage scheme.

time_to_template_vars(prefix, t)[source]

Get dict of path-template substitution variables for a time instant.

Parameters:
  • prefix (str) – Prefix to prepend to each generated variable name (e.g. 'wmin' or 'wmax').

  • t (get_time_float()) – Time instant to be converted.

Returns:

Dict with keys '<prefix>_year', '<prefix>_month', '<prefix>_day', '<prefix>_jday', '<prefix>_hour', '<prefix>_minute', '<prefix>_second' and (for backwards compatibility) '<prefix>'.

Return type:

dict

iter_windows(tmin, tmax, tinc, tinc_nonuniform)[source]

Iterate over time windows covering a given time span.

Parameters:
  • tmin (get_time_float()) – Start of the time span to be covered.

  • tmax (get_time_float()) – End of the time span to be covered.

  • tinc (float) – Window length [s], or None to yield a single window covering [tmin, tmax].

  • tinc_nonuniform (str) – If given, tinc is ignored and windows follow non-uniform calendar boundaries instead: 'month' or 'year'.

Yields:

(wmin, wmax) tuples.

Raises:

SquirrelError – If tinc_nonuniform is set to an unsupported value.

class StorageSchemeLayout(**kwargs)[source]

Bases: Object

Specific directory layout within a storage scheme.

♦ name

str

Name of the layout, informational.

♦ time_increment

float, optional

Time window length stored in each file[s]. Exact or approximate, depending on time_increment_nonuniform.

♦ time_increment_nonuniform

str, optional

Identifier for non-uniform time windows. E.g. 'month' or 'year'.

♦ path_template

str

Template for file paths.

get_additional(wmin, wmax)[source]

Get path-template substitution variables for a time window.

Parameters:
Returns:

Combined 'wmin_*' and 'wmax_*' variables, see time_to_template_vars().

Return type:

dict

classmethod describe_header()[source]

Get column header line matching describe()’s output, for display purposes.

Return type:

str

describe(deltat)[source]

Get one-line summary of file sizing for a given sampling interval, for display purposes (see describe_header() for the matching column header).

Parameters:

deltat (float) – Sampling interval [s] to describe file sizing for.

Return type:

str

class StorageScheme(**kwargs)[source]

Bases: Object

Storage scheme for waveform archive data.

♦ name

str

Storage scheme name.

♦ layouts

list of StorageSchemeLayout objects, default: []

Directory layouts supported by the scheme.

♦ min_segments_per_file

float, default: 1.0

Target minimum number of segments to be stored in each file.

♦ format

str, default: 'mseed'

File format of waveform data files.

♦ description

str, default: ''

Description of the storage scheme.

♦ mseed_record_length

int (pyrocko.guts.IntChoice), optional

MiniSEED record length [bytes] to use when saving. Default: 4096.

♦ mseed_steim

int (pyrocko.guts.IntChoice), optional

MiniSEED STEIM compression variant to use when saving, 1 or 2. Default: 2.

post_init()[source]

Guts post-initialization hook, setting up the (unset) base path.

set_base_path(base_path)[source]

Set base directory prepended to layout path templates.

Parameters:

base_path (str) – Base directory path, or None to use path templates as-is.

select_layout(deltat)[source]

Select the most appropriate directory layout for a given sampling interval.

Parameters:

deltat (float) – Sampling interval [s] to select a layout for.

Returns:

The first of layouts whose time_increment is large enough to hold min_segments_per_file segments at the given sampling interval (or has no time increment restriction), falling back to the last layout.

Return type:

StorageSchemeLayout

get_storage_scheme(name='default')[source]

Get a fresh copy of a named built-in storage scheme.

Parameters:

name (str) – Name of the storage scheme, see StorageSchemeChoice.

Return type:

StorageScheme

class StorageSchemeChoice(...) → str[source]

Bases: StringChoice

Name of a supported storage scheme.