pyrocko.squirrel.storage¶
Waveform data storage utilities.
Functions
|
Get a fresh copy of a named built-in storage scheme. |
|
Iterate over time windows covering a given time span. |
|
Get dict of path-template substitution variables for a time instant. |
Classes
|
Storage scheme for waveform archive data. |
|
Name of a supported storage scheme. |
|
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:
- 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
Noneto yield a single window covering[tmin, tmax].tinc_nonuniform (str) – If given,
tincis ignored and windows follow non-uniform calendar boundaries instead:'month'or'year'.
- Yields:
(wmin, wmax)tuples.- Raises:
SquirrelError – If
tinc_nonuniformis set to an unsupported value.
- class StorageSchemeLayout(**kwargs)[source]¶
Bases:
ObjectSpecific directory layout within a storage scheme.
- ♦ name¶
strName of the layout, informational.
- ♦ time_increment¶
float, optionalTime window length stored in each file[s]. Exact or approximate, depending on
time_increment_nonuniform.
- ♦ time_increment_nonuniform¶
str, optionalIdentifier for non-uniform time windows. E.g.
'month'or'year'.
- ♦ path_template¶
strTemplate for file paths.
- get_additional(wmin, wmax)[source]¶
Get path-template substitution variables for a time window.
- Parameters:
wmin (
get_time_float()) – Start of the window.wmax (
get_time_float()) – End of the window.
- Returns:
Combined
'wmin_*'and'wmax_*'variables, seetime_to_template_vars().- Return type:
- classmethod describe_header()[source]¶
Get column header line matching
describe()’s output, for display purposes.- Return type:
- 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).
- class StorageScheme(**kwargs)[source]¶
Bases:
ObjectStorage scheme for waveform archive data.
- ♦ name¶
strStorage scheme name.
- ♦ layouts¶
listofStorageSchemeLayoutobjects, default:[]Directory layouts supported by the scheme.
- ♦ min_segments_per_file¶
float, default:1.0Target 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), optionalMiniSEED record length [bytes] to use when saving. Default: 4096.
- ♦ mseed_steim¶
int(pyrocko.guts.IntChoice), optionalMiniSEED STEIM compression variant to use when saving,
1or2. Default: 2.
- set_base_path(base_path)[source]¶
Set base directory prepended to layout path templates.
- Parameters:
base_path (str) – Base directory path, or
Noneto 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
layoutswhosetime_incrementis large enough to holdmin_segments_per_filesegments at the given sampling interval (or has no time increment restriction), falling back to the last layout.- Return type:
- 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:
- class StorageSchemeChoice(...) str[source]¶
Bases:
StringChoiceName of a supported storage scheme.