scatseisnet =========== .. py:module:: scatseisnet .. autoapi-nested-parse:: Deep scattering transform clustering on segmented time series. This package implements the deep scattering transform clustering on segmented time series. The deep scattering transform is a deep learning architecture that can be used to extract features from time series. .. dropdown:: Terms of use .. code-block:: text Copyright (C) 2023 Léonard Seydoux. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/scatseisnet/network/index /autoapi/scatseisnet/operation/index /autoapi/scatseisnet/wavelet/index Classes ------- .. autoapisummary:: scatseisnet.ScatteringNetwork Package Contents ---------------- .. py:class:: ScatteringNetwork(*layer_kwargs: dict, bins: int = 128, sampling_rate: float = 1.0, verbose: bool = False) Scattering network graph. :param layer_kwargs: The keyword argiments of each filter bank keyword arguments, in the form of a :series of :class:`dict` objects with the keyword arguments for :class:`~.ComplexMorletBank`. The number of network layers is defined by the number of arguments. Please see the :class:`~.ComplexMorletBank` documentation for more information about the keyword arguments themselves. :type layer_kwargs: :class:`dict` :param bins: Number of time samples per signal windows. By default, this value is 128. Note that once set, the value cannot be changed. :type bins: :class:`int`, optional :param sampling_rate: Input data sampling rate in Hertz. This is useful to keep track of physical frequencies in the filterbanks properties. The default value is 1.0 (reduced frequency). :type sampling_rate: :class:`float`, optional .. !! processed by numpydoc !! .. py:attribute:: sampling_rate :value: 1.0 .. py:attribute:: bins :value: 128 .. py:attribute:: verbose :value: False .. py:attribute:: banks .. py:attribute:: taper .. py:method:: __len__() -> int Number of layers (or depth) of the scattering network. .. !! processed by numpydoc !! .. py:method:: __repr__() -> str String representation of the scattering network. .. !! processed by numpydoc !! .. py:method:: transform_segment(segment: numpy.ndarray, reduce_type: Union[Callable, None] = None) -> list Scattering network transformation. This function transforms a single segment with the scattering network. The `reduce_type` parameter defines the pooling operation. It can be either `max`, `avg`, or `med`. .. note:: If the ``reduce_type`` parameter is not defined, the function returns the scalogram of each layer of the scattering network (i.e. the continuous wavelet transform of the input segment at each layer) without any pooling operation. :param segment: The input segment time series to calculate the scattering coefficients from. The shape of the array must be ``(bins, n_channels)``, where ``bins`` is the number of time samples per segment and ``n_channels`` is the number of channels. The number of channels can be 1 or more. :type segment: :class:`numpy.ndarray` :param reduce_type: The reduction function (e.g. :func:`numpy.mean`). If not defined, the function returns the scalogram of each layer of the scattering network, without any pooling operation. :type reduce_type: callable, optional :returns: **scattering_coefficients** -- The scattering coefficients per layer of the scattering network. :rtype: :class:`list` of array-like .. rubric:: Examples >>> import numpy as np >>> from scatseisnet import ScatteringNetwork >>> layer_kwargs = [ ... {"octaves": 8, "resolution": 8}, ... {"octaves": 12, "resolution": 1}, ... ] >>> network = ScatteringNetwork(*layer_kwargs) >>> segment = np.random.randn(128) >>> scattering_coefficients = network.transform_segment(segment, reduce_type=np.max) >>> len(scattering_coefficients) 2 >>> scattering_coefficients[0].shape (64,) >>> scattering_coefficients[1].shape (64, 12) .. !! processed by numpydoc !! .. py:method:: transform(segments: numpy.ndarray, taper_alpha=None, reduce_type: Union[Callable, None] = None) -> list Transform a set of segments. This function is a wrapper to loop over a series of segments with the :meth:`~.transform_segment` method. Please refer to this method for more information. :param segments: The input segment time series to calculate the scattering coefficients from. The shape of the array must be ``(n_segments, bins, n_channels)``, where ``bins`` is the number of time samples per segment and ``n_channels`` is the number of channels. The number of channels can be 1 or more. :type segments: :class:`numpy.ndarray` :param taper_alpha: Tapering factor for the time domain. If None, no tapering is applied (default None). :type taper_alpha: float, optional :param reduce_type: The reduction function (e.g. :func:`numpy.mean`). If not defined, the function returns the scalogram of each layer of the scattering network, without any pooling operation. :type reduce_type: callable, optional :returns: **scattering_coefficients** -- The scattering coefficients per layer of the scattering network. :rtype: :class:`list` of array-like .. rubric:: Examples >>> import numpy as np >>> from scatseisnet import ScatteringNetwork >>> layer_kwargs = [ ... {"octaves": 8, "resolution": 8}, ... {"octaves": 12, "resolution": 1}, ... ] >>> network = ScatteringNetwork(*layer_kwargs) >>> segments = np.random.randn(10, 128) >>> scattering_coefficients = network.transform(segments, np.max) >>> len(scattering_coefficients) 2 >>> scattering_coefficients[0].shape (10, 64) >>> scattering_coefficients[1].shape (10, 64, 12) .. !! processed by numpydoc !!