xdas.atoms.Trigger#

class xdas.atoms.Trigger(thresh, dim='last')[source]#

Find picks in a data array along a given axis based on a given threshold.

The pick findings use a triggering mechanism where triggers are turned on and off based on the threshold crossings. The trigger off threshold is half of the trigger on threshold. Picks are determined by finding the maximum value on each triggered region.

Parameters:
  • thresh (float) – The threshold value for picking.

  • dim (str, optional) – The dimension along which to find picks. Defaults to “last”.

Notes

For more details see the documentation of the initialize and call methods.

Examples

>>> import numpy as np
>>> import xdas as xd
>>> from xdas.atoms import Trigger

Use case:

>>> cft = xd.DataArray(
...     data=[[0.0, 0.1, 0.9, 0.8, 0.2, 0.1, 0.6, 0.7, 0.3, 0.2]],
...     coords={
...         "space": [0.0],
...         "time": {"tie_indices": [0, 9], "tie_values": [0.0, 9.0]},
...     },
... )

Chunked processing using atomic processing:

>>> atom = Trigger(thresh=0.5, dim="time")
>>> chunks = xd.split(cft, 3, dim="time")
>>> result = []
>>> for chunk in chunks:
...     picks = atom(chunk, chunk_dim="time")
...     result.append(picks)
>>> result = pd.concat(result, ignore_index=True)
>>> result
   space  time  value
0    0.0   2.0    0.9
1    0.0   7.0    0.7
__init__(thresh, dim='last')[source]#

Methods

__init__(thresh[, dim])

call(cft, **flags)

Call the trigger.

initialize(cft, **flags)

Initialize the trigger with the following states.

initialize_from_state()

Initialise the atom from its current state.

load_state(path)

Load the atom state from the NetCDF4 file at path.

reset()

Reset all state entries to ... (uninitialised sentinel).

save_state(path)

Serialise the current state to a NetCDF4 file at path.

set_state(state)

Restore the atom state from a previously saved state dict.

Attributes

initialized

True if every state key has been initialised (no ... sentinels remain).

state

Dict of the current state, including nested atom states.