pyrocko.squirrel.io.base

Squirrel core file reading and indexing.

Functions

detect_format(path)

Determine file type from first 512 bytes.

get_backend(fmt)

Get squirrel io backend module for a given file format.

iload(paths[, segment, format, database, ...])

Iteratively load content or index/reindex meta-information from files.

supported_content_kinds()

Get list of supported content kinds offered through Squirrel.

supported_formats()

Get list of file formats supported by Squirrel.

update_format_providers()

Update global mapping from file format to io backend module.

Exceptions

FormatDetectionFailed(path)

Exception raised when file format detection fails.

UnknownFormat(format)

Exception raised when user requests an unknown file format.

update_format_providers()[source]

Update global mapping from file format to io backend module.

exception FormatDetectionFailed(path)[source]

Bases: FileLoadError

Exception raised when file format detection fails.

exception UnknownFormat(format)[source]

Bases: Exception

Exception raised when user requests an unknown file format.

get_backend(fmt)[source]

Get squirrel io backend module for a given file format.

Parameters:

fmt (str) – Format identifier.

detect_format(path)[source]

Determine file type from first 512 bytes.

Parameters:

path (str) – Path to file.

supported_formats()[source]

Get list of file formats supported by Squirrel.

supported_content_kinds()[source]

Get list of supported content kinds offered through Squirrel.

iload(paths, segment=None, format='detect', database=None, check=True, skip_unchanged=False, content=['waveform', 'station', 'channel', 'response', 'event'], show_progress=True, update_selection=None)[source]

Iteratively load content or index/reindex meta-information from files.

Parameters:
  • paths (iterator yielding str or Selection) – Iterator yielding file names to load from or a Squirrel selection object providing the file names.

  • segment (int) – File-specific segment identifier (can only be used when loading from a single file).

  • format (str) – File format identifier or 'detect' for autodetection. When loading from a selection, per-file format assignation is taken from the hint in the selection and this flag is ignored.

  • database (Database) – Database to use for meta-information caching. When loading from a selection, this should be None and the database from the selection is used.

  • check (bool) – If True, investigate modification time and file sizes of known files to debunk modified files (pessimistic mode), or False to deactivate checks (optimistic mode).

  • skip_unchanged (bool) – If True, only yield index nuts for new / modified files.

  • content (list of str) – Selection of content types to load.

This generator yields Nut objects for individual pieces of information found when reading the given files. Such a nut may represent a waveform, a station, a channel, an event or other data type. The nut itself only contains the meta-information. The actual content information is attached to the nut if requested. All nut meta-information is stored in the squirrel meta-information database. If possible, this function avoids accessing the actual disk files and provides the requested information straight from the database. Modified files are recognized and reindexed as needed.