Sharedsupport / 2017-08-29-packages.ipynbOpen in CoCalc
Author: William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
In [3]:
import obspy
In [7]:
help(obspy)
WARNING: some intermediate output was truncated.
Help on package obspy: NAME obspy DESCRIPTION ObsPy: A Python Toolbox for seismology/seismological observatories ================================================================== ObsPy is an open-source project dedicated to provide a Python framework for processing seismological data. It provides parsers for common file formats and seismological signal processing routines which allow the manipulation of seismological time series. The goal of the ObsPy project is to facilitate rapid application development for seismology. :copyright: The ObsPy Development Team ([email protected]) :license: GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html) PACKAGE CONTENTS clients (package) core (package) db (package) geodetics (package) imaging (package) io (package) lib (package) realtime (package) scripts (package) signal (package) taup (package) CLASSES builtins.object obspy.core.event.catalog.Catalog obspy.core.stream.Stream obspy.core.trace.Trace obspy.core.utcdatetime.UTCDateTime class Catalog(builtins.object) | This class serves as a container for Event objects. | | :type events: list of :class:`~obspy.core.event.event.Event`, optional | :param events: List of events | :type resource_id: :class:`~obspy.core.event.base.ResourceIdentifier` | :param resource_id: Resource identifier of the catalog. | :type description: str, optional | :param description: Description string that can be assigned to the | earthquake catalog, or collection of events. | :type comments: list of :class:`~obspy.core.event.base.Comment`, optional | :param comments: Additional comments. | :type creation_info: :class:`~obspy.core.event.base.CreationInfo`, optional | :param creation_info: Creation information used to describe author, | version, and creation time. | | .. note:: | | For handling additional information not covered by the QuakeML | standard and how to output it to QuakeML see the | :ref:`ObsPy Tutorial <quakeml-extra>`. | | Methods defined here: | | __add__(self, other) | Method to add two catalogs. | | __delitem__(self, index) | Passes on the __delitem__ method to the underlying list of traces. | | __eq__(self, other) | __eq__ method of the Catalog object. | | :type other: :class:`~obspy.core.event.Catalog` | :param other: Catalog object for comparison. | :rtype: bool | :return: ``True`` if both Catalogs contain the same events. | | .. rubric:: Example | | >>> from obspy.core.event import read_events | >>> cat = read_events() | >>> cat2 = cat.copy() | >>> cat is cat2 | False | >>> cat == cat2 | True | | __getitem__(self, index) | __getitem__ method of the Catalog object. | | :return: Event objects | | __getslice__(self, i, j, k=1) | __getslice__ method of the Catalog object. | | :return: Catalog object | | __iadd__(self, other) | Method to add two catalog with self += other. | | It will extend the current Catalog object with the events of the given | Catalog. Events will not be copied but references to the original | events will be appended. | | :type other: :class:`~obspy.core.event.Catalog` or | :class:`~obspy.core.event.event.Event` | :param other: Catalog or Event object to add. | | __init__(self, events=None, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) | Return a robust iterator for Events of current Catalog. | | Doing this it is safe to remove events from catalogs inside of | for-loops using catalog's :meth:`~obspy.core.event.Catalog.remove` | method. Actually this creates a new iterator every time a event is | removed inside the for-loop. | | __len__(self) | Returns the number of Events in the Catalog object. | | __ne__(self, other) | Return self!=value. | | __setitem__(self, index, event) | __setitem__ method of the Catalog object. | | __str__(self, print_all=False) | Returns short summary string of the current catalog. | | It will contain the number of Events in the Catalog and the return | value of each Event's :meth:`~obspy.core.event.event.Event.__str__` | method. | | :type print_all: bool, optional | :param print_all: If True, all events will be printed, otherwise a | maximum of ten event will be printed. | Defaults to False. | | append(self, event) | Appends a single Event object to the current Catalog object. | | clear(self) | Clears event list (convenient method). | | .. rubric:: Example | | >>> from obspy.core.event import read_events | >>> cat = read_events() | >>> len(cat) | 3 | >>> cat.clear() | >>> cat.events | [] | | copy(self) | Returns a deepcopy of the Catalog object. | | :rtype: :class:`~obspy.core.stream.Catalog` | :return: Copy of current catalog. | | .. rubric:: Examples | | 1. Create a Catalog and copy it | | >>> from obspy.core.event import read_events | >>> cat = read_events() | >>> cat2 = cat.copy() | | The two objects are not the same: | | >>> cat is cat2 | False | | But they have equal data: | | >>> cat == cat2 | True | | 2. The following example shows how to make an alias but not copy the | data. Any changes on ``st3`` would also change the contents of | ``st``. | | >>> cat3 = cat | >>> cat is cat3 | True | >>> cat == cat3 | True | | count = __len__(self) | | extend(self, event_list) | Extends the current Catalog object with a list of Event objects. | | filter(self, *args, **kwargs) | Returns a new Catalog object only containing Events which match the | specified filter rules. | | Valid filter keys are: | | * magnitude; | * longitude; | * latitude; | * depth; | * time; | * standard_error; | * azimuthal_gap; | * used_station_count; | * used_phase_count. | | Use ``inverse=True`` to return the Events that *do not* match the | specified filter rules. | | :rtype: :class:`Catalog` | :return: Filtered catalog. A new Catalog object with filtered | Events as references to the original Events. | | .. rubric:: Example | | >>> from obspy.core.event import read_events | >>> cat = read_events() | >>> print(cat) | 3 Event(s) in Catalog: | 2012-04-04T14:21:42.300000Z | +41.818, +79.689 | 4.4 mb | manual | 2012-04-04T14:18:37.000000Z | +39.342, +41.044 | 4.3 ML | manual | 2012-04-04T14:08:46.000000Z | +38.017, +37.736 | 3.0 ML | manual | >>> cat2 = cat.filter("magnitude >= 4.0", "latitude < 40.0") | >>> print(cat2) | 1 Event(s) in Catalog: | 2012-04-04T14:18:37.000000Z | +39.342, +41.044 | 4.3 ML | manual | >>> cat3 = cat.filter("time > 2012-04-04T14:10", | ... "time < 2012-04-04T14:20") | >>> print(cat3) | 1 Event(s) in Catalog: | 2012-04-04T14:18:37.000000Z | +39.342, +41.044 | 4.3 ML | manual | >>> cat4 = cat.filter("time > 2012-04-04T14:10", | ... "time < 2012-04-04T14:20", | ... inverse=True) | >>> print(cat4) | 2 Event(s) in Catalog: | 2012-04-04T14:21:42.300000Z | +41.818, +79.689 | 4.4 mb | manual | 2012-04-04T14:08:46.000000Z | +38.017, +37.736 | 3.0 ML | manual | | plot(self, projection='global', resolution='l', continent_fill_color='0.9', water_fill_color='1.0', label='magnitude', color='depth', colormap=None, show=True, outfile=None, method=None, fig=None, title=None, **kwargs) | Creates preview map of all events in current Catalog object. | | :type projection: str, optional | :param projection: The map projection. Currently supported are: | | * ``"global"`` (Will plot the whole world.) | * ``"ortho"`` (Will center around the mean lat/long.) | * ``"local"`` (Will plot around local events) | | Defaults to "global" | :type resolution: str, optional | :param resolution: Resolution of the boundary database to use. Will be | based directly to the basemap module. Possible values are: | | * ``"c"`` (crude) | * ``"l"`` (low) | * ``"i"`` (intermediate) | * ``"h"`` (high) | * ``"f"`` (full) | | Defaults to ``"l"`` | :type continent_fill_color: Valid matplotlib color, optional | :param continent_fill_color: Color of the continents. Defaults to | ``"0.9"`` which is a light gray. | :type water_fill_color: Valid matplotlib color, optional | :param water_fill_color: Color of all water bodies. | Defaults to ``"white"``. | :type label: str, optional | :param label: Events will be labelled based on the chosen property. | Possible values are: | | * ``"magnitude"`` | * ``None`` | | Defaults to ``"magnitude"`` | :type color: str, optional | :param color: The events will be color-coded based on the chosen | property. Possible values are: | | * ``"date"`` | * ``"depth"`` | | Defaults to ``"depth"`` | :type colormap: str, any matplotlib colormap, optional | :param colormap: The colormap for color-coding the events. | The event with the smallest property will have the | color of one end of the colormap and the event with the biggest | property the color of the other end with all other events in | between. | Defaults to None which will use the default colormap for the date | encoding and a colormap going from green over yellow to red for the | depth encoding. | :type show: bool | :param show: Whether to show the figure after plotting or not. Can be | used to do further customization of the plot before | showing it. Has no effect if `outfile` is specified. | :type outfile: str | :param outfile: Output file path to directly save the resulting image | (e.g. ``"/tmp/image.png"``). Overrides the ``show`` option, image | will not be displayed interactively. The given path/filename is | also used to automatically determine the output format. Supported | file formats depend on your matplotlib backend. Most backends | support png, pdf, ps, eps and svg. Defaults to ``None``. | The figure is closed after saving it to file. | :type method: str | :param method: Method to use for plotting. Possible values are: | | * ``'basemap'`` to use the Basemap library | * ``'cartopy'`` to use the Cartopy library | * ``None`` to pick the best available library | | Defaults to ``None``. | :type fig: :class:`matplotlib.figure.Figure` (or | :class:`matplotlib.axes.Axes`) | :param fig: Figure instance to reuse, returned from a previous | inventory/catalog plot call with `method=basemap`. | If a previous basemap plot is reused, any kwargs regarding the | basemap plot setup will be ignored (i.e. `projection`, | `resolution`, `continent_fill_color`, `water_fill_color`). Note | that multiple plots using colorbars likely are problematic, but | e.g. one station plot (without colorbar) and one event plot (with | colorbar) together should work well. | If an :class:`~matplotlib.axes.Axes` is supplied, the given axes is | used to plot into and no colorbar will be produced. | :type title: str | :param title: Title above plot. If left ``None``, an automatic title | will be generated. Set to ``""`` for no title. | :returns: Figure instance with the plot. | | .. rubric:: Examples | | Mollweide projection for global overview: | | >>> from obspy import read_events | >>> cat = read_events() | >>> cat.plot() # doctest:+SKIP | | .. plot:: | | from obspy import read_events | cat = read_events() | cat.plot() | | Orthographic projection: | | >>> cat.plot(projection="ortho") # doctest:+SKIP | | .. plot:: | | from obspy import read_events | cat = read_events() | cat.plot(projection="ortho") | | Local (Albers equal area) projection: | | >>> cat.plot(projection="local") # doctest:+SKIP | | .. plot:: | | from obspy import read_events | cat = read_events() | cat.plot(projection="local") | | Combining a station and event plot (uses basemap): | | >>> from obspy import read_inventory, read_events | >>> inv = read_inventory() | >>> cat = read_events() | >>> fig = inv.plot(method=basemap, show=False) # doctest:+SKIP | >>> cat.plot(method=basemap, fig=fig) # doctest:+SKIP | | .. plot:: | | from obspy import read_inventory, read_events | inv = read_inventory() | cat = read_events() | fig = inv.plot(show=False) | cat.plot(fig=fig) | | write(self, filename, format, **kwargs) | Saves catalog into a file. | | :type filename: str | :param filename: The name of the file to write. | :type format: str | :param format: The file format to use (e.g. ``"QUAKEML"``). See the | `Supported Formats`_ section below for a list of supported formats. | :param kwargs: Additional keyword arguments passed to the underlying | plugin's writer method. | | .. rubric:: Example | | >>> from obspy.core.event import read_events | >>> catalog = read_events() # doctest: +SKIP | >>> catalog.write("example.xml", format="QUAKEML") # doctest: +SKIP | | Writing single events into files with meaningful filenames can be done | e.g. using event.id | | >>> for ev in catalog: # doctest: +SKIP | ... filename = str(ev.resource_id) + ".xml" | ... ev.write(filename, format="QUAKEML") # doctest: +SKIP | | .. rubric:: _`Supported Formats` | | Additional ObsPy modules extend the parameters of the | :meth:`~obspy.core.event.Catalog.write` method. The following | table summarizes all known formats currently available for ObsPy. | | Please refer to the `Linked Function Call`_ of each module for any | extra options available. | | =========== =========================== ==================================================== | Format Required Module _`Linked Function Call` | =========== =========================== ==================================================== | CMTSOLUTION :mod:`obspy.io.cmtsolution` :func:`obspy.io.cmtsolution.core._write_cmtsolution` | CNV :mod:`obspy.io.cnv` :func:`obspy.io.cnv.core._write_cnv` | JSON :mod:`obspy.io.json` :func:`obspy.io.json.core._write_json` | KML :mod:`obspy.io.kml` :func:`obspy.io.kml.core._write_kml` | NLLOC_OBS :mod:`obspy.io.nlloc` :func:`obspy.io.nlloc.core.write_nlloc_obs` | QUAKEML :mod:`obspy.io.quakeml` :func:`obspy.io.quakeml.core._write_quakeml` | SHAPEFILE :mod:`obspy.io.shapefile` :func:`obspy.io.shapefile.core._write_shapefile` | ZMAP :mod:`obspy.io.zmap` :func:`obspy.io.zmap.core._write_zmap` | =========== =========================== ==================================================== | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | creation_info | | resource_id | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None class Stream(builtins.object) | List like object of multiple ObsPy Trace objects. | | :type traces: list of :class:`~obspy.core.trace.Trace`, optional | :param traces: Initial list of ObsPy :class:`~obspy.core.trace.Trace` | objects. | | .. rubric:: Basic Usage | | >>> trace1 = Trace() | >>> trace2 = Trace() | >>> stream = Stream(traces=[trace1, trace2]) | >>> print(stream) # doctest: +ELLIPSIS | 2 Trace(s) in Stream: | ... | | .. rubric:: Supported Operations | | ``stream = streamA + streamB`` | Merges all traces within the two Stream objects ``streamA`` and | ``streamB`` into the new Stream object ``stream``. | See also: :meth:`Stream.__add__`. | ``stream += streamA`` | Extends the Stream object ``stream`` with all traces from ``streamA``. | See also: :meth:`Stream.__iadd__`. | ``len(stream)`` | Returns the number of Traces in the Stream object ``stream``. | See also: :meth:`Stream.__len__`. | ``str(stream)`` | Contains the number of traces in the Stream object and returns the | value of each Trace's __str__ method. | See also: :meth:`Stream.__str__`. | | Methods defined here: | | __add__(self, other) | Add two streams or a stream with a single trace. | | :type other: :class:`~obspy.core.stream.Stream` or | :class:`~obspy.core.trace.Trace` | :param other: Stream or Trace object to add. | :rtype: :class:`~obspy.core.stream.Stream` | :returns: New Stream object containing references to the traces of the | original streams | | .. rubric:: Examples | | 1. Adding two Streams | | >>> st1 = Stream([Trace(), Trace(), Trace()]) | >>> len(st1) | 3 | >>> st2 = Stream([Trace(), Trace()]) | >>> len(st2) | 2 | >>> stream = st1 + st2 | >>> len(stream) | 5 | | 2. Adding Stream and Trace | | >>> stream2 = st1 + Trace() | >>> len(stream2) | 4 | | __delitem__(self, index) | Passes on the __delitem__ method to the underlying list of traces. | | __eq__(self, other) | Implements rich comparison of Stream objects for "==" operator. | | :type other: :class:`~obspy.core.stream.Stream` | :param other: Stream object for comparison. | :rtype: bool | :return: ``True`` if both Streams contain the same traces, i.e. after a | sort operation going through both streams every trace should be | equal according to Trace's | :meth:`~obspy.core.trace.Trace.__eq__` operator. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st2 = st.copy() | >>> st is st2 | False | >>> st == st2 | True | | __ge__(self, other) | Too ambiguous, throw an Error. | | __getitem__(self, index) | __getitem__ method of obspy.Stream objects. | | :return: Trace objects | | __getslice__(self, i, j, k=1) | __getslice__ method of obspy.Stream objects. | | :return: Stream object | | __gt__(self, other) | Too ambiguous, throw an Error. | | __iadd__(self, other) | Add two streams with self += other. | | It will extend the current Stream object with the traces of the given | Stream. Traces will not be copied but references to the original traces | will be appended. | | :type other: :class:`~obspy.core.stream.Stream` or | :class:`~obspy.core.trace.Trace` | :param other: Stream or Trace object to add. | | .. rubric:: Example | | >>> stream = Stream([Trace(), Trace(), Trace()]) | >>> len(stream) | 3 | | >>> stream += Stream([Trace(), Trace()]) | >>> len(stream) | 5 | | >>> stream += Trace() | >>> len(stream) | 6 | | __init__(self, traces=None) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) | Return a robust iterator for stream.traces. | | Doing this it is safe to remove traces from streams inside of | for-loops using stream's :meth:`~obspy.core.stream.Stream.remove` | method. Actually this creates a new iterator every time a trace is | removed inside the for-loop. | | .. rubric:: Example | | >>> from obspy import Stream | >>> st = Stream() | >>> for component in ["1", "Z", "2", "3", "Z", "N", "E", "4", "5"]: | ... channel = "EH" + component | ... tr = Trace(header={'station': 'TEST', 'channel': channel}) | ... st.append(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 9 Trace(s) in Stream: | .TEST..EH1 | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHZ | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EH2 | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EH3 | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHZ | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHN | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHE | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EH4 | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EH5 | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | | >>> for tr in st: | ... if tr.stats.channel[-1] not in ["Z", "N", "E"]: | ... st.remove(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 4 Trace(s) in Stream: | .TEST..EHZ | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHZ | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHN | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | .TEST..EHE | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples | | __le__(self, other) | Too ambiguous, throw an Error. | | __len__(self) | Return the number of Traces in the Stream object. | | .. rubric:: Example | | >>> stream = Stream([Trace(), Trace(), Trace()]) | >>> len(stream) | 3 | | __lt__(self, other) | Too ambiguous, throw an Error. | | __mul__(self, num) | Create a new Stream containing num copies of this stream. | | :rtype num: int | :param num: Number of copies. | :returns: New ObsPy Stream object. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> len(st) | 3 | >>> st2 = st * 5 | >>> len(st2) | 15 | | __ne__(self, other) | Implements rich comparison of Stream objects for "!=" operator. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st2 = st.copy() | >>> st is st2 | False | >>> st != st2 | False | | __nonzero__(self) | A Stream is considered zero if has no Traces. | | __setitem__(self, index, trace) | __setitem__ method of obspy.Stream objects. | | __str__(self, extended=False) | Return short summary string of the current stream. | | It will contain the number of Traces in the Stream and the return value | of each Trace's :meth:`~obspy.core.trace.Trace.__str__` method. | | :type extended: bool, optional | :param extended: This method will show only 20 traces by default. | Enable this option to show all entries. | | .. rubric:: Example | | >>> stream = Stream([Trace(), Trace()]) | >>> print(stream) # doctest: +ELLIPSIS | 2 Trace(s) in Stream: | ... | | append(self, trace) | Append a single Trace object to the current Stream object. | | :param trace: :class:`~obspy.core.stream.Trace` object. | | .. rubric:: Example | | >>> from obspy import read, Trace | >>> st = read() | >>> tr = Trace() | >>> tr.stats.station = 'TEST' | >>> st.append(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 4 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | .TEST.. | 1970-01-01T00:00:00.000000Z ... | 1.0 Hz, 0 samples | | attach_response(self, inventories) | Search for and attach channel response to each trace as | trace.stats.response. Does not raise an exception but shows a warning | if response information can not be found for all traces. Returns a | list of traces for which no response could be found. | To subsequently deconvolve the instrument response use | :meth:`Stream.remove_response`. | | >>> from obspy import read, read_inventory | >>> st = read() | >>> inv = read_inventory() | >>> st.attach_response(inv) | [] | >>> tr = st[0] | >>> print(tr.stats.response) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE | Channel Response | From M/S (Velocity in Meters per Second) to COUNTS (Digital Counts) | Overall Sensitivity: 2.5168e+09 defined at 0.020 Hz | 4 stages: | Stage 1: PolesZerosResponseStage from M/S to V, gain: 1500 | Stage 2: CoefficientsTypeResponseStage from V to COUNTS, ... | Stage 3: FIRResponseStage from COUNTS to COUNTS, gain: 1 | Stage 4: FIRResponseStage from COUNTS to COUNTS, gain: 1 | | :type inventories: :class:`~obspy.core.inventory.inventory.Inventory` | or :class:`~obspy.core.inventory.network.Network` or a list | containing objects of these types. | :param inventories: Station metadata to use in search for response for | each trace in the stream. | :rtype: list of :class:`~obspy.core.trace.Trace` | :returns: list of traces for which no response information could be | found. | | clear(self) | Clear trace list (convenience method). | | Replaces Stream's trace list by an empty one creating an empty | Stream object. Useful if there are references to the current | Stream object that should not break. Otherwise simply use a new | Stream() instance. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> len(st) | 3 | >>> st.clear() # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.traces | [] | | copy(self) | Return a deepcopy of the Stream object. | | :rtype: :class:`~obspy.core.stream.Stream` | :return: Copy of current stream. | | .. rubric:: Examples | | 1. Create a Stream and copy it | | >>> from obspy import read | >>> st = read() | >>> st2 = st.copy() | | The two objects are not the same: | | >>> st is st2 | False | | But they have equal data (before applying further processing): | | >>> st == st2 | True | | 2. The following example shows how to make an alias but not copy the | data. Any changes on ``st3`` would also change the contents of | ``st``. | | >>> st3 = st | >>> st is st3 | True | >>> st == st3 | True | | count = __len__(self) | | cutout(self, starttime, endtime) | Cut the given time range out of all traces of this Stream object. | | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param starttime: Start of time span to remove from stream. | :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param endtime: End of time span to remove from stream. | | .. rubric:: Example | | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> t1 = UTCDateTime("2009-08-24T00:20:06") | >>> t2 = UTCDateTime("2009-08-24T00:20:11") | >>> st.cutout(t1, t2) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 6 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 301 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 301 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 301 samples | BW.RJOB..EHZ | 2009-08-24T00:20:11.000000Z ... | 100.0 Hz, 2200 samples | BW.RJOB..EHN | 2009-08-24T00:20:11.000000Z ... | 100.0 Hz, 2200 samples | BW.RJOB..EHE | 2009-08-24T00:20:11.000000Z ... | 100.0 Hz, 2200 samples | | decimate(self, factor, no_filter=False, strict_length=False) | Downsample data in all traces of stream by an integer factor. | | :type factor: int | :param factor: Factor by which the sampling rate is lowered by | decimation. | :type no_filter: bool, optional | :param no_filter: Deactivates automatic filtering if set to ``True``. | Defaults to ``False``. | :type strict_length: bool, optional | :param strict_length: Leave traces unchanged for which end time of | trace would change. Defaults to ``False``. | | Currently a simple integer decimation is implemented. | Only every decimation_factor-th sample remains in the trace, all other | samples are thrown away. Prior to decimation a lowpass filter is | applied to ensure no aliasing artifacts are introduced. The automatic | filtering can be deactivated with ``no_filter=True``. | | If the length of the data array modulo ``decimation_factor`` is not | zero then the end time of the trace is changing on sub-sample scale. To | abort downsampling in case of changing end times set | ``strict_length=True``. | | .. note:: | | The :class:`~Stream` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate` | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: Example | | For the example we switch off the automatic pre-filtering so that | the effect of the downsampling routine becomes clearer. | | >>> from obspy import Trace, Stream | >>> tr = Trace(data=np.arange(10)) | >>> st = Stream(traces=[tr]) | >>> tr.stats.sampling_rate | 1.0 | >>> tr.data | array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) | >>> st.decimate(4, strict_length=False, no_filter=True) | ... # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> tr.stats.sampling_rate | 0.25 | >>> tr.data | array([0, 4, 8]) | | detrend(self, type='simple') | Remove a trend from all traces. | | For details see the corresponding | :meth:`~obspy.core.trace.Trace.detrend` method of | :class:`~obspy.core.trace.Trace`. | | differentiate(self, method='gradient') | Differentiate all traces with respect to time. | | :type method: str, optional | :param method: Method to use for differentiation. Defaults to | ``'gradient'``. See the `Supported Methods`_ section below for | further details. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: _`Supported Methods` | | ``'gradient'`` | The gradient is computed using central differences in the interior | and first differences at the boundaries. The returned gradient | hence has the same shape as the input array. (uses | :func:`numpy.gradient`) | | extend(self, trace_list) | Extend the current Stream object with a list of Trace objects. | | :param trace_list: list of :class:`~obspy.core.trace.Trace` objects or | :class:`~obspy.core.stream.Stream`. | | .. rubric:: Example | | >>> from obspy import read, Trace | >>> st = read() | >>> tr1 = Trace() | >>> tr1.stats.station = 'TEST1' | >>> tr2 = Trace() | >>> tr2.stats.station = 'TEST2' | >>> st.extend([tr1, tr2]) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 5 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | .TEST1.. | 1970-01-01T00:00:00.000000Z ... | 1.0 Hz, 0 samples | .TEST2.. | 1970-01-01T00:00:00.000000Z ... | 1.0 Hz, 0 samples | | filter(self, type, **options) | Filter the data of all traces in the Stream. | | :type type: str | :param type: String that specifies which filter is applied (e.g. | ``"bandpass"``). See the `Supported Filter`_ section below for | further details. | :param options: Necessary keyword arguments for the respective filter | that will be passed on. (e.g. ``freqmin=1.0``, ``freqmax=20.0`` for | ``"bandpass"``) | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: _`Supported Filter` | | ``'bandpass'`` | Butterworth-Bandpass (uses :func:`obspy.signal.filter.bandpass`). | | ``'bandstop'`` | Butterworth-Bandstop (uses :func:`obspy.signal.filter.bandstop`). | | ``'lowpass'`` | Butterworth-Lowpass (uses :func:`obspy.signal.filter.lowpass`). | | ``'highpass'`` | Butterworth-Highpass (uses :func:`obspy.signal.filter.highpass`). | | ``'lowpass_cheby_2'`` | Cheby2-Lowpass (uses :func:`obspy.signal.filter.lowpass_cheby_2`). | | ``'lowpass_fir'`` (experimental) | FIR-Lowpass (uses :func:`obspy.signal.filter.lowpass_fir`). | | ``'remez_fir'`` (experimental) | Minimax optimal bandpass using Remez algorithm (uses | :func:`obspy.signal.filter.remez_fir`). | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st.filter("highpass", freq=1.0) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | st.filter("highpass", freq=1.0) | st.plot() | | getGaps(self, *args, **kwargs) | DEPRECATED: 'getGaps' has been renamed to | 'get_gaps'. Use that instead. | | get_gaps(self, min_gap=None, max_gap=None) | Determine all trace gaps/overlaps of the Stream object. | | :param min_gap: All gaps smaller than this value will be omitted. The | value is assumed to be in seconds. Defaults to None. | :param max_gap: All gaps larger than this value will be omitted. The | value is assumed to be in seconds. Defaults to None. | | The returned list contains one item in the following form for each gap/ | overlap: [network, station, location, channel, starttime of the gap, | end time of the gap, duration of the gap, number of missing samples] | | Please be aware that no sorting and checking of stations, channels, ... | is done. This method only compares the start and end times of the | Traces. | | .. rubric:: Example | | Our example stream has no gaps: | | >>> from obspy import read, UTCDateTime | >>> st = read() | >>> st.get_gaps() | [] | >>> st.print_gaps() # doctest: +ELLIPSIS | Source Last Sample ... | Total: 0 gap(s) and 0 overlap(s) | | So let's make a copy of the first trace and cut both so that we end up | with a gappy stream: | | >>> tr = st[0].copy() | >>> t = UTCDateTime("2009-08-24T00:20:13.0") | >>> st[0].trim(endtime=t) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.trim(starttime=t + 1) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> st.append(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.get_gaps()[0] # doctest: +SKIP | [['BW', 'RJOB', '', 'EHZ', UTCDateTime(2009, 8, 24, 0, 20, 13), | UTCDateTime(2009, 8, 24, 0, 20, 14), 1.0, 99]] | >>> st.print_gaps() # doctest: +ELLIPSIS | Source Last Sample ... | BW.RJOB..EHZ 2009-08-24T00:20:13.000000Z ... | Total: 1 gap(s) and 0 overlap(s) | | insert(self, position, object) | Insert either a single Trace or a list of Traces before index. | | :param position: The Trace will be inserted at position. | :param object: Single Trace object or list of Trace objects. | | integrate(self, method='cumtrapz', **options) | Integrate all traces with respect to time. | | For details see the corresponding | :meth:`~obspy.core.trace.Trace.integrate` method of | :class:`~obspy.core.trace.Trace`. | | :type method: str, optional | :param type: Method to use for integration. Defaults to | ``'cumtrapz'``. See :meth:`~obspy.core.trace.Trace.integrate` for | further details. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | interpolate(self, *args, **kwargs) | Interpolate all Traces in a Stream. | | For details see the corresponding | :meth:`~obspy.core.trace.Trace.interpolate` method of | :class:`~obspy.core.trace.Trace`. | | .. note:: | | The :class:`~Stream` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate` | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data will no longer be accessible afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | | >>> from obspy import read | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples | >>> st.interpolate(sampling_rate=111.1) # doctest: +ELLIPSIS | <obspy.core.stream.Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 111.1 Hz, 3332 samples | BW.RJOB..EHN | 2009-08-24T00:20:03... - ... | 111.1 Hz, 3332 samples | BW.RJOB..EHE | 2009-08-24T00:20:03... - ... | 111.1 Hz, 3332 samples | | max(self) | Get the values of the absolute maximum amplitudes of all traces in the | stream. See :meth:`~obspy.core.trace.Trace.max`. | | :return: List of values of absolute maxima of all traces | | .. rubric:: Example | | >>> from obspy import Trace, Stream | >>> tr1 = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr2 = Trace(data=np.array([0, -3, -9, 6, 4])) | >>> tr3 = Trace(data=np.array([0.3, -3.5, 9.0, 6.4, 4.3])) | >>> st = Stream(traces=[tr1, tr2, tr3]) | >>> st.max() | [9, -9, 9.0] | | merge(self, method=0, fill_value=None, interpolation_samples=0, **kwargs) | Merge ObsPy Trace objects with same IDs. | | :type method: int, optional | :param method: Methodology to handle overlaps/gaps of traces. Defaults | to ``0``. | See :meth:`obspy.core.trace.Trace.__add__` for details on | methods ``0`` and ``1``, | see :meth:`obspy.core.stream.Stream._cleanup` for details on | method ``-1``. Any merge operation performs a cleanup merge as | a first step (method ``-1``). | :type fill_value: int, float, str or ``None``, optional | :param fill_value: Fill value for gaps. Defaults to ``None``. Traces | will be converted to NumPy masked arrays if no value is given and | gaps are present. The value ``'latest'`` will use the latest value | before the gap. If value ``'interpolate'`` is provided, missing | values are linearly interpolated (not changing the data | type e.g. of integer valued traces). Not used for ``method=-1``. | :type interpolation_samples: int, optional | :param interpolation_samples: Used only for ``method=1``. It specifies | the number of samples which are used to interpolate between | overlapping traces. Default to ``0``. If set to ``-1`` all | overlapping samples are interpolated. | | Importing waveform data containing gaps or overlaps results into | a :class:`~obspy.core.stream.Stream` object with multiple traces having | the same identifier. This method tries to merge such traces inplace, | thus returning nothing. Merged trace data will be converted into a | NumPy :class:`~numpy.ma.MaskedArray` type if any gaps are present. This | behavior may be prevented by setting the ``fill_value`` parameter. | The ``method`` argument controls the handling of overlapping data | values. | | normalize(self, global_max=False) | Normalize all Traces in the Stream. | | By default all traces are normalized separately to their respective | absolute maximum. By setting ``global_max=True`` all traces get | normalized to the global maximum of all traces. | | :param global_max: If set to ``True``, all traces are normalized with | respect to the global maximum of all traces in the stream | instead of normalizing every trace separately. | | .. note:: | If ``data.dtype`` of a trace was integer it is changing to float. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: Example | | Make a Stream with two Traces: | | >>> from obspy import Trace, Stream | >>> tr1 = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr2 = Trace(data=np.array([0.3, -0.5, -0.8, 0.4, 0.3])) | >>> st = Stream(traces=[tr1, tr2]) | | All traces are normalized to their absolute maximum and processing | information is added: | | >>> st.normalize() # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st[0].data # doctest: +ELLIPSIS | array([ 0. , -0.33333333, 1. , 0.66666667, ...]) | >>> print(st[0].stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ... normalize(norm=None) | >>> st[1].data | array([ 0.375, -0.625, -1. , 0.5 , 0.375]) | >>> print(st[1].stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ...: normalize(norm=None) | | Now let's do it again normalize all traces to the stream's global | maximum: | | >>> tr1 = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr2 = Trace(data=np.array([0.3, -0.5, -0.8, 0.4, 0.3])) | >>> st = Stream(traces=[tr1, tr2]) | | >>> st.normalize(global_max=True) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st[0].data # doctest: +ELLIPSIS | array([ 0. , -0.33333333, 1. , 0.66666667, ...]) | >>> print(st[0].stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ...: normalize(norm=9) | >>> st[1].data # doctest: +ELLIPSIS | array([ 0.03333333, -0.05555556, -0.08888889, 0.04444444, ...]) | >>> print(st[1].stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ...: normalize(norm=9) | | plot(self, *args, **kwargs) | Create a waveform plot of the current ObsPy Stream object. | | :param outfile: Output file string. Also used to automatically | determine the output format. Supported file formats depend on your | matplotlib backend. Most backends support png, pdf, ps, eps and | svg. Defaults to ``None``. | :param format: Format of the graph picture. If no format is given the | outfile parameter will be used to try to automatically determine | the output format. If no format is found it defaults to png output. | If no outfile is specified but a format is, than a binary | imagestring will be returned. | Defaults to ``None``. | :param starttime: Start time of the graph as a | :class:`~obspy.core.utcdatetime.UTCDateTime` object. If not set | the graph will be plotted from the beginning. | Defaults to ``None``. | :param endtime: End time of the graph as a | :class:`~obspy.core.utcdatetime.UTCDateTime` object. If not set | the graph will be plotted until the end. | Defaults to ``None``. | :param fig: Use an existing matplotlib figure instance. | Defaults to ``None``. | :param automerge: If automerge is True, Traces with the same id will be | merged. | Defaults to ``True``. | :param size: Size tuple in pixel for the output file. This corresponds | to the resolution of the graph for vector formats. | Defaults to ``(800, 250)`` pixel per channel for ``type='normal'`` | or ``type='relative'``, ``(800, 600)`` for ``type='dayplot'``, and | ``(1000, 600)`` for ``type='section'``. | :param dpi: Dots per inch of the output file. This also affects the | size of most elements in the graph (text, linewidth, ...). | Defaults to ``100``. | :param color: Color of the graph as a matplotlib color string as | described below. If ``type='dayplot'`` a list/tuple of color | strings is expected that will be periodically repeated for each | line plotted. If ``type='section'`` then the values ``'network'``, | ``'station'`` or ``'channel'`` are also accepted, and traces will | be uniquely colored by the given information. | Defaults to ``'black'`` or to ``('#B2000F', '#004C12', '#847200', | '#0E01FF')`` for ``type='dayplot'``. | :param bgcolor: Background color of the graph. | Defaults to ``'white'``. | :param face_color: Face color of the matplotlib canvas. | Defaults to ``'white'``. | :param transparent: Make all backgrounds transparent (True/False). This | will override the ``bgcolor`` and ``face_color`` arguments. | Defaults to ``False``. | :param number_of_ticks: The number of ticks on the x-axis. | Defaults to ``4``. | :param tick_format: The way the time axis is formatted. | Defaults to ``'%H:%M:%S'`` or ``'%.2f'`` if ``type='relative'``. | :param tick_rotation: Tick rotation in degrees. | Defaults to ``0``. | :param handle: Whether or not to return the matplotlib figure instance | after the plot has been created. | Defaults to ``False``. | :param method: By default, all traces with more than 400,000 samples | will be plotted with a fast method that cannot be zoomed. | Setting this argument to ``'full'`` will straight up plot the data. | This results in a potentially worse performance but the interactive | matplotlib view can be used properly. | Defaults to 'fast'. | :param type: Type may be set to either: ``'normal'`` to produce the | standard plot; ``'dayplot'`` to create a one-day plot for a single | Trace; ``'relative'`` to convert all date/time information to a | relative scale starting the seismogram at 0 seconds; ``'section'`` | to plot all seismograms in a single coordinate system shifted | according to their distance from a reference point. Defaults to | ``'normal'``. | :param equal_scale: If enabled all plots are equally scaled. | Defaults to ``True``. | :param show: If True, show the plot interactively after plotting. This | is ignored if any of ``outfile``, ``format``, ``handle``, or | ``fig`` are specified. | Defaults to ``True``. | :param draw: If True, the figure canvas is explicitly re-drawn, which | ensures that *existing* figures are fresh. It makes no difference | for figures that are not yet visible. | Defaults to ``True``. | :param block: If True block call to showing plot. Only works if the | active matplotlib backend supports it. | Defaults to ``True``. | :param linewidth: Float value in points of the line width. | Defaults to ``1.0``. | :param linestyle: Line style. | Defaults to ``'-'`` | :param grid_color: Color of the grid. | Defaults to ``'black'``. | :param grid_linewidth: Float value in points of the grid line width. | Defaults to ``0.5``. | :param grid_linestyle: Grid line style. | Defaults to ``':'`` | | **Dayplot Parameters** | | The following parameters are only available if ``type='dayplot'`` is | set. | | :param vertical_scaling_range: Determines how each line is scaled in | its given space. Every line will be centered around its mean value | and then clamped to fit its given space. This argument is the range | in data units that will be used to clamp the data. If the range is | smaller than the actual range, the lines' data may overshoot to | other lines which is usually a desired effect. Larger ranges will | result in a vertical padding. | If ``0``, the actual range of the data will be used and no | overshooting or additional padding will occur. | If ``None`` the range will be chosen to be the 99.5-percentile of | the actual range - so some values will overshoot. | Defaults to ``None``. | :param interval: This defines the interval length in minutes for one | line. | Defaults to ``15``. | :param time_offset: Only used if ``type='dayplot'``. The difference | between the timezone of the data (specified with the kwarg | ``timezone``) and UTC time in hours. Will be displayed in a string. | Defaults to the current offset of the system time to UTC time. | :param timezone: Defines the name of the user defined time scale. Will | be displayed in a string together with the actual offset defined in | the kwarg ``time_offset``. | Defaults to ``'local time'``. | :param localization_dict: Enables limited localization of the dayplot | through the usage of a dictionary. To change the labels to, e.g. | German, use the following:: | | localization_dict={'time in': 'Zeit in', 'seconds': 'Sekunden', | 'minutes': 'Minuten', 'hours': 'Stunden'} | | :param data_unit: If given, the scale of the data will be drawn on the | right hand side in the form ``"%f {data_unit}"``. The unit is | supposed to be a string containing the actual unit of the data. Can | be a LaTeX expression if matplotlib has been built with LaTeX | support, e.g., ``"$\\frac{m}{s}$"``. Be careful to escape the | backslashes, or use r-prefixed strings, e.g., | ``r"$\\frac{m}{s}$"``. | Defaults to ``None``, meaning no scale is drawn. | :param events: An optional list of events can be drawn on the plot if | given. They will be displayed as yellow stars with optional | annotations. They are given as a list of dictionaries. Each | dictionary at least needs to have a "time" key, containing a | UTCDateTime object with the origin time of the event. Furthermore | every event can have an optional "text" key which will then be | displayed as an annotation. | Example:: | | events=[{"time": UTCDateTime(...), "text": "Event A"}, {...}] | | It can also be a :class:`~obspy.core.event.Catalog` object. In this | case each event will be annotated with its corresponding | Flinn-Engdahl region and the magnitude. | Events can also be automatically downloaded with the help of | obspy.clients.fdsn. Just pass a dictionary with a "min_magnitude" | key, e.g. :: | | events={"min_magnitude": 5.5} | | Defaults to ``[]``. | :param x_labels_size: Size of x labels in points or fontsize. | Defaults to ``8``. | :param y_labels_size: Size of y labels in points or fontsize. | Defaults to ``8``. | :param title_size: Size of the title in points or fontsize. | Defaults to ``10``. | :param subplots_adjust_left: The left side of the subplots of the | figure in fraction of the figure width. | Defaults to ``0.12``. | :param subplots_adjust_right: The right side of the subplots of the | figure in fraction of the figure width. | Defaults to ``0.88``. | :param subplots_adjust_top: The top side of the subplots of the figure | in fraction of the figure width. | Defaults to ``0.95``. | :param subplots_adjust_bottom: The bottom side of the subplots of the | figure in fraction of the figure width. | Defaults to ``0.1``. | :param right_vertical_labels: Whether or not to display labels on the | right side of the dayplot. | Defaults to ``False``. | :param one_tick_per_line: Whether or not to display one tick per line. | Defaults to ``False``. | :param show_y_UTC_label: Whether or not to display the Y UTC vertical | label. | Defaults to ``True``. | :param title: The title to display on top of the plot. | Defaults to ``self.stream[0].id``. | | **Section Parameters** | | These parameters are only available if ``type='section'`` is set. To | plot a record section the ObsPy header ``trace.stats.distance`` must be | defined in meters (Default). Or ``trace.stats.coordinates.latitude`` & | ``trace.stats.coordinates.longitude`` must be set if plotted in | azimuthal distances (``dist_degree=True``) along with ``ev_coord``. | | :type scale: float, optional | :param scale: Scale the traces width with this factor. | Defaults to ``1.0``. | :type vred: float, optional | :param vred: Perform velocity reduction, in m/s. | :type norm_method: str, optional | :param norm_method: Defines how the traces are normalized, either | against each ``trace`` or against the global maximum ``stream``. | Defaults to ``trace``. | :type offset_min: float or None, optional | :param offset_min: Minimum offset in meters to plot. | Defaults to minimum offset of all traces. | :type offset_max: float or None, optional | :param offset_max: Maximum offset in meters to plot. | Defaults to maximum offset of all traces. | :type dist_degree: bool, optional | :param dist_degree: Plot trace distance in degree from epicenter. If | ``True``, parameter ``ev_coord`` has to be defined. | Defaults to ``False``. | :type ev_coord: tuple or None, optional | :param ev_coord: Event's coordinates as tuple | ``(latitude, longitude)``. | :type plot_dx: int, optional | :param plot_dx: Spacing of ticks on the spatial x-axis. | Either m or degree, depending on ``dist_degree``. | :type recordstart: int or float, optional | :param recordstart: Seconds to crop from the beginning. | :type recordlength: int or float, optional | :param recordlength: Length of the record section in seconds. | :type alpha: float, optional | :param alpha: Transparency of the traces between 0.0 - 1.0. | Defaults to ``0.5``. | :type time_down: bool, optional | :param time_down: Flip the plot horizontally, time goes down. | Defaults to ``False``, i.e., time goes up. | :type reftime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param reftime: The reference time to which the time scale will refer. | Defaults to the minimum start time of the visible traces. | :type orientation: str, optional | :param orientation: The orientation of the time axis, either | ``'vertical'`` or ``'horizontal'``. Defaults to ``'vertical'``. | | **Relative Parameters** | | The following parameters are only available if ``type='relative'`` is | set. | | :type reftime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param reftime: The reference time to which the relative scale will | refer. | Defaults to ``starttime``. | | .. rubric:: Color Options | | Colors can be specified as defined in the :mod:`matplotlib.colors` | documentation. | | Short Version: For all color values, you can either use: | | * legal `HTML color names <https://www.w3.org/TR/css3-color/#html4>`_, | e.g. ``'blue'``, | * HTML hex strings, e.g. ``'#EE00FF'``, | * pass an string of a R, G, B tuple, where each of the components is a | float value in the range of 0 to 1, e.g. ``'(1, 0.25, 0.5)'``, or | * use single letters for the basic built-in colors, such as ``'b'`` | (blue), ``'g'`` (green), ``'r'`` (red), ``'c'`` (cyan), ``'m'`` | (magenta), ``'y'`` (yellow), ``'k'`` (black), ``'w'`` (white). | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | st.plot() | | pop(self, index=-1) | Remove and return the Trace object specified by index from the Stream. | | If no index is given, remove the last Trace. Passes on the pop() to | self.traces. | | :param index: Index of the Trace object to be returned and removed. | :returns: Removed Trace. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> tr = st.pop() | >>> print(st) # doctest: +ELLIPSIS | 2 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | printGaps(self, *args, **kwargs) | DEPRECATED: 'printGaps' has been renamed to | 'print_gaps'. Use that instead. | | print_gaps(self, min_gap=None, max_gap=None) | Print gap/overlap list summary information of the Stream object. | | :param min_gap: All gaps smaller than this value will be omitted. The | value is assumed to be in seconds. Defaults to None. | :param max_gap: All gaps larger than this value will be omitted. The | value is assumed to be in seconds. Defaults to None. | | .. rubric:: Example | | Our example stream has no gaps: | | >>> from obspy import read, UTCDateTime | >>> st = read() | >>> st.get_gaps() | [] | >>> st.print_gaps() # doctest: +ELLIPSIS | Source Last Sample Next Sample ... | Total: 0 gap(s) and 0 overlap(s) | | So let's make a copy of the first trace and cut both so that we end up | with a gappy stream: | | >>> tr = st[0].copy() | >>> t = UTCDateTime("2009-08-24T00:20:13.0") | >>> st[0].trim(endtime=t) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.trim(starttime=t+1) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> st.append(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.get_gaps() # doctest: +ELLIPSIS | [[..., UTCDateTime(2009, 8, 24, 0, 20, 13), ... | >>> st.print_gaps() # doctest: +ELLIPSIS | Source Last Sample ... | BW.RJOB..EHZ 2009-08-24T00:20:13.000000Z ... | Total: 1 gap(s) and 0 overlap(s) | | | And finally let us create some overlapping traces: | | >>> st = read() | >>> tr = st[0].copy() | >>> t = UTCDateTime("2009-08-24T00:20:13.0") | >>> st[0].trim(endtime=t) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.trim(starttime=t-1) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> st.append(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.get_gaps() # doctest: +ELLIPSIS | [[...'EHZ', UTCDateTime(2009, 8, 24, 0, 20, 13), ... | >>> st.print_gaps() # doctest: +ELLIPSIS | Source Last Sample ... | BW.RJOB..EHZ 2009-08-24T00:20:13.000000Z ... | Total: 0 gap(s) and 1 overlap(s) | | remove(self, trace) | Remove the first occurrence of the specified Trace object in the | Stream object. Passes on the remove() call to self.traces. | | :param trace: Trace object to be removed from Stream. | | .. rubric:: Example | | This example shows how to delete all "E" component traces in a stream: | | >>> from obspy import read | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> for tr in st.select(component="E"): | ... st.remove(tr) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 2 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | remove_response(self, *args, **kwargs) | Deconvolve instrument response for all Traces in Stream. | | For details see the corresponding | :meth:`~obspy.core.trace.Trace.remove_response` method of | :class:`~obspy.core.trace.Trace`. | | >>> from obspy import read, read_inventory | >>> st = read() | >>> inv = read_inventory() | >>> st.remove_response(inventory=inv) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read, read_inventory | st = read() | inv = read_inventory() | st.remove_response(inventory=inv) | st.plot() | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | | remove_sensitivity(self, *args, **kwargs) | Remove instrument sensitivity for all Traces in Stream. | | For details see the corresponding | :meth:`~obspy.core.trace.Trace.remove_sensitivity` method of | :class:`~obspy.core.trace.Trace`. | | >>> from obspy import read, read_inventory | >>> st = read() | >>> inv = read_inventory() | >>> st.remove_sensitivity(inv) # doctest: +ELLIPSIS | <...Stream object at 0x...> | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | | resample(self, sampling_rate, window='hanning', no_filter=True, strict_length=False) | Resample data in all traces of stream using Fourier method. | | :type sampling_rate: float | :param sampling_rate: The sampling rate of the resampled signal. | :type window: array_like, callable, str, float, or tuple, optional | :param window: Specifies the window applied to the signal in the | Fourier domain. Defaults ``'hanning'`` window. See | :func:`scipy.signal.resample` for details. | :type no_filter: bool, optional | :param no_filter: Deactivates automatic filtering if set to ``True``. | Defaults to ``True``. | :type strict_length: bool, optional | :param strict_length: Leave traces unchanged for which end time of | trace would change. Defaults to ``False``. | | .. note:: | | The :class:`~Stream` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate` | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | Uses :func:`scipy.signal.resample`. Because a Fourier method is used, | the signal is assumed to be periodic. | | .. rubric:: Example | | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> st.resample(10.0) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 10.0 Hz, 300 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 10.0 Hz, 300 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 10.0 Hz, 300 samples | | reverse(self) | Reverse the Traces of the Stream object in place. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> st.reverse() # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | rotate(self, method, back_azimuth=None, inclination=None) | Rotate stream objects. | | :type method: str | :param method: Determines the rotation method. | | ``'NE->RT'``: Rotates the North- and East-components of a | seismogram to radial and transverse components. | ``'RT->NE'``: Rotates the radial and transverse components of a | seismogram to North- and East-components. | ``'ZNE->LQT'``: Rotates from left-handed Z, North, and East system | to LQT, e.g. right-handed ray coordinate system. | ``'LQT->ZNE'``: Rotates from LQT, e.g. right-handed ray coordinate | system to left handed Z, North, and East system. | | :type back_azimuth: float, optional | :param back_azimuth: Depends on the chosen method. | A single float, the back azimuth from station to source in degrees. | If not given, ``stats.back_azimuth`` will be used. It will also be | written after the rotation is done. | :type inclination: float, optional | :param inclination: Inclination of the ray at the station in degrees. | Only necessary for three component rotations. If not given, | ``stats.inclination`` will be used. It will also be written after | the rotation is done. | | select(self, network=None, station=None, location=None, channel=None, sampling_rate=None, npts=None, component=None, id=None) | Return new Stream object only with these traces that match the given | stats criteria (e.g. all traces with ``channel="EHZ"``). | | .. rubric:: Examples | | >>> from obspy import read | >>> st = read() | >>> st2 = st.select(station="R*") | >>> print(st2) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | >>> st2 = st.select(id="BW.RJOB..EHZ") | >>> print(st2) # doctest: +ELLIPSIS | 1 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | >>> st2 = st.select(component="Z") | >>> print(st2) # doctest: +ELLIPSIS | 1 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | >>> st2 = st.select(network="CZ") | >>> print(st2) # doctest: +NORMALIZE_WHITESPACE | 0 Trace(s) in Stream: | | .. warning:: | A new Stream object is returned but the traces it contains are | just aliases to the traces of the original stream. Does not copy | the data but only passes a reference. | | All keyword arguments except for ``component`` are tested directly | against the respective entry in the :class:`~obspy.core.trace.Stats` | dictionary. | | If a string for ``component`` is given (should be a single letter) it | is tested against the last letter of the ``Trace.stats.channel`` entry. | | Alternatively, ``channel`` may have the last one or two letters | wildcarded (e.g. ``channel="EH*"``) to select all components with a | common band/instrument code. | | All other selection criteria that accept strings (network, station, | location) may also contain Unix style wildcards (``*``, ``?``, ...). | | simulate(self, paz_remove=None, paz_simulate=None, remove_sensitivity=True, simulate_sensitivity=True, **kwargs) | Correct for instrument response / Simulate new instrument response. | | :type paz_remove: dict, None | :param paz_remove: Dictionary containing keys ``'poles'``, ``'zeros'``, | ``'gain'`` (A0 normalization factor). Poles and zeros must be a | list of complex floating point numbers, gain must be of type float. | Poles and Zeros are assumed to correct to m/s, SEED convention. | Use ``None`` for no inverse filtering. | Use ``'self'`` to use paz AttribDict in ``trace.stats`` for every | trace in stream. | :type paz_simulate: dict, None | :param paz_simulate: Dictionary containing keys ``'poles'``, | ``'zeros'``, ``'gain'``. Poles and zeros must be a list of complex | floating point numbers, gain must be of type float. Or ``None`` for | no simulation. | :type remove_sensitivity: bool | :param remove_sensitivity: Determines if data is divided by | ``paz_remove['sensitivity']`` to correct for overall sensitivity of | recording instrument (seismometer/digitizer) during instrument | correction. | :type simulate_sensitivity: bool | :param simulate_sensitivity: Determines if data is multiplied with | ``paz_simulate['sensitivity']`` to simulate overall sensitivity of | new instrument (seismometer/digitizer) during instrument | simulation. | | This function corrects for the original instrument response given by | ``paz_remove`` and/or simulates a new instrument response given by | ``paz_simulate``. | | For additional information and more options to control the instrument | correction/simulation (e.g. water level, demeaning, tapering, ...) see | :func:`~obspy.signal.invsim.simulate_seismometer`. | | The keywords `paz_remove` and `paz_simulate` are expected to be | dictionaries containing information on poles, zeros and gain (and | usually also sensitivity). | | If both ``paz_remove`` and ``paz_simulate`` are specified, both steps | are performed in one go in the frequency domain, otherwise only the | specified step is performed. | | .. note:: | | Instead of the builtin deconvolution based on Poles and Zeros | information, the deconvolution can be performed using evalresp | instead by using the option `seedresp` (see documentation of | :func:`~obspy.signal.invsim.simulate_seismometer` and the | `ObsPy Tutorial | <https://docs.obspy.org/master/tutorial/code_snippets/seismometer_correction_simulation.html#using-a-resp-file>`_. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: Example | | >>> from obspy import read | >>> from obspy.signal.invsim import corn_freq_2_paz | >>> st = read() | >>> paz_sts2 = {'poles': [-0.037004+0.037016j, -0.037004-0.037016j, | ... -251.33+0j, | ... -131.04-467.29j, -131.04+467.29j], | ... 'zeros': [0j, 0j], | ... 'gain': 60077000.0, | ... 'sensitivity': 2516778400.0} | >>> paz_1hz = corn_freq_2_paz(1.0, damp=0.707) | >>> st.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz) | ... # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | from obspy.signal.invsim import corn_freq_2_paz | st = read() | paz_sts2 = {'poles': [-0.037004+0.037016j, -0.037004-0.037016j, | -251.33+0j, | -131.04-467.29j, -131.04+467.29j], | 'zeros': [0j, 0j], | 'gain': 60077000.0, | 'sensitivity': 2516778400.0} | paz_1hz = corn_freq_2_paz(1.0, damp=0.707) | paz_1hz['sensitivity'] = 1.0 | st.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz) | st.plot() | | slice(self, starttime=None, endtime=None, keep_empty_traces=False, nearest_sample=True) | Return new Stream object cut to the given start and end time. | | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param starttime: Specify the start time of all traces. | :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param endtime: Specify the end time of all traces. | :type keep_empty_traces: bool, optional | :param keep_empty_traces: Empty traces will be kept if set to ``True``. | Defaults to ``False``. | :type nearest_sample: bool, optional | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | :return: :class:`~obspy.core.stream.Stream` | | .. note:: | | The basic idea of :meth:`~obspy.core.stream.Stream.slice` | is to avoid copying the sample data in memory. So sample data in | the resulting :class:`~obspy.core.stream.Stream` object contains | only a reference to the original traces. | | .. rubric:: Example | | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> dt = UTCDateTime("2009-08-24T00:20:20") | >>> st = st.slice(dt, dt + 5) | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | BW.RJOB..EHN | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | BW.RJOB..EHE | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | | slide(self, window_length, step, offset=0, include_partial_windows=False, nearest_sample=True) | Generator yielding equal length sliding windows of the Stream. | | Please keep in mind that it only returns a new view of the original | data. Any modifications are applied to the original data as well. If | you don't want this you have to create a copy of the yielded | windows. Also be aware that if you modify the original data and you | have overlapping windows, all following windows are affected as well. | | Not all yielded windows must have the same number of traces. The | algorithm will determine the maximal temporal extents by analysing | all Traces and then creates windows based on these times. | | .. rubric:: Example | | >>> import obspy | >>> st = obspy.read() | >>> for windowed_st in st.slide(window_length=10.0, step=10.0): | ... print(windowed_st) | ... print("---") # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS | 3 Trace(s) in Stream: | ... | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:13.000000Z | ... | ... | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:13.000000Z | ... | ... | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:13.000000Z | ... | --- | 3 Trace(s) in Stream: | ... | 2009-08-24T00:20:13.000000Z - 2009-08-24T00:20:23.000000Z | ... | ... | 2009-08-24T00:20:13.000000Z - 2009-08-24T00:20:23.000000Z | ... | ... | 2009-08-24T00:20:13.000000Z - 2009-08-24T00:20:23.000000Z | ... | | | :param window_length: The length of each window in seconds. | :type window_length: float | :param step: The step between the start times of two successive | windows in seconds. Can be negative if an offset is given. | :type step: float | :param offset: The offset of the first window in seconds relative to | the start time of the whole interval. | :type offset: float | :param include_partial_windows: Determines if windows that are | shorter then 99.9 % of the desired length are returned. | :type include_partial_windows: bool | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | :type nearest_sample: bool, optional | | sort(self, keys=['network', 'station', 'location', 'channel', 'starttime', 'endtime'], reverse=False) | Sort the traces in the Stream object. | | The traces will be sorted according to the keys list. It will be sorted | by the first item first, then by the second and so on. It will always | be sorted from low to high and from A to Z. | | :type keys: list, optional | :param keys: List containing the values according to which the traces | will be sorted. They will be sorted by the first item first and | then by the second item and so on. | Always available items: 'network', 'station', 'channel', | 'location', 'starttime', 'endtime', 'sampling_rate', 'npts', | 'dataquality' | Defaults to ['network', 'station', 'location', 'channel', | 'starttime', 'endtime']. | :type reverse: bool | :param reverse: Reverts sorting order to descending. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> st.sort() # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | | spectrogram(self, **kwargs) | Create a spectrogram plot for each trace in the stream. | | For details on kwargs that can be used to customize the spectrogram | plot see :func:`obspy.imaging.spectrogram.spectrogram`. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st[0].spectrogram() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | st[0].spectrogram() | | split(self) | Split any trace containing gaps into contiguous unmasked traces. | | :rtype: :class:`obspy.core.stream.Stream` | :returns: Returns a new stream object containing only contiguous | unmasked. | | std(self) | Calculate standard deviations of all Traces in the Stream. | | Standard deviations are calculated by NumPy method | :meth:`~numpy.ndarray.std` on ``trace.data`` for every trace in the | stream. | | :return: List of standard deviations of all traces. | | .. rubric:: Example | | >>> from obspy import Trace, Stream | >>> tr1 = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr2 = Trace(data=np.array([0.3, -3.5, 9.0, 6.4, 4.3])) | >>> st = Stream(traces=[tr1, tr2]) | >>> st.std() | [4.2614551505325036, 4.4348618918744247] | | taper(self, *args, **kwargs) | Taper all Traces in Stream. | | For details see the corresponding :meth:`~obspy.core.trace.Trace.taper` | method of :class:`~obspy.core.trace.Trace`. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | | trigger(self, type, **options) | Run a triggering algorithm on all traces in the stream. | | :param type: String that specifies which trigger is applied (e.g. | ``'recstalta'``). See the `Supported Trigger`_ section below for | further details. | :param options: Necessary keyword arguments for the respective | trigger that will be passed on. (e.g. ``sta=3``, ``lta=10``) | Arguments ``sta`` and ``lta`` (seconds) will be mapped to ``nsta`` | and ``nlta`` (samples) by multiplying with sampling rate of trace. | (e.g. ``sta=3``, ``lta=10`` would call the trigger with 3 and 10 | seconds average, respectively) | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of every trace. | | .. rubric:: _`Supported Trigger` | | ``'classicstalta'`` | Computes the classic STA/LTA characteristic function (uses | :func:`obspy.signal.trigger.classic_sta_lta`). | | ``'recstalta'`` | Recursive STA/LTA | (uses :func:`obspy.signal.trigger.recursive_sta_lta`). | | ``'recstaltapy'`` | Recursive STA/LTA written in Python (uses | :func:`obspy.signal.trigger.recursive_sta_lta_py`). | | ``'delayedstalta'`` | Delayed STA/LTA. | (uses :func:`obspy.signal.trigger.delayed_sta_lta`). | | ``'carlstatrig'`` | Computes the carl_sta_trig characteristic function (uses | :func:`obspy.signal.trigger.carl_sta_trig`). | | ``'zdetect'`` | Z-detector (uses :func:`obspy.signal.trigger.z_detect`). | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> st.filter("highpass", freq=1.0) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.plot() # doctest: +SKIP | >>> st.trigger('recstalta', sta=1, lta=4) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> st.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | st.filter("highpass", freq=1.0) | st.plot() | st.trigger('recstalta', sta=1, lta=4) | st.plot() | | trim(self, starttime=None, endtime=None, pad=False, nearest_sample=True, fill_value=None) | Cut all traces of this Stream object to given start and end time. | | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param starttime: Specify the start time. | :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param endtime: Specify the end time. | :type pad: bool, optional | :param pad: Gives the possibility to trim at time points outside the | time frame of the original trace, filling the trace with the | given ``fill_value``. Defaults to ``False``. | :type nearest_sample: bool, optional | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | | :type fill_value: int, float or ``None``, optional | :param fill_value: Fill value for gaps. Defaults to ``None``. Traces | will be converted to NumPy masked arrays if no value is given and | gaps are present. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data will no longer be accessible afterwards. To keep your | original data, use :meth:`~obspy.core.stream.Stream.copy` to create | a copy of your stream object. | | .. rubric:: Example | | >>> st = read() | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> dt = UTCDateTime("2009-08-24T00:20:20") | >>> st.trim(dt, dt + 5) # doctest: +ELLIPSIS | <...Stream object at 0x...> | >>> print(st) # doctest: +ELLIPSIS | 3 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | BW.RJOB..EHN | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | BW.RJOB..EHE | 2009-08-24T00:20:20.000000Z ... | 100.0 Hz, 501 samples | | verify(self) | Verify all traces of current Stream against available meta data. | | .. rubric:: Example | | >>> from obspy import Trace, Stream | >>> tr = Trace(data=np.array([1, 2, 3, 4])) | >>> tr.stats.npts = 100 | >>> st = Stream([tr]) | >>> st.verify() #doctest: +ELLIPSIS | Traceback (most recent call last): | ... | Exception: ntps(100) differs from data size(4) | | write(self, filename, format, **kwargs) | Save stream into a file. | | :type filename: str | :param filename: The name of the file to write. | :type format: str | :param format: The file format to use (e.g. ``"MSEED"``). See | the `Supported Formats`_ section below for a list of supported | formats. | :param kwargs: Additional keyword arguments passed to the underlying | waveform writer method. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() # doctest: +SKIP | >>> st.write("example.mseed", format="MSEED") # doctest: +SKIP | | Writing single traces into files with meaningful filenames can be done | e.g. using trace.id | | >>> for tr in st: #doctest: +SKIP | ... tr.write(tr.id + ".MSEED", format="MSEED") #doctest: +SKIP | | .. rubric:: _`Supported Formats` | | Additional ObsPy modules extend the parameters of the | :meth:`~obspy.core.stream.Stream.write` method. The following | table summarizes all known formats currently available for ObsPy. | | Please refer to the `Linked Function Call`_ of each module for any | extra options available. | | ====== ======================== ========================================= | Format Required Module _`Linked Function Call` | ====== ======================== ========================================= | GSE2 :mod:`obspy.io.gse2` :func:`obspy.io.gse2.core._write_gse2` | MSEED :mod:`obspy.io.mseed` :func:`obspy.io.mseed.core._write_mseed` | PICKLE :mod:`obspy.core.stream` :func:`obspy.core.stream._write_pickle` | Q :mod:`obspy.io.sh` :func:`obspy.io.sh.core._write_q` | SAC :mod:`obspy.io.sac` :func:`obspy.io.sac.core._write_sac` | SACXY :mod:`obspy.io.sac` :func:`obspy.io.sac.core._write_sac_xy` | SEGY :mod:`obspy.io.segy` :func:`obspy.io.segy.core._write_segy` | SH_ASC :mod:`obspy.io.sh` :func:`obspy.io.sh.core._write_asc` | SLIST :mod:`obspy.io.ascii` :func:`obspy.io.ascii.core._write_slist` | SU :mod:`obspy.io.segy` :func:`obspy.io.segy.core._write_su` | TSPAIR :mod:`obspy.io.ascii` :func:`obspy.io.ascii.core._write_tspair` | WAV :mod:`obspy.io.wav` :func:`obspy.io.wav.core._write_wav` | ====== ======================== ========================================= | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None class Trace(builtins.object) | An object containing data of a continuous series, such as a seismic trace. | | :type data: :class:`~numpy.ndarray` or :class:`~numpy.ma.MaskedArray` | :param data: Array of data samples | :type header: dict or :class:`~obspy.core.trace.Stats` | :param header: Dictionary containing header fields | | :var id: A SEED compatible identifier of the trace. | :var stats: A container :class:`~obspy.core.trace.Stats` for additional | header information of the trace. | :var data: Data samples in a :class:`~numpy.ndarray` or | :class:`~numpy.ma.MaskedArray` | | .. rubric:: Supported Operations | | ``trace = traceA + traceB`` | Merges traceA and traceB into one new trace object. | See also: :meth:`Trace.__add__`. | ``len(trace)`` | Returns the number of samples contained in the trace. That is | it es equal to ``len(trace.data)``. | See also: :meth:`Trace.__len__`. | ``str(trace)`` | Returns basic information about the trace object. | See also: :meth:`Trace.__str__`. | | Methods defined here: | | __add__(self, trace, method=0, interpolation_samples=0, fill_value=None, sanity_checks=True) | Add another Trace object to current trace. | | :type method: int, optional | :param method: Method to handle overlaps of traces. Defaults to ``0``. | See the `Handling Overlaps`_ section below for further details. | :type fill_value: int, float, str or ``None``, optional | :param fill_value: Fill value for gaps. Defaults to ``None``. Traces | will be converted to NumPy masked arrays if no value is given and | gaps are present. If the keyword ``'latest'`` is provided it will | use the latest value before the gap. If keyword ``'interpolate'`` | is provided, missing values are linearly interpolated (not | changing the data type e.g. of integer valued traces). | See the `Handling Gaps`_ section below for further details. | :type interpolation_samples: int, optional | :param interpolation_samples: Used only for ``method=1``. It specifies | the number of samples which are used to interpolate between | overlapping traces. Defaults to ``0``. If set to ``-1`` all | overlapping samples are interpolated. | :type sanity_checks: bool, optional | :param sanity_checks: Enables some sanity checks before merging traces. | Defaults to ``True``. | | Trace data will be converted into a NumPy masked array data type if | any gaps are present. This behavior may be prevented by setting the | ``fill_value`` parameter. The ``method`` argument controls the | handling of overlapping data values. | | Sampling rate, data type and trace.id of both traces must match. | | .. rubric:: _`Handling Overlaps` | | ====== =============================================================== | Method Description | ====== =============================================================== | 0 Discard overlapping data. Overlaps are essentially treated the | same way as gaps:: | | Trace 1: AAAAAAAA | Trace 2: FFFFFFFF | 1 + 2 : AAAA----FFFF | | Contained traces with differing data will be marked as gap:: | | Trace 1: AAAAAAAAAAAA | Trace 2: FF | 1 + 2 : AAAA--AAAAAA | | Missing data can be merged in from a different trace:: | | Trace 1: AAAA--AAAAAA (contained trace, missing samples) | Trace 2: FF | 1 + 2 : AAAAFFAAAAAA | 1 Discard data of the previous trace assuming the following trace | contains data with a more correct time value. The parameter | ``interpolation_samples`` specifies the number of samples used | to linearly interpolate between the two traces in order to | prevent steps. Note that if there are gaps inside, the | returned array is still a masked array, only if ``fill_value`` | is set, the returned array is a normal array and gaps are | filled with fill value. | | No interpolation (``interpolation_samples=0``):: | | Trace 1: AAAAAAAA | Trace 2: FFFFFFFF | 1 + 2 : AAAAFFFFFFFF | | Interpolate first two samples (``interpolation_samples=2``):: | | Trace 1: AAAAAAAA | Trace 2: FFFFFFFF | 1 + 2 : AAAACDFFFFFF (interpolation_samples=2) | | Interpolate all samples (``interpolation_samples=-1``):: | | Trace 1: AAAAAAAA | Trace 2: FFFFFFFF | 1 + 2 : AAAABCDEFFFF | | Any contained traces with different data will be discarded:: | | Trace 1: AAAAAAAAAAAA (contained trace) | Trace 2: FF | 1 + 2 : AAAAAAAAAAAA | | Missing data can be merged in from a different trace:: | | Trace 1: AAAA--AAAAAA (contained trace, missing samples) | Trace 2: FF | 1 + 2 : AAAAFFAAAAAA | ====== =============================================================== | | .. rubric:: _`Handling gaps` | | 1. Traces with gaps and ``fill_value=None`` (default):: | | Trace 1: AAAA | Trace 2: FFFF | 1 + 2 : AAAA----FFFF | | 2. Traces with gaps and given ``fill_value=0``:: | | Trace 1: AAAA | Trace 2: FFFF | 1 + 2 : AAAA0000FFFF | | 3. Traces with gaps and given ``fill_value='latest'``:: | | Trace 1: ABCD | Trace 2: FFFF | 1 + 2 : ABCDDDDDFFFF | | 4. Traces with gaps and given ``fill_value='interpolate'``:: | | Trace 1: AAAA | Trace 2: FFFF | 1 + 2 : AAAABCDEFFFF | | __div__(self, num) | Split Trace into new Stream containing num Traces of the same size. | | :type num: int | :param num: Number of traces in returned Stream. Last trace may contain | lesser samples. | :returns: New ObsPy Stream object. | | .. rubric:: Example | | >>> from obspy import read | >>> tr = read()[0] | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> st = tr / 7 | >>> print(st) # doctest: +ELLIPSIS | 7 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:07.290000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:11.580000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:15.870000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:20.160000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:24.450000Z ... | 100.0 Hz, 429 samples | BW.RJOB..EHZ | 2009-08-24T00:20:28.740000Z ... | 100.0 Hz, 426 samples | | __eq__(self, other) | Implements rich comparison of Trace objects for "==" operator. | | Traces are the same, if both their data and stats are the same. | | __ge__(self, other) | Too ambiguous, throw an Error. | | __getitem__(self, index) | __getitem__ method of Trace object. | | :rtype: list | :return: List of data points | | __gt__(self, other) | Too ambiguous, throw an Error. | | __init__(self, data=array([], dtype=float64), header=None) | Initialize self. See help(type(self)) for accurate signature. | | __le__(self, other) | Too ambiguous, throw an Error. | | __len__(self) | Return number of data samples of the current trace. | | :rtype: int | :return: Number of data samples. | | .. rubric:: Example | | >>> trace = Trace(data=np.array([1, 2, 3, 4])) | >>> trace.count() | 4 | >>> len(trace) | 4 | | __lt__(self, other) | Too ambiguous, throw an Error. | | __mod__(self, num) | Split Trace into new Stream containing Traces with num samples. | | :type num: int | :param num: Number of samples in each trace in returned Stream. Last | trace may contain lesser samples. | :returns: New ObsPy Stream object. | | .. rubric:: Example | | >>> from obspy import read | >>> tr = read()[0] | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 3000 samples | >>> st = tr % 800 | >>> print(st) # doctest: +ELLIPSIS | 4 Trace(s) in Stream: | BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z ... | 100.0 Hz, 800 samples | BW.RJOB..EHZ | 2009-08-24T00:20:11.000000Z ... | 100.0 Hz, 800 samples | BW.RJOB..EHZ | 2009-08-24T00:20:19.000000Z ... | 100.0 Hz, 800 samples | BW.RJOB..EHZ | 2009-08-24T00:20:27.000000Z ... | 100.0 Hz, 600 samples | | __mul__(self, num) | Create a new Stream containing num copies of this trace. | | :type num: int | :param num: Number of copies. | :returns: New ObsPy Stream object. | | .. rubric:: Example | | >>> from obspy import read | >>> tr = read()[0] | >>> st = tr * 5 | >>> len(st) | 5 | | __ne__(self, other) | Implements rich comparison of Trace objects for "!=" operator. | | Calls __eq__() and returns the opposite. | | __nonzero__(self) | No data means no trace. | | __original_str__ = __str__(self, id_length=None) | Return short summary string of the current trace. | | :rtype: str | :return: Short summary string of the current trace containing the SEED | identifier, start time, end time, sampling rate and number of | points of the current trace. | | .. rubric:: Example | | >>> tr = Trace(header={'station':'FUR', 'network':'GR'}) | >>> str(tr) # doctest: +ELLIPSIS | 'GR.FUR.. | 1970-01-01T00:00:00.000000Z - ... | 1.0 Hz, 0 samples' | | __setattr__(self, key, value) | __setattr__ method of Trace object. | | __str__ = _segy_trace_str_(self, *args, **kwargs) | Monkey patch for the __str__ method of the Trace object. SEGY object do not | have network, station, channel codes. It just prints the trace sequence | number within the line. | | __truediv__ = __div__(self, num) | | attach_response(self, inventories) | Search for and attach channel response to the trace as | :class:`Trace`.stats.response. Raises an exception if no matching | response can be found. | To subsequently deconvolve the instrument response use | :meth:`Trace.remove_response`. | | >>> from obspy import read, read_inventory | >>> st = read() | >>> tr = st[0] | >>> inv = read_inventory() | >>> tr.attach_response(inv) | >>> print(tr.stats.response) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE | Channel Response | From M/S (Velocity in Meters per Second) to COUNTS (Digital Counts) | Overall Sensitivity: 2.5168e+09 defined at 0.020 Hz | 4 stages: | Stage 1: PolesZerosResponseStage from M/S to V, gain: 1500 | Stage 2: CoefficientsTypeResponseStage from V to COUNTS, ... | Stage 3: FIRResponseStage from COUNTS to COUNTS, gain: 1 | Stage 4: FIRResponseStage from COUNTS to COUNTS, gain: 1 | | :type inventories: :class:`~obspy.core.inventory.inventory.Inventory` | or :class:`~obspy.core.inventory.network.Network` or a list | containing objects of these types or a string with a filename of | a StationXML file. | :param inventories: Station metadata to use in search for response for | each trace in the stream. | | copy(self) | Returns a deepcopy of the trace. | | :return: Copy of trace. | | This actually copies all data in the trace and does not only provide | another pointer to the same data. At any processing step if the | original data has to be available afterwards, this is the method to | use to make a copy of the trace. | | .. rubric:: Example | | Make a Trace and copy it: | | >>> tr = Trace(data=np.random.rand(10)) | >>> tr2 = tr.copy() | | The two objects are not the same: | | >>> tr2 is tr | False | | But they have equal data (before applying further processing): | | >>> tr2 == tr | True | | The following example shows how to make an alias but not copy the | data. Any changes on ``tr3`` would also change the contents of ``tr``. | | >>> tr3 = tr | >>> tr3 is tr | True | >>> tr3 == tr | True | | count = __len__(self) | | decimate(self, factor, no_filter=False, strict_length=False) | Downsample trace data by an integer factor. | | :type factor: int | :param factor: Factor by which the sampling rate is lowered by | decimation. | :type no_filter: bool, optional | :param no_filter: Deactivates automatic filtering if set to ``True``. | Defaults to ``False``. | :type strict_length: bool, optional | :param strict_length: Leave traces unchanged for which end time of | trace would change. Defaults to ``False``. | | Currently a simple integer decimation is implemented. | Only every ``decimation_factor``-th sample remains in the trace, all | other samples are thrown away. Prior to decimation a lowpass filter is | applied to ensure no aliasing artifacts are introduced. The automatic | filtering can be deactivated with ``no_filter=True``. | | If the length of the data array modulo ``decimation_factor`` is not | zero then the end time of the trace is changing on sub-sample scale. To | abort downsampling in case of changing end times set | ``strict_length=True``. | | .. note:: | | The :class:`~Trace` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate` | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: Example | | For the example we switch off the automatic pre-filtering so that | the effect of the downsampling routine becomes clearer: | | >>> tr = Trace(data=np.arange(10)) | >>> tr.stats.sampling_rate | 1.0 | >>> tr.data | array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) | >>> tr.decimate(4, strict_length=False, | ... no_filter=True) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.stats.sampling_rate | 0.25 | >>> tr.data | array([0, 4, 8]) | | detrend(self, type='simple', **options) | Remove a trend from the trace. | | :type type: str, optional | :param type: Method to use for detrending. Defaults to ``'simple'``. | See the `Supported Methods`_ section below for further details. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: _`Supported Methods` | | ``'simple'`` | Subtracts a linear function defined by first/last sample of the | trace (uses :func:`obspy.signal.detrend.simple`). | | ``'linear'`` | Fitting a linear function to the trace with least squares and | subtracting it (uses :func:`scipy.signal.detrend`). | | ``'constant'`` or ``'demean'`` | Mean of data is subtracted (uses :func:`scipy.signal.detrend`). | | ``'polynomial'`` | Subtracts a polynomial of a given order. | (uses :func:`obspy.signal.detrend.polynomial`). | | ``'spline'`` | Subtracts a spline of a given order with a given number of | samples between spline nodes. | (uses :func:`obspy.signal.detrend.spline`). | | differentiate(self, method='gradient', **options) | Differentiate the trace with respect to time. | | :type method: str, optional | :param method: Method to use for differentiation. Defaults to | ``'gradient'``. See the `Supported Methods`_ section below for | further details. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: _`Supported Methods` | | ``'gradient'`` | The gradient is computed using central differences in the interior | and first differences at the boundaries. The returned gradient | hence has the same shape as the input array. (uses | :func:`numpy.gradient`) | | filter(self, type, **options) | Filter the data of the current trace. | | :type type: str | :param type: String that specifies which filter is applied (e.g. | ``"bandpass"``). See the `Supported Filter`_ section below for | further details. | :param options: Necessary keyword arguments for the respective filter | that will be passed on. (e.g. ``freqmin=1.0``, ``freqmax=20.0`` for | ``"bandpass"``) | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: _`Supported Filter` | | ``'bandpass'`` | Butterworth-Bandpass (uses :func:`obspy.signal.filter.bandpass`). | | ``'bandstop'`` | Butterworth-Bandstop (uses :func:`obspy.signal.filter.bandstop`). | | ``'lowpass'`` | Butterworth-Lowpass (uses :func:`obspy.signal.filter.lowpass`). | | ``'highpass'`` | Butterworth-Highpass (uses :func:`obspy.signal.filter.highpass`). | | ``'lowpass_cheby_2'`` | Cheby2-Lowpass (uses :func:`obspy.signal.filter.lowpass_cheby_2`). | | ``'lowpass_fir'`` (experimental) | FIR-Lowpass (uses :func:`obspy.signal.filter.lowpass_fir`). | | ``'remez_fir'`` (experimental) | Minimax optimal bandpass using Remez algorithm (uses | :func:`obspy.signal.filter.remez_fir`). | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> tr = st[0] | >>> tr.filter("highpass", freq=1.0) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | tr = st[0] | tr.filter("highpass", freq=1.0) | tr.plot() | | getId(self, *args, **kwargs) | DEPRECATED: 'getId' has been renamed to | 'get_id'. Use that instead. | | get_id(self) | Return a SEED compatible identifier of the trace. | | :rtype: str | :return: SEED identifier | | The SEED identifier contains the network, station, location and channel | code for the current Trace object. | | .. rubric:: Example | | >>> meta = {'station': 'MANZ', 'network': 'BW', 'channel': 'EHZ'} | >>> tr = Trace(header=meta) | >>> print(tr.get_id()) | BW.MANZ..EHZ | >>> print(tr.id) | BW.MANZ..EHZ | | integrate(self, method='cumtrapz', **options) | Integrate the trace with respect to time. | | .. rubric:: _`Supported Methods` | | ``'cumtrapz'`` | First order integration of data using the trapezoidal rule. Uses | :func:`obspy.signal.differentiate_and_integrate.integrate_cumtrapz` | | ``'spline'`` | Integrates by generating an interpolating spline and integrating | that. Uses | :func:`obspy.signal.differentiate_and_integrate.integrate_spline` | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | interpolate(self, sampling_rate, method='weighted_average_slopes', starttime=None, npts=None, time_shift=0.0, *args, **kwargs) | Interpolate the data using various interpolation techniques. | | Be careful when downsampling data and make sure to apply an appropriate | anti-aliasing lowpass filter before interpolating in case it's | necessary. | | .. note:: | | The :class:`~Trace` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate`. | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data will no longer be accessible afterwards. To keep your | original data, use :meth:`~.copy` to create a copy of your Trace | object. | | .. rubric:: _`Interpolation Methods:` | | The chosen method is crucial and we will elaborate a bit about the | choices here: | | * ``"lanczos"``: This offers the highest quality interpolation and | should be chosen whenever possible. It is only due to legacy | reasons that this is not the default method. The one downside it | has is that it can be fairly expensive. See the | :func:`~obspy.signal.interpolation.lanczos_interpolation` function | for more details. | * ``"weighted_average_slopes"``: This is the interpolation method used | by SAC. Refer to | :func:`~obspy.signal.interpolation.weighted_average_slopes` for | more details. | * ``"slinear"``, ``"quadratic"`` and ``"cubic"``: spline interpolation | of first, second or third order. | * ``"linear"``: Linear interpolation. | * ``"nearest"``: Nearest neighbour interpolation. | * ``"zero"``: Last encountered value interpolation. | | .. rubric:: _`Parameters:` | | :param sampling_rate: The new sampling rate in ``Hz``. | :param method: The kind of interpolation to perform as a string. One of | ``"linear"``, ``"nearest"``, ``"zero"``, ``"slinear"``, | ``"quadratic"``, ``"cubic"``, ``"lanczos"``, or | ``"weighted_average_slopes"``. Alternatively an integer | specifying the order of the spline interpolator to use also works. | Defaults to ``"weighted_average_slopes"``. | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` or int | :param starttime: The start time (or timestamp) for the new | interpolated stream. Will be set to current start time of the | trace if not given. | :type npts: int | :param npts: The new number of samples. Will be set to the best | fitting number to retain the current end time of the trace if | not given. | :type time_shift: float | :param time_shift: Interpolation can also shift the data with | subsample accuracy. The time shift is always given in seconds. A | positive shift means the data is shifted towards the future, | e.g. a positive time delta. Please note that a time shift in | the Fourier domain is always more accurate than this. When using | Lanczos interpolation with large values of ``a`` and away from the | boundaries this is nonetheless pretty good. | | .. rubric:: _`New in version 0.11:` | | * New parameter ``time_shift``. | * New interpolation method ``lanczos``. | | | .. rubric:: _`Usage Examples` | | >>> from obspy import read | >>> tr = read()[0] | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples | >>> tr.interpolate(sampling_rate=111.1) # doctest: +ELLIPSIS | <obspy.core.trace.Trace object at 0x...> | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 111.1 Hz, 3332 samples | | Setting ``starttime`` and/or ``npts`` will interpolate to sampling | points with the given start time and/or number of samples. | Extrapolation will not be performed. | | >>> tr = read()[0] | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples | >>> tr.interpolate(sampling_rate=111.1, | ... starttime=tr.stats.starttime + 10) # doctest: +ELLIPSIS | <obspy.core.trace.Trace object at 0x...> | >>> print(tr) # doctest: +ELLIPSIS | BW.RJOB..EHZ | 2009-08-24T00:20:13... - ... | 111.1 Hz, 2221 samples | | max(self) | Returns the value of the absolute maximum amplitude in the trace. | | :return: Value of absolute maximum of ``trace.data``. | | .. rubric:: Example | | >>> tr = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr.max() | 9 | >>> tr = Trace(data=np.array([0, -3, -9, 6, 4])) | >>> tr.max() | -9 | >>> tr = Trace(data=np.array([0.3, -3.5, 9.0, 6.4, 4.3])) | >>> tr.max() | 9.0 | | normalize(self, norm=None) | Normalize the trace to its absolute maximum. | | :type norm: ``None`` or float | :param norm: If not ``None``, trace is normalized by dividing by | specified value ``norm`` instead of dividing by its absolute | maximum. If a negative value is specified then its absolute value | is used. If it is zero (either through a zero array or by being | passed), nothing will happen and the original array will not | change. | | If ``trace.data.dtype`` was integer it is changing to float. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: Example | | >>> tr = Trace(data=np.array([0, -3, 9, 6])) | >>> tr.normalize() # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.data | array([ 0. , -0.33333333, 1. , 0.66666667]) | >>> print(tr.stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ...: normalize(norm=None) | >>> tr = Trace(data=np.array([0.3, -3.5, -9.2, 6.4])) | >>> tr.normalize() # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.data | array([ 0.0326087 , -0.38043478, -1. , 0.69565217]) | >>> print(tr.stats.processing[0]) # doctest: +ELLIPSIS | ObsPy ...: normalize(norm=None) | | plot(self, **kwargs) | Create a simple graph of the current trace. | | Various options are available to change the appearance of the waveform | plot. Please see :meth:`~obspy.core.stream.Stream.plot` method for all | possible options. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> tr = st[0] | >>> tr.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | tr = st[0] | tr.plot() | | remove_response(self, inventory=None, output='VEL', water_level=60, pre_filt=None, zero_mean=True, taper=True, taper_fraction=0.05, plot=False, fig=None, **kwargs) | Deconvolve instrument response. | | Uses the adequate :class:`obspy.core.inventory.response.Response` | from the provided | :class:`obspy.core.inventory.inventory.Inventory` data. Raises an | exception if the response is not present. | | Note that there are two ways to prevent overamplification | while convolving the inverted instrument spectrum: One possibility is | to specify a water level which represents a clipping of the inverse | spectrum and limits amplification to a certain maximum cut-off value | (`water_level` in dB). The other possibility is to taper the waveform | data in the frequency domain prior to multiplying with the inverse | spectrum, i.e. perform a pre-filtering in the frequency domain | (specifying the four corner frequencies of the frequency taper as a | tuple in `pre_filt`). | | .. note:: | | Any additional kwargs will be passed on to | :meth:`obspy.core.inventory.response.Response.get_evalresp_response`, | see documentation of that method for further customization (e.g. | start/stop stage). | | .. note:: | | Using :meth:`~Trace.remove_response` is equivalent to using | :meth:`~Trace.simulate` with the identical response provided as | a (dataless) SEED or RESP file and when using the same | `water_level` and `pre_filt` (and options `sacsim=True` and | `pitsasim=False` which influence very minor details in detrending | and tapering). | | .. rubric:: Example | | >>> from obspy import read, read_inventory | >>> st = read() | >>> tr = st[0].copy() | >>> inv = read_inventory() | >>> tr.remove_response(inventory=inv) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read, read_inventory | st = read() | tr = st[0] | inv = read_inventory() | tr.remove_response(inventory=inv) | tr.plot() | | Using the `plot` option it is possible to visualize the individual | steps during response removal in the frequency domain to check the | chosen `pre_filt` and `water_level` options to stabilize the | deconvolution of the inverted instrument response spectrum: | | >>> from obspy import read, read_inventory | >>> st = read("/path/to/IU_ULN_00_LH1_2015-07-18T02.mseed") | >>> tr = st[0] | >>> inv = read_inventory("/path/to/IU_ULN_00_LH1.xml") | >>> pre_filt = [0.001, 0.005, 45, 50] | >>> tr.remove_response(inventory=inv, pre_filt=pre_filt, output="DISP", | ... water_level=60, plot=True) # doctest: +SKIP | <...Trace object at 0x...> | | .. plot:: | | from obspy import read, read_inventory | st = read("/path/to/IU_ULN_00_LH1_2015-07-18T02.mseed", "MSEED") | tr = st[0] | inv = read_inventory("/path/to/IU_ULN_00_LH1.xml", "STATIONXML") | pre_filt = [0.001, 0.005, 45, 50] | output = "DISP" | tr.remove_response(inventory=inv, pre_filt=pre_filt, output=output, | water_level=60, plot=True) | | :type inventory: :class:`~obspy.core.inventory.inventory.Inventory` | or None. | :param inventory: Station metadata to use in search for adequate | response. If inventory parameter is not supplied, the response | has to be attached to the trace with :meth:`Trace.attach_response` | beforehand. | :type output: str | :param output: Output units. One of: | | ``"DISP"`` | displacement, output unit is meters | ``"VEL"`` | velocity, output unit is meters/second | ``"ACC"`` | acceleration, output unit is meters/second**2 | | :type water_level: float | :param water_level: Water level for deconvolution. | :type pre_filt: list or tuple of four float | :param pre_filt: Apply a bandpass filter in frequency domain to the | data before deconvolution. The list or tuple defines | the four corner frequencies `(f1, f2, f3, f4)` of a cosine taper | which is one between `f2` and `f3` and tapers to zero for | `f1 < f < f2` and `f3 < f < f4`. | :type zero_mean: bool | :param zero_mean: If `True`, the mean of the waveform data is | subtracted in time domain prior to deconvolution. | :type taper: bool | :param taper: If `True`, a cosine taper is applied to the waveform data | in time domain prior to deconvolution. | :type taper_fraction: float | :param taper_fraction: Taper fraction of cosine taper to use. | :type plot: bool or str | :param plot: If `True`, brings up a plot that illustrates how the | data are processed in the frequency domain in three steps. First by | `pre_filt` frequency domain tapering, then by inverting the | instrument response spectrum with or without `water_level` and | finally showing data with inverted instrument response multiplied | on it in frequency domain. It also shows the comparison of | raw/corrected data in time domain. If a `str` is provided then the | plot is saved to file (filename must have a valid image suffix | recognizable by matplotlib e.g. '.png'). | | remove_sensitivity(self, inventory=None) | Remove instrument sensitivity. | | :type inventory: :class:`~obspy.core.inventory.inventory.Inventory` | or None. | :param inventory: Station metadata to use in search for adequate | response. If inventory parameter is not supplied, the response | has to be attached to the trace with :meth:`Trace.attach_response` | beforehand. | | .. rubric:: Example | | >>> from obspy import read, read_inventory | >>> tr = read()[0] | >>> inv = read_inventory() | >>> tr.remove_sensitivity(inv) # doctest: +ELLIPSIS | <...Trace object at 0x...> | | resample(self, sampling_rate, window='hanning', no_filter=True, strict_length=False) | Resample trace data using Fourier method. Spectra are linearly | interpolated if required. | | :type sampling_rate: float | :param sampling_rate: The sampling rate of the resampled signal. | :type window: array_like, callable, str, float, or tuple, optional | :param window: Specifies the window applied to the signal in the | Fourier domain. Defaults to ``'hanning'`` window. See | :func:`scipy.signal.resample` for details. | :type no_filter: bool, optional | :param no_filter: Deactivates automatic filtering if set to ``True``. | Defaults to ``True``. | :type strict_length: bool, optional | :param strict_length: Leave traces unchanged for which end time of | trace would change. Defaults to ``False``. | | .. note:: | | The :class:`~Trace` object has three different methods to change | the sampling rate of its data: :meth:`~.resample`, | :meth:`~.decimate`, and :meth:`~.interpolate` | | Make sure to choose the most appropriate one for the problem at | hand. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | Uses :func:`scipy.signal.resample`. Because a Fourier method is used, | the signal is assumed to be periodic. | | .. rubric:: Example | | >>> tr = Trace(data=np.array([0.5, 0, 0.5, 1, 0.5, 0, 0.5, 1])) | >>> len(tr) | 8 | >>> tr.stats.sampling_rate | 1.0 | >>> tr.resample(4.0) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> len(tr) | 32 | >>> tr.stats.sampling_rate | 4.0 | >>> tr.data # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS | array([ 0.5 , 0.40432914, 0.3232233 , 0.26903012, 0.25 ... | | simulate(self, paz_remove=None, paz_simulate=None, remove_sensitivity=True, simulate_sensitivity=True, **kwargs) | Correct for instrument response / Simulate new instrument response. | | :type paz_remove: dict, None | :param paz_remove: Dictionary containing keys ``'poles'``, ``'zeros'``, | ``'gain'`` (A0 normalization factor). Poles and zeros must be a | list of complex floating point numbers, gain must be of type float. | Poles and Zeros are assumed to correct to m/s, SEED convention. | Use ``None`` for no inverse filtering. | :type paz_simulate: dict, None | :param paz_simulate: Dictionary containing keys ``'poles'``, | ``'zeros'``, ``'gain'``. Poles and zeros must be a list of complex | floating point numbers, gain must be of type float. Or ``None`` for | no simulation. | :type remove_sensitivity: bool | :param remove_sensitivity: Determines if data is divided by | ``paz_remove['sensitivity']`` to correct for overall sensitivity of | recording instrument (seismometer/digitizer) during instrument | correction. | :type simulate_sensitivity: bool | :param simulate_sensitivity: Determines if data is multiplied with | ``paz_simulate['sensitivity']`` to simulate overall sensitivity of | new instrument (seismometer/digitizer) during instrument | simulation. | | This function corrects for the original instrument response given by | `paz_remove` and/or simulates a new instrument response given by | `paz_simulate`. | For additional information and more options to control the instrument | correction/simulation (e.g. water level, demeaning, tapering, ...) see | :func:`~obspy.signal.invsim.simulate_seismometer`. | | `paz_remove` and `paz_simulate` are expected to be dictionaries | containing information on poles, zeros and gain (and usually also | sensitivity). | | If both `paz_remove` and `paz_simulate` are specified, both steps are | performed in one go in the frequency domain, otherwise only the | specified step is performed. | | .. note:: | | Instead of the builtin deconvolution based on Poles and Zeros | information, the deconvolution can be performed using evalresp | instead by using the option `seedresp` (see documentation of | :func:`~obspy.signal.invsim.simulate_seismometer` and the `ObsPy | Tutorial <https://docs.obspy.org/master/tutorial/code_snippets/seismometer_correction_simulation.html#using-a-resp-file>`_. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: Example | | >>> from obspy import read | >>> from obspy.signal.invsim import corn_freq_2_paz | >>> st = read() | >>> tr = st[0] | >>> paz_sts2 = {'poles': [-0.037004+0.037016j, -0.037004-0.037016j, | ... -251.33+0j, | ... -131.04-467.29j, -131.04+467.29j], | ... 'zeros': [0j, 0j], | ... 'gain': 60077000.0, | ... 'sensitivity': 2516778400.0} | >>> paz_1hz = corn_freq_2_paz(1.0, damp=0.707) | >>> paz_1hz['sensitivity'] = 1.0 | >>> tr.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz) | ... # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | from obspy.signal.invsim import corn_freq_2_paz | st = read() | tr = st[0] | paz_sts2 = {'poles': [-0.037004+0.037016j, -0.037004-0.037016j, | -251.33+0j, | -131.04-467.29j, -131.04+467.29j], | 'zeros': [0j, 0j], | 'gain': 60077000.0, | 'sensitivity': 2516778400.0} | paz_1hz = corn_freq_2_paz(1.0, damp=0.707) | paz_1hz['sensitivity'] = 1.0 | tr.simulate(paz_remove=paz_sts2, paz_simulate=paz_1hz) | tr.plot() | | slice(self, starttime=None, endtime=None, nearest_sample=True) | Return a new Trace object with data going from start to end time. | | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param starttime: Specify the start time of slice. | :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime` | :param endtime: Specify the end time of slice. | :type nearest_sample: bool, optional | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | | :return: New :class:`~obspy.core.trace.Trace` object. Does not copy | data but just passes a reference to it. | | .. rubric:: Example | | >>> tr = Trace(data=np.arange(0, 10)) | >>> tr.stats.delta = 1.0 | >>> t = tr.stats.starttime | >>> tr2 = tr.slice(t + 2, t + 8) | >>> tr2.data | array([2, 3, 4, 5, 6, 7, 8]) | | slide(self, window_length, step, offset=0, include_partial_windows=False, nearest_sample=True) | Generator yielding equal length sliding windows of the Trace. | | Please keep in mind that it only returns a new view of the original | data. Any modifications are applied to the original data as well. If | you don't want this you have to create a copy of the yielded | windows. Also be aware that if you modify the original data and you | have overlapping windows, all following windows are affected as well. | | .. rubric:: Example | | >>> import obspy | >>> tr = obspy.read()[0] | >>> for windowed_tr in tr.slide(window_length=10.0, step=10.0): | ... print("---") # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS | ... print(windowed_tr) | --- | ... | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:13.000000Z | ... | --- | ... | 2009-08-24T00:20:13.000000Z - 2009-08-24T00:20:23.000000Z | ... | | | :param window_length: The length of each window in seconds. | :type window_length: float | :param step: The step between the start times of two successive | windows in seconds. Can be negative if an offset is given. | :type step: float | :param offset: The offset of the first window in seconds relative to | the start time of the whole interval. | :type offset: float | :param include_partial_windows: Determines if windows that are | shorter then 99.9 % of the desired length are returned. | :type include_partial_windows: bool | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | :type nearest_sample: bool, optional | | spectrogram(self, **kwargs) | Create a spectrogram plot of the trace. | | For details on kwargs that can be used to customize the spectrogram | plot see :func:`~obspy.imaging.spectrogram.spectrogram`. | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> tr = st[0] | >>> tr.spectrogram() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | tr = st[0] | tr.spectrogram(sphinx=True) | | split(self) | Split Trace object containing gaps using a NumPy masked array into | several traces. | | :rtype: :class:`~obspy.core.stream.Stream` | :returns: Stream containing all split traces. A gapless trace will | still be returned as Stream with only one entry. | | std(self) | Method to get the standard deviation of amplitudes in the trace. | | :return: Standard deviation of ``trace.data``. | | Standard deviation is calculated by NumPy method | :meth:`~numpy.ndarray.std` on ``trace.data``. | | .. rubric:: Example | | >>> tr = Trace(data=np.array([0, -3, 9, 6, 4])) | >>> tr.std() | 4.2614551505325036 | >>> tr = Trace(data=np.array([0.3, -3.5, 9.0, 6.4, 4.3])) | >>> tr.std() | 4.4348618918744247 | | taper(self, max_percentage, type='hann', max_length=None, side='both', **kwargs) | Taper the trace. | | Optional (and sometimes necessary) options to the tapering function can | be provided as kwargs. See respective function definitions in | `Supported Methods`_ section below. | | :type type: str | :param type: Type of taper to use for detrending. Defaults to | ``'cosine'``. See the `Supported Methods`_ section below for | further details. | :type max_percentage: None, float | :param max_percentage: Decimal percentage of taper at one end (ranging | from 0. to 0.5). | :type max_length: None, float | :param max_length: Length of taper at one end in seconds. | :type side: str | :param side: Specify if both sides should be tapered (default, "both") | or if only the left half ("left") or right half ("right") should be | tapered. | | .. note:: | | To get the same results as the default taper in SAC, use | `max_percentage=0.05` and leave `type` as `hann`. | | .. note:: | | If both `max_percentage` and `max_length` are set to a float, the | shorter tape length is used. If both `max_percentage` and | `max_length` are set to `None`, the whole trace will be tapered. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: _`Supported Methods` | | ``'cosine'`` | Cosine taper, for additional options like taper percentage see: | :func:`obspy.signal.invsim.cosine_taper`. | ``'barthann'`` | Modified Bartlett-Hann window. (uses: | :func:`scipy.signal.barthann`) | ``'bartlett'`` | Bartlett window. (uses: :func:`scipy.signal.bartlett`) | ``'blackman'`` | Blackman window. (uses: :func:`scipy.signal.blackman`) | ``'blackmanharris'`` | Minimum 4-term Blackman-Harris window. (uses: | :func:`scipy.signal.blackmanharris`) | ``'bohman'`` | Bohman window. (uses: :func:`scipy.signal.bohman`) | ``'boxcar'`` | Boxcar window. (uses: :func:`scipy.signal.boxcar`) | ``'chebwin'`` | Dolph-Chebyshev window. (uses: :func:`scipy.signal.chebwin`) | ``'flattop'`` | Flat top window. (uses: :func:`scipy.signal.flattop`) | ``'gaussian'`` | Gaussian window with standard-deviation std. (uses: | :func:`scipy.signal.gaussian`) | ``'general_gaussian'`` | Generalized Gaussian window. (uses: | :func:`scipy.signal.general_gaussian`) | ``'hamming'`` | Hamming window. (uses: :func:`scipy.signal.hamming`) | ``'hann'`` | Hann window. (uses: :func:`scipy.signal.hann`) | ``'kaiser'`` | Kaiser window with shape parameter beta. (uses: | :func:`scipy.signal.kaiser`) | ``'nuttall'`` | Minimum 4-term Blackman-Harris window according to Nuttall. | (uses: :func:`scipy.signal.nuttall`) | ``'parzen'`` | Parzen window. (uses: :func:`scipy.signal.parzen`) | ``'slepian'`` | Slepian window. (uses: :func:`scipy.signal.slepian`) | ``'triang'`` | Triangular window. (uses: :func:`scipy.signal.triang`) | | times(self) | For convenient plotting compute a NumPy array of seconds since | starttime corresponding to the samples in Trace. | | :rtype: :class:`~numpy.ndarray` or :class:`~numpy.ma.MaskedArray` | :returns: An array of time samples in an :class:`~numpy.ndarray` if | the trace doesn't have any gaps or a :class:`~numpy.ma.MaskedArray` | otherwise. | | trigger(self, type, **options) | Run a triggering algorithm on the data of the current trace. | | :param type: String that specifies which trigger is applied (e.g. | ``'recstalta'``). See the `Supported Trigger`_ section below for | further details. | :param options: Necessary keyword arguments for the respective trigger | that will be passed on. | (e.g. ``sta=3``, ``lta=10``) | Arguments ``sta`` and ``lta`` (seconds) will be mapped to ``nsta`` | and ``nlta`` (samples) by multiplying with sampling rate of trace. | (e.g. ``sta=3``, ``lta=10`` would call the trigger with 3 and 10 | seconds average, respectively) | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | This also makes an entry with information on the applied processing | in ``stats.processing`` of this trace. | | .. rubric:: _`Supported Trigger` | | ``'classicstalta'`` | Computes the classic STA/LTA characteristic function (uses | :func:`obspy.signal.trigger.classic_sta_lta`). | | ``'recstalta'`` | Recursive STA/LTA | (uses :func:`obspy.signal.trigger.recursive_sta_lta`). | | ``'recstaltapy'`` | Recursive STA/LTA written in Python (uses | :func:`obspy.signal.trigger.recursive_sta_lta_py`). | | ``'delayedstalta'`` | Delayed STA/LTA. | (uses :func:`obspy.signal.trigger.delayed_sta_lta`). | | ``'carlstatrig'`` | Computes the carl_sta_trig characteristic function (uses | :func:`obspy.signal.trigger.carl_sta_trig`). | | ``'zdetect'`` | Z-detector (uses :func:`obspy.signal.trigger.z_detect`). | | .. rubric:: Example | | >>> from obspy import read | >>> st = read() | >>> tr = st[0] | >>> tr.filter("highpass", freq=1.0) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.plot() # doctest: +SKIP | >>> tr.trigger("recstalta", sta=1, lta=4) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.plot() # doctest: +SKIP | | .. plot:: | | from obspy import read | st = read() | tr = st[0] | tr.filter("highpass", freq=1.0) | tr.plot() | tr.trigger('recstalta', sta=1, lta=4) | tr.plot() | | trim(self, starttime=None, endtime=None, pad=False, nearest_sample=True, fill_value=None) | Cut current trace to given start and end time. | | :type starttime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param starttime: Specify the start time. | :type endtime: :class:`~obspy.core.utcdatetime.UTCDateTime`, optional | :param endtime: Specify the end time. | :type pad: bool, optional | :param pad: Gives the possibility to trim at time points outside the | time frame of the original trace, filling the trace with the | given ``fill_value``. Defaults to ``False``. | :type nearest_sample: bool, optional | :param nearest_sample: If set to ``True``, the closest sample is | selected, if set to ``False``, the outer (previous sample for a | start time border, next sample for an end time border) sample | containing the time is selected. Defaults to ``True``. | | Given the following trace containing 4 samples, "|" are the | sample points, "A" is the requested starttime:: | | | A| | | | | ``nearest_sample=True`` will select the second sample point, | ``nearest_sample=False`` will select the first sample point. | | :type fill_value: int, float or ``None``, optional | :param fill_value: Fill value for gaps. Defaults to ``None``. Traces | will be converted to NumPy masked arrays if no value is given and | gaps are present. | | .. note:: | | This operation is performed in place on the actual data arrays. The | raw data is not accessible anymore afterwards. To keep your | original data, use :meth:`~obspy.core.trace.Trace.copy` to create | a copy of your trace object. | | .. rubric:: Example | | >>> tr = Trace(data=np.arange(0, 10)) | >>> tr.stats.delta = 1.0 | >>> t = tr.stats.starttime | >>> tr.trim(t + 2.000001, t + 7.999999) # doctest: +ELLIPSIS | <...Trace object at 0x...> | >>> tr.data | array([2, 3, 4, 5, 6, 7, 8]) | | verify(self) | Verify current trace object against available meta data. | | .. rubric:: Example | | >>> tr = Trace(data=np.array([1,2,3,4])) | >>> tr.stats.npts = 100 | >>> tr.verify() #doctest: +ELLIPSIS | Traceback (most recent call last): | ... | Exception: ntps(100) differs from data size(4) | | write(self, filename, format, **kwargs) | Save current trace into a file. | | :type filename: str | :param filename: The name of the file to write. | :type format: str | :param format: The format to write must be specified. See | :meth:`obspy.core.stream.Stream.write` method for possible | formats. | :param kwargs: Additional keyword arguments passed to the underlying | waveform writer method. | | .. rubric:: Example | | >>> tr = Trace() | >>> tr.write("out.mseed", format="MSEED") # doctest: +SKIP | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | id | Return a SEED compatible identifier of the trace. | | :rtype: str | :return: SEED identifier | | The SEED identifier contains the network, station, location and channel | code for the current Trace object. | | .. rubric:: Example | | >>> meta = {'station': 'MANZ', 'network': 'BW', 'channel': 'EHZ'} | >>> tr = Trace(header=meta) | >>> print(tr.get_id()) | BW.MANZ..EHZ | >>> print(tr.id) | BW.MANZ..EHZ | | meta | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None class UTCDateTime(builtins.object) | A UTC-based datetime object. | | This datetime class is based on the POSIX time, a system for describing | instants in time, defined as the number of seconds elapsed since midnight | Coordinated Universal Time (UTC) of Thursday, January 1, 1970. Using a | single float timestamp allows higher precision as the default Python | :class:`datetime.datetime` class. It features the full `ISO8601:2004`_ | specification and some additional string patterns during object | initialization. | | :type args: int, float, str, :class:`datetime.datetime`, optional | :param args: The creation of a new `UTCDateTime` object depends from the | given input parameters. All possible options are summarized in the | `Examples`_ section below. | :type iso8601: bool, optional | :param iso8601: Enforce `ISO8601:2004`_ detection. Works only with a string | as first input argument. | :type precision: int, optional | :param precision: Sets the precision used by the rich comparison operators. | Defaults to ``6`` digits after the decimal point. See also `Precision`_ | section below. | | .. versionchanged:: 0.5.1 | UTCDateTime is no longer based on Python's datetime.datetime class | instead uses timestamp as a single floating point value which allows | higher precision. | | .. rubric:: Supported Operations | | ``UTCDateTime = UTCDateTime + delta`` | Adds/removes ``delta`` seconds (given as int or float) to/from the | current ``UTCDateTime`` object and returns a new ``UTCDateTime`` | object. | See also: :meth:`~obspy.core.utcdatetime.UTCDateTime.__add__`. | | ``delta = UTCDateTime - UTCDateTime`` | Calculates the time difference in seconds between two ``UTCDateTime`` | objects. The time difference is given as float data type and may also | contain a negative number. | See also: :meth:`~obspy.core.utcdatetime.UTCDateTime.__sub__`. | | .. rubric:: _`Examples` | | (1) Using a timestamp. | | >>> UTCDateTime(0) | UTCDateTime(1970, 1, 1, 0, 0) | | >>> UTCDateTime(1240561632) | UTCDateTime(2009, 4, 24, 8, 27, 12) | | >>> UTCDateTime(1240561632.5) | UTCDateTime(2009, 4, 24, 8, 27, 12, 500000) | | (2) Using a `ISO8601:2004`_ string. The detection may be enforced by | setting the ``iso8601`` parameter to True. | | * Calendar date representation. | | >>> UTCDateTime("2009-12-31T12:23:34.5") | UTCDateTime(2009, 12, 31, 12, 23, 34, 500000) | | >>> UTCDateTime("20091231T122334.5") # compact | UTCDateTime(2009, 12, 31, 12, 23, 34, 500000) | | >>> UTCDateTime("2009-12-31T12:23:34.5Z") # w/o time zone | UTCDateTime(2009, 12, 31, 12, 23, 34, 500000) | | >>> UTCDateTime("2009-12-31T12:23:34+01:15") # w/ time zone | UTCDateTime(2009, 12, 31, 11, 8, 34) | | * Ordinal date representation. | | >>> UTCDateTime("2009-365T12:23:34.5") | UTCDateTime(2009, 12, 31, 12, 23, 34, 500000) | | >>> UTCDateTime("2009365T122334.5") # compact | UTCDateTime(2009, 12, 31, 12, 23, 34, 500000) | | >>> UTCDateTime("2009001", iso8601=True) # enforce ISO8601 | UTCDateTime(2009, 1, 1, 0, 0) | | * Week date representation. | | >>> UTCDateTime("2009-W53-7T12:23:34.5") | UTCDateTime(2010, 1, 3, 12, 23, 34, 500000) | | >>> UTCDateTime("2009W537T122334.5") # compact | UTCDateTime(2010, 1, 3, 12, 23, 34, 500000) | | >>> UTCDateTime("2009W011", iso8601=True) # enforce ISO8601 | UTCDateTime(2008, 12, 29, 0, 0) | | (3) Using not ISO8601 compatible strings. | | >>> UTCDateTime("1970-01-01 12:23:34") | UTCDateTime(1970, 1, 1, 12, 23, 34) | | >>> UTCDateTime("1970,01,01,12:23:34") | UTCDateTime(1970, 1, 1, 12, 23, 34) | | >>> UTCDateTime("1970,001,12:23:34") | UTCDateTime(1970, 1, 1, 12, 23, 34) | | >>> UTCDateTime("20090701121212") | UTCDateTime(2009, 7, 1, 12, 12, 12) | | >>> UTCDateTime("19700101") | UTCDateTime(1970, 1, 1, 0, 0) | | >>> UTCDateTime("20110818_03:00:00") | UTCDateTime(2011, 8, 18, 3, 0) | | (4) Using multiple arguments in the following order: `year, month, | day[, hour[, minute[, second[, microsecond]]]`. The year, month and day | arguments are required. | | >>> UTCDateTime(1970, 1, 1) | UTCDateTime(1970, 1, 1, 0, 0) | | >>> UTCDateTime(1970, 1, 1, 12, 23, 34, 123456) | UTCDateTime(1970, 1, 1, 12, 23, 34, 123456) | | (5) Using the following keyword arguments: `year, month, day, julday, hour, | minute, second, microsecond`. Either the combination of year, month and | day, or year and Julian day are required. | | >>> UTCDateTime(year=1970, month=1, day=1, minute=15, microsecond=20) | UTCDateTime(1970, 1, 1, 0, 15, 0, 20) | | >>> UTCDateTime(year=2009, julday=234, hour=14, minute=13) | UTCDateTime(2009, 8, 22, 14, 13) | | (6) Using a Python :class:`datetime.datetime` object. | | >>> dt = datetime.datetime(2009, 5, 24, 8, 28, 12, 5001) | >>> UTCDateTime(dt) | UTCDateTime(2009, 5, 24, 8, 28, 12, 5001) | | .. rubric:: _`Precision` | | The :class:`UTCDateTime` class works with a default precision of ``6`` | digits which effects the comparison of date/time values, e.g.: | | >>> dt = UTCDateTime(0) | >>> dt2 = UTCDateTime(0.00001) | >>> dt3 = UTCDateTime(0.0000001) | >>> print(dt.precision) | 6 | >>> dt == dt2 # 5th digit is within current precision | False | >>> dt == dt3 # 7th digit will be neglected | True | | You may change that behavior either by, | | (1) using the ``precision`` keyword during object initialization: | | >>> dt = UTCDateTime(0, precision=4) | >>> dt2 = UTCDateTime(0.00001, precision=4) | >>> print(dt.precision) | 4 | >>> dt == dt2 | True | | (2) or set it the class attribute ``DEFAULT_PRECISION`` for all new | :class:`UTCDateTime` objects using a monkey patch: | | >>> UTCDateTime.DEFAULT_PRECISION = 4 | >>> dt = UTCDateTime(0) | >>> dt2 = UTCDateTime(0.00001) | >>> print(dt.precision) | 4 | >>> dt == dt2 | True | | Don't forget to reset ``DEFAULT_PRECISION`` if not needed anymore! | | >>> UTCDateTime.DEFAULT_PRECISION = 6 | | .. _ISO8601:2004: https://en.wikipedia.org/wiki/ISO_8601 | | Methods defined here: | | __abs__(self) | Returns absolute timestamp value of the current UTCDateTime object. | | __add__(self, value) | Adds seconds and microseconds to current UTCDateTime object. | | :type value: int, float | :param value: Seconds to add | :rtype: :class:`~obspy.core.utcdatetime.UTCDateTime` | :return: New UTCDateTime object. | | .. rubric:: Example | | >>> dt = UTCDateTime(1970, 1, 1, 0, 0) | >>> dt + 2 | UTCDateTime(1970, 1, 1, 0, 0, 2) | | >>> UTCDateTime(1970, 1, 1, 0, 0) + 1.123456 | UTCDateTime(1970, 1, 1, 0, 0, 1, 123456) | | __eq__(self, other) | Rich comparison operator '=='. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000012) | >>> t2 = UTCDateTime(123.000000099) | >>> t1 == t2 | True | | But the actual timestamp differ | | >>> t1.timestamp == t2.timestamp | False | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 == t2 | False | | __float__(self) | Returns UTC timestamp in seconds. | | :rtype: float | :return: Timestamp in seconds. | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 123456) | >>> float(dt) | 1222864235.123456 | | __ge__(self, other) | Rich comparison operator '>='. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000012) | >>> t2 = UTCDateTime(123.000000099) | >>> t1 >= t2 | True | | But the actual timestamp differ | | >>> t1.timestamp >= t2.timestamp | False | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 >= t2 | False | | __gt__(self, other) | Rich comparison operator '>'. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000099) | >>> t2 = UTCDateTime(123.000000012) | >>> t1 > t2 | False | | But the actual timestamp differ | | >>> t1.timestamp > t2.timestamp | True | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 > t2 | True | | __hash__(self) | An object is hashable if it has a hash value which never changes | during its lifetime. As an UTCDateTime object may change over time, | it's not hashable. Use the :meth:`~UTCDateTime.datetime()` method to | generate a :class:`datetime.datetime` object for hashing. But be aware: | once the UTCDateTime object changes, the hash is not valid anymore. | | __init__(self, *args, **kwargs) | Creates a new UTCDateTime object. | | __le__(self, other) | Rich comparison operator '<='. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000099) | >>> t2 = UTCDateTime(123.000000012) | >>> t1 <= t2 | True | | But the actual timestamp differ | | >>> t1.timestamp <= t2.timestamp | False | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 <= t2 | False | | __lt__(self, other) | Rich comparison operator '<'. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000012) | >>> t2 = UTCDateTime(123.000000099) | >>> t1 < t2 | False | | But the actual timestamp differ | | >>> t1.timestamp < t2.timestamp | True | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 < t2 | True | | __ne__(self, other) | Rich comparison operator '!='. | | .. rubric: Example | | Comparing two UTCDateTime object will always compare timestamps rounded | to a precision of 6 digits by default. | | >>> t1 = UTCDateTime(123.000000012) | >>> t2 = UTCDateTime(123.000000099) | >>> t1 != t2 | False | | But the actual timestamp differ | | >>> t1.timestamp != t2.timestamp | True | | Resetting the precision changes the behavior of the operator | | >>> t1.precision = 11 | >>> t1 != t2 | True | | __repr__(self) | Returns a representation of UTCDatetime object. | | __str__(self) | Returns ISO8601 string representation from current UTCDateTime object. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> str(dt) | '2008-10-01T12:30:35.045020Z' | | __sub__(self, value) | Subtracts seconds and microseconds from current UTCDateTime object. | | :type value: int, float or :class:`~obspy.core.utcdatetime.UTCDateTime` | :param value: Seconds or UTCDateTime object to subtract. Subtracting an | UTCDateTime objects results into a relative time span in seconds. | :rtype: :class:`~obspy.core.utcdatetime.UTCDateTime` or float | :return: New UTCDateTime object or relative time span in seconds. | | .. rubric:: Example | | >>> dt = UTCDateTime(1970, 1, 2, 0, 0) | >>> dt - 2 | UTCDateTime(1970, 1, 1, 23, 59, 58) | | >>> UTCDateTime(1970, 1, 2, 0, 0) - 1.123456 | UTCDateTime(1970, 1, 1, 23, 59, 58, 876544) | | >>> UTCDateTime(1970, 1, 2, 0, 0) - UTCDateTime(1970, 1, 1, 0, 0) | 86400.0 | | __unicode__(self) | Returns ISO8601 unicode representation from current UTCDateTime object. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> dt.__unicode__() | '2008-10-01T12:30:35.045020Z' | | ctime(self) | Return a string representing the date and time. | | .. rubric:: Example | | >>> UTCDateTime(2002, 12, 4, 20, 30, 40).ctime() | 'Wed Dec 4 20:30:40 2002' | | dst(self) | Returns None (to stay compatible with :class:`datetime.datetime`) | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> dt.dst() | | formatArcLink(self, *args, **kwargs) | DEPRECATED: 'formatArcLink' has been renamed to | 'format_arclink'. Use that instead. | | formatFissures(self, *args, **kwargs) | DEPRECATED: 'formatFissures' has been renamed to | 'format_fissures'. Use that instead. | | formatIRISWebService(self, *args, **kwargs) | DEPRECATED: 'formatIRISWebService' has been renamed to | 'format_iris_web_service'. Use that instead. | | formatSEED(self, *args, **kwargs) | DEPRECATED: 'formatSEED' has been renamed to | 'format_seed'. Use that instead. | | formatSeedLink(self, *args, **kwargs) | DEPRECATED: 'formatSeedLink' has been renamed to | 'format_seedlink'. Use that instead. | | format_arclink(self) | Returns string representation for the ArcLink protocol. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> print(dt.format_arclink()) | 2008,10,1,12,30,35,45020 | | format_fissures(self) | Returns string representation for the IRIS Fissures protocol. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> print(dt.format_fissures()) | 2008275T123035.0450Z | | format_iris_web_service(self) | Returns string representation usable for the IRIS Web services. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 5, 27, 12, 30, 35, 45020) | >>> print(dt.format_iris_web_service()) | 2008-05-27T12:30:35.045 | | format_seed(self, compact=False) | Returns string representation for a SEED volume. | | :type compact: bool, optional | :param compact: Delivers a compact SEED date string if enabled. Default | value is set to False. | :rtype: string | :return: Datetime string in the SEED format. | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> print(dt.format_seed()) | 2008,275,12:30:35.0450 | | >>> dt = UTCDateTime(2008, 10, 1, 0, 30, 0, 0) | >>> print(dt.format_seed(compact=True)) | 2008,275,00:30 | | format_seedlink(self) | Returns string representation for the SeedLink protocol. | | :return: string | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35.45020) | >>> print(dt.format_seedlink()) | 2008,10,1,12,30,35 | | isocalendar(self) | Returns a tuple containing (ISO year, ISO week number, ISO weekday). | | :rtype: tuple of ints | :return: Returns a tuple containing ISO year, ISO week number and ISO | weekday. | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> dt.isocalendar() | (2008, 40, 3) | | isoformat(self, sep='T') | Return a string representing the date and time in ISO 8601 format. | | :rtype: str | :return: String representing the date and time in ISO 8601 format like | YYYY-MM-DDTHH:MM:SS.mmmmmm or, if microsecond is 0, | YYYY-MM-DDTHH:MM:SS. | | .. rubric:: Example | | >>> dt = UTCDateTime(2008, 10, 1, 12, 30, 35, 45020) | >>> dt.isoformat() | '2008-10-01T12:30:35.045020' | | >>> dt = UTCDateTime(2008, 10, 1) | >>> dt.isoformat() | '2008-10-01T00:00:00' | | isoweekday(self) | Return the day of the week as an integer (Monday is 1, Sunday is 7). | | :rtype: int | :return: Returns day of the week as an integer, where Monday is 1 and | Sunday is 7. | | .. rubric:: Example | | >>> …
WARNING: some intermediate output was truncated.
In [1]:
import pyrocko
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-7849ba77b75b> in <module>() ----> 1 import pyrocko ImportError: No module named 'pyrocko'
In [2]:
import simpeg
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-2-ea22c130d0f4> in <module>() ----> 1 import simpeg ImportError: No module named 'simpeg'
In [5]:
!pip install --user pyrocko
Collecting pyrocko Could not find a version that satisfies the requirement pyrocko (from versions: ) No matching distribution found for pyrocko
In [6]:
import pyrocko
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-6-7849ba77b75b> in <module>() ----> 1 import pyrocko ImportError: No module named 'pyrocko'
In [ ]: