Coverage for /opt/obspy/update-docs/src/obspy/obspy/sac/core : 97%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- SAC bindings to ObsPy core module.
:copyright: The ObsPy Development Team (devs@obspy.org) & C. J. Ammon :license: GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html) """
""" Checks whether a file is a SAC file or not.
:type filename: string :param filename: SAC file to be checked. :rtype: bool :return: ``True`` if a SAC file.
.. rubric:: Example
>>> isSAC('/path/to/test.sac') #doctest: +SKIP """ # 70 header floats, 9 position in header integers # check file size # check if file is big-endian # File-size and theoretical size inconsistent!
""" Checks whether a file is alphanumeric SAC file or not.
:type filename: string :param filename: Alphanumeric SAC file to be checked. :rtype: bool :return: ``True`` if a alphanumeric SAC file.
.. rubric:: Example
>>> isSACXY('/path/to/testxy.sac') #doctest: +SKIP """ ### First find out if it is a text or a binary file. This should ### always be true if a file is a text-file and only true for a ### binary file in rare occasions (Recipe 173220 found on ### http://code.activestate.com/ # read in the header cards # read in the seismogram # check that npts header value and seismogram length are consistent
**kwargs): # @UnusedVariable """ Reads an alphanumeric SAC file and returns an ObsPy Stream object.
.. warning:: This function should NOT be called directly, it registers via the ObsPy :func:`~obspy.core.stream.read` function, call this instead.
:type filename: str :param filename: Alphanumeric SAC file to be read. :type headonly: bool, optional :param headonly: If set to True, read only the head. This is most useful for scanning available data in huge (temporary) data sets. :type debug_headers: bool, optional :param debug_headers: Extracts also the SAC headers ``'nzyear', 'nzjday', 'nzhour', 'nzmin', 'nzsec', 'nzmsec', 'delta', 'scale', 'npts', 'knetwk', 'kstnm', 'kcmpnm'`` which are usually directly mapped to the :class:`~obspy.core.stream.Stream` object if set to ``True``. Those values are not synchronized with the Stream object itself and won't be used during writing of a SAC file! Defaults to ``False``. :rtype: :class:`~obspy.core.stream.Stream` :return: A ObsPy Stream object.
.. rubric:: Example
>>> from obspy import read # doctest: +SKIP >>> st = read("/path/to/testxy.sac") # doctest: +SKIP """ else: # assign all header entries to a new dictionary compatible with ObsPy
else:
""" Writes a alphanumeric SAC file.
.. warning:: This function should NOT be called directly, it registers via the the :meth:`~obspy.core.stream.Stream.write` method of an ObsPy :class:`~obspy.core.stream.Stream` object, call this instead.
:type stream: :class:`~obspy.core.stream.Stream` :param stream: The ObsPy Stream object to write. :type filename: str :param filename: Name of file to write.
.. rubric:: Example
>>> from obspy import read >>> st = read() >>> st.write("testxy.sac", format="SACXY") #doctest: +SKIP """ # Translate the common (renamed) entries filename = "%s%02d%s" % (base, i + 1, ext)
**kwargs): # @UnusedVariable """ Reads an SAC file and returns an ObsPy Stream object.
.. warning:: This function should NOT be called directly, it registers via the ObsPy :func:`~obspy.core.stream.read` function, call this instead.
:type filename: str :param filename: SAC file to be read. :type headonly: bool, optional :param headonly: If set to True, read only the head. This is most useful for scanning available data in huge (temporary) data sets. :type debug_headers: bool, optional :param debug_headers: Extracts also the SAC headers ``'nzyear', 'nzjday', 'nzhour', 'nzmin', 'nzsec', 'nzmsec', 'delta', 'scale', 'npts', 'knetwk', 'kstnm', 'kcmpnm'`` which are usually directly mapped to the :class:`~obspy.core.stream.Stream` object if set to ``True``. Those values are not synchronized with the Stream object itself and won't be used during writing of a SAC file! Defaults to ``False``. :rtype: :class:`~obspy.core.stream.Stream` :return: A ObsPy Stream object.
.. rubric:: Example
>>> from obspy import read # doctest: +SKIP >>> st = read("/path/to/test.sac") # doctest: +SKIP """ # read SAC file else: # assign all header entries to a new dictionary compatible with an ObsPy
else:
""" Writes a SAC file.
.. warning:: This function should NOT be called directly, it registers via the the :meth:`~obspy.core.stream.Stream.write` method of an ObsPy :class:`~obspy.core.stream.Stream` object, call this instead.
:type stream: :class:`~obspy.core.stream.Stream` :param stream: The ObsPy Stream object to write. :type filename: str :param filename: Name of file to write.
.. rubric:: Example
>>> from obspy import read >>> st = read() >>> st.write("test.sac", format="SAC") #doctest: +SKIP """ # Translate the common (renamed) entries filename = "%s%02d%s" % (base, i + 1, ext) |