scatcluster.processing.scattering

Classes

Scattering

Module Contents

class scatcluster.processing.scattering.Scattering[source]
reduce_type()[source]

Pooling operation performed on the last axis.

load_data_times()[source]

Load the data times from a file and store them in the data_times attribute.

This function reads the data times from a file located at {self.data_savepath}data/{self.data_network}_{self.data_station}_{self.data_location}_ {self.network_name}_times.npy and stores them in the data_times attribute.

build_day_list() None[source]

Build data_day_list object

build_channel_list() None[source]
stream_process(stream: obspy.core.stream.Stream) obspy.core.stream.Stream[source]

PreProcessing of obspy stream before calculating scattering coefficients

Parameters:

stream (Stream) – Obspy Stream

Returns:

processed obspy Stream

Return type:

Stream

load_data(starttime: obspy.core.UTCDateTime, endtime: obspy.core.UTCDateTime, channel: str) obspy.core.stream.Stream[source]

Load the seismic and trim according to data_starttime and data_endtime

Parameters:
  • starttime (UTCDateTime) – Start datetime of the trim

  • endtime (UTCDateTime) – End datetime of the trim

  • channel (str) – Channel selected

Returns:

Processed obspy stream

Return type:

Stream

network_build_scatcluster() None[source]

Build scatcluster network, assign to self.net and store as pickle

plot_network_filter_banks(savefig: bool = True, **kwargs) None[source]

Plot the filter banks

load_sample_data() obspy.core.stream.Stream[source]

Load sample

plot_sample_spectra() None[source]

Plot the Network filter spectra

process_sample_data(plot_spectra: bool = True) None[source]

Process the sample data range. This involes: (1) load the data and process, (2) define the sample_times and sample_data, (3) segmentize into sample_data_segments and respective sample_times_scatterings, (4) transform into sample_scattering_coefficients, (5) plot filter spectra

plot_seismic(sample: bool = False)[source]

Plot the seismic data.

Parameters:

sample (bool) – If True, plot the sample data. Otherwise, plot the regular data.

process_scatcluster_yyyy_mm_dd(day_start: str, day_end: str) None[source]

Process scatcluster for a single day.

Parameters:
  • day_start (str) – Start day of format “YYYY-MM-DD”

  • day_end (str) – End day of format “YYYY-MM-DD”

process_scatcluster_for_range() None[source]

Process scatcluster_yyyy_mm_dd for range of YYYY-MM-DDs

filters_per_layer(model)[source]

Get the number of filters per layer.

layer_shape(model, order)[source]
log(dataset, waterlevel=1e-10)[source]

Get the log of the scattering coefficients.

Parameters:
  • dataset (xarray.Dataset) – The scattering coefficients in the xarray.Dataset format.

  • waterlevel (float) – The waterlevel to apply to the scattering coefficients.

Returns:

The scattering coefficients in the xarray.Dataset format.

Return type:

xarray.Dataset

nyquist_mask(dataset)[source]

Mask the scattering coefficients with a Nyquist frequency.

The scattering coefficients of order 2 are masked when the frequency f2 is greater than the frequency f1 to avoid aliasing.

Parameters:

dataset (xarray.Dataset) – The scattering coefficients in the xarray.Dataset format.

Returns:

The scattering coefficients in the xarray.Dataset format.

Return type:

xarray.Dataset

normalize(dataset)[source]

Normalize the scattering coefficients.

Parameters:

dataset (xarray.Dataset) – The scattering coefficients in the xarray.Dataset format.

Returns:

The scattering coefficients in the xarray.Dataset format.

Return type:

xarray.Dataset

min_max_scaling(dataset)[source]

Min-Max scaling the scattering coefficients.

Parameters:

dataset (xarray.Dataset) – The scattering coefficients in the xarray.Dataset format.

Returns:

The scattering coefficients in the xarray.Dataset format.

Return type:

xarray.Dataset

process_vectorized_scattering_coefficients() None[source]

Process the vectorized scattering coefficients by loading data from files, reshaping the coefficients, standardizing in log space, and vectorizing them. Display statistics from the vectorization and store the processed data.

Parameters:

self – An instance of the class.

vectorize_scattering_coefficients_xarray(coefficients)[source]
load_scattering_coefficients_xarray()[source]

Load the scattering coefficients from an xarray dataset file and store them in the scattering_coefficients_xarray attribute.

Returns:

The loaded scattering coefficients dataset.

Return type:

xr.Dataset

plot_scattering_coefficients_normalisation(**kwargs)[source]

Plot the normalization of scattering coefficients. This function loads the scattering coefficients from an xarray dataset file and plots the normalization of the coefficients. The plot is saved as a PNG file in the specified directory.

Parameters:
  • self (object) – The instance of the class.

  • **kwargs (dict) – Additional keyword arguments to pass to the plt.subplots function.

preload_times()[source]

Preloads the times data from a numpy file and assigns it to the data_times attribute of the class.

load_scat_coef_vectorized()[source]