obspy.clients.filesystem.tsindex.Indexer

class Indexer(root_path, database='timeseries.sqlite', leap_seconds_file='SEARCH', index_cmd='mseedindex', bulk_params=None, filename_pattern='*', parallel=5, loglevel=None)[source]

Bases: object

Build an index for miniSEED data using EarthScope’s mseedindex program. Recursively search for files matching filename_pattern starting from root_path and run index_cmd for each target file found that is not already in the index. After all new files are indexed a summary table is generated with the extents of each timeseries.

Public Methods

build_file_list

Create a list of absolute paths to all files under root_path that match the filename_pattern.

download_leap_seconds_file

Attempt to download leap-seconds.list from Internet Engineering Task Force (IETF) and save to a file.

run

Execute the file discovery and indexing.

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

Indexer._download(url)[source]
Indexer._find_leap_seconds_file(leap_seconds_file=None, download=False, download_url=None)[source]

Search for leap seconds file and return path.

Parameters:
  • leap_seconds_file (str or None) – Leap seconds file location. If None a file location will be generated in same directory as a SQLite database location if present.

  • download (bool) – If download is True and any existing file has expired, a new file will be downloaded.

  • download_url (str or None) – URL to download from, passed to download_leap_seconds_file().

Indexer._get_leap_seconds_file(leap_seconds_file)[source]

Return path to leap second file and set appropriate environment variable for mseedindex.

Parameters:

leap_seconds_file (str or None) – Leap second file options defined in the Indexer constructor.

Indexer._get_rootpath_files(relative_paths=False)[source]

Return a list of absolute paths to files under the rootpath that match the Indexers filename pattern

Indexer._is_index_cmd_installed()[source]

Checks if the index command (e.g. mseedindex) is installed.

Return type:

bool

Returns:

Returns True if the index_cmd is installed.

Indexer._leap_seconds_file_expired(file_path)[source]

Test expiration status of specified leap seconds file.

The file is expected to be a leap-seconds.list as published by the Internet Engineering Task Force (IETF), which contains a line starting with #@ followed by the expiration time stamp in NTP format.

Parameters:

file_path (str) – Path to leap seconds file to test

Return type:

bool

Returns:

Expiration status of leap seconds file.

classmethod Indexer._run_index_command(index_cmd, root_path, file_name, bulk_params)[source]

Execute a command to perform indexing.

Parameters:
  • index_cmd (str) – Name of indexing command to execute. Defaults to mseedindex.

  • file_name (str) – Name of file to index.

  • bulk_params (dict) – Dictionary of options to pass to index_cmd.

Special Methods

Indexer.__delattr__(name, /)

Implement delattr(self, name).

Indexer.__dir__()

Default dir() implementation.

Indexer.__eq__(value, /)

Return self==value.

Indexer.__format__(format_spec, /)

Default object formatter.

Indexer.__ge__(value, /)

Return self>=value.

Indexer.__getattribute__(name, /)

Return getattr(self, name).

Indexer.__gt__(value, /)

Return self>value.

Indexer.__hash__()

Return hash(self).

Indexer.__init__(root_path, database='timeseries.sqlite', leap_seconds_file='SEARCH', index_cmd='mseedindex', bulk_params=None, filename_pattern='*', parallel=5, loglevel=None)[source]

Initializes the Indexer.

Parameters:
  • root_path (str) – Root path to the directory structure to index.

  • database (str or TSIndexDatabaseHandler) – Path to SQLite tsindex database or a TSIndexDatabaseHandler object. A database will be created if one does not already exists at the specified path.

  • leap_seconds_file (str) –

    Path to leap seconds file. If set to “SEARCH” (default), then the program looks for a leap seconds file in the same directory as the SQLite database. If set to “DOWNLOAD”, a leap seconds file will be downloaded from the IETF (if expired). If set to None then no leap seconds file will be used.

    In run() the leap seconds listed in this file will be used to adjust the time coverage for records that contain a leap second. Also, leap second indicators in the miniSEED headers will be ignored. See the `mseedindex wiki leap second

    ”master/doc/mseedindex.md#leap-second-list-file>`_ for more” “for more information regarding this file.

  • index_cmd (str) – Command to be run for each target file found that is not already in the index

  • bulk_params (dict) – Dictionary of options to pass to index_cmd.

  • filename_pattern (str) – Glob pattern to determine what files to index.

  • parallel (int) – Max number of index_cmd instances to run in parallel. By default a max of 5 parallel process are run.

Indexer.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

Indexer.__le__(value, /)

Return self<=value.

Indexer.__lt__(value, /)

Return self<value.

Indexer.__ne__(value, /)

Return self!=value.

Indexer.__new__(**kwargs)
Indexer.__reduce__()

Helper for pickle.

Indexer.__reduce_ex__(protocol, /)

Helper for pickle.

Indexer.__repr__()

Return repr(self).

Indexer.__setattr__(name, value, /)

Implement setattr(self, name, value).

Indexer.__sizeof__()

Size of object in memory, in bytes.

Indexer.__str__()

Return str(self).

Indexer.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).