Read Data from File

Module for reading seismic data from file.

Public API

read(fnames, obspy_read_kwargs=None, degrees_from_north=None, verbose=False)

Read seismic data file(s).

Parameters:
  • fnames (iterable of iterable of str or iterable of str) – Collection of file name(s) to be read. All entries should be readable by the function hvsrpy.read_single().

  • obspy_read_kwargs (dict or iterable of dicts, optional) – Keyword arguments to be passed directly to hvsrpy.read_single().

    If dict, keyword argument will be repeated for all file names provided.

    If iterable of dicts each keyword arguments will be provided in order.

    Default is None indicating standard read behavior will be used.

  • degrees_from_north (float or iterable of floats, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive.

    If float, it will be repeated for all file names provided.

    If iterable of floats each float will be provided in order.

    Default is None indicating either the metadata in the file denoting the sensor’s orientation is correct and should be used or (if the sensor’s orientation is not listed in the file) the sensor’s north component is aligned with magnetic north (i.e., degrees_from_north=0).

  • verbose (bool, optional) – If True information is provided about the attempts to read the file and the associated error(s). Can we useful for debugging a file that cannot be read. Default is False.

Returns:

list – Of initialized SeismicRecording3C objects, one for each each iterable entry provided.

read_single(fnames, obspy_read_kwargs=None, degrees_from_north=None, verbose=False)

Read file(s) associated with a single recording.

Parameters:
  • fnames ({list, str}) – File name(s) to be read.

    If str, name of file to be read, may include a relative or the full path. The file should contain all three components (2 horizontal and 1 vertical).

    If list, names of files to be read, each may be a relative or the full path. Each file should contain only one component.

  • obspy_read_kwargs (dict, optional) – Keyword arguments to be passed directly to obspy.read, in general this should not be needed, default is None indicating no custom arguments will be passed to obspy.read.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is None indicating either the metadata in the file denoting the sensor’s orientation is correct and should be used or (if the sensor’s orientation is not listed in the file) the sensor’s north component is aligned with magnetic north (i.e., degrees_from_north=0).

  • verbose (bool, optional) – If True information is provided about the attempts to read the file and the associated error(s). Can we useful for debugging a file that cannot be read. Default is False.

Returns:

SeismicRecording3C – Initialized three-component seismic recording object.

Private API

_read_mseed(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in miniSEED format.

Warning

Private API is subject to change without warning.

Parameters:
  • fnames ({str, list}) – If str then fnames is the name of the miniSEED file, full path may be used if desired. The file should contain three traces with the appropriate channel names. Refer to the SEED Manual. for specifics. If list then fnames is a list of length three with the names of miniSEED files for each component.

  • obspy_read_kwargs (dict, optional) – For passing arguments to the obspy.read function to customize its behavior, default is None indicating not keyword arguments will be passed.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.

_read_saf(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in SESAME ASCII format (SAF).

Warning

Private API is subject to change without warning.

Parameters:
  • fnames (str) – Name of the SESAME ASCII format file, full path may be used if desired. The file should contain three traces with the appropriate channel names. See SESAME standard.

  • obspy_read_kwargs (dict, optional) – Ignored, kept only to maintain consistency with other read functions.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.

_read_minishark(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in MiniShark format.

Warning

Private API is subject to change without warning.

Parameters:
  • fnames (str) – Name of the MiniShark format file, full path may be used if desired. The file should contain three traces with the appropriate channel names.

  • obspy_read_kwargs (dict, optional) – Ignored, kept only to maintain consistency with other read functions.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.

_read_sac(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in Seismic Analysis Code format.

Warning

Private API is subject to change without warning.

Parameters:
  • fnames (list) – List of length three with the names of the Seismic Analysis Code (SAC) format files; one per component. Files can be little endian or big endian. Each file should the appropriate channel names. See SAC manual.

  • obspy_read_kwargs (dict, optional) – For passing arguments to the obspy.read function to customize its behavior, default is None indicating no keyword arguments will be passed.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.

_read_gcf(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in Guralp Compressed Format (GCF).

Warning

Private API is subject to change without warning.

Parameters:
  • fnames (str) – Name of the MiniShark Guralp Compressed Format (GCF) file, full path may be used if desired. The file should contain three traces with the appropriate channel names.

  • obspy_read_kwargs (dict, optional) – For passing arguments to the obspy.read function to customize its behavior, default is None indicating no keyword arguments will be passed.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.

_read_peer(fnames, obspy_read_kwargs=None, degrees_from_north=None)

Read seismic data from file(s) in PEER format.

Warning

Private API is subject to change without warning.

Parameters:
  • fnames (list) – List of length three with the names of the Pacific Earthquake Engineering Research (PEER) format files; one per component. Each file should have appropriate channel names. Some information on the PEER format is provided by SCEC.

  • obspy_read_kwargs (dict, optional) – Ignored, kept only to maintain consistency with other read functions.

  • degrees_from_north (float, optional) – Rotation in degrees of the sensor’s north component relative to magnetic north; clock wise positive. Default is 0.0 indicating the sensor’s north component is aligned with magnetic north.

Returns:

SeismicRecording3C – Initialized 3-component seismic recording object.