Module io

Tools used for loading and writing a station database to and from disk. These functions are used in most scripts bundled with this package.

stdb.io.load_db(fname, binp=True, keys=None)

Submodule to read the station database from pickle or .csv file

Parameters:
  • fname (str) – File name. Assume csv format when ending in “.csv”

  • binp (bool) – Whether or not to use binary input (only for pickle files)

  • keys (List) – Default None If a list, then load database and select only keys that match those in this list. Returns the full db and a second optional output containing

Returns:

stdb – Instance of StDbElement

Return type:

StDbElement

stdb.io.write_db(fname, stdb, binp=True)

Submodule to write the station database to file

Parameters:
  • fname (str) – File name

  • stdb (StDbElement) – Instance of StDbElement

  • binp (bool) – Whether or not to use binary output

stdb.io.tocsv(stel)

Subroutine to output an StDbElement to a csv formatted string

Parameters:

stel (StDbElement) – Instance of StDbElement to convert to .csv

Returns:

csvstr – String representation of the csv content

Return type:

str

stdb.io.fromcsv(line='', lkey=False)

Subroutine to convert a csv format string into an StDbElement

Parameters:
  • line (str) – Line to read as csv

  • lkey (bool) – Parameter controlling the length of the key (with or without CHANNEL info)

Returns:

  • key (str) – Key associated with each entry in database

  • entry (StDbElement) – Instance of StDbElement class