pysdkit.data#

Created on 2024/7/22 22:56 @author: Whenxuan Wang @email: wwhenxuan@gmail.com

pysdkit.data._time_series

Created on 2025/02/10 18:35:29 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate time series test examples

pysdkit.data._add_noise

Created on Sat Mar 8 21:45:02 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com

pysdkit.data._cube

Created on 2025/02/11 00:19:03 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate 3D cube test sample

pysdkit.data._generator

Created on Sat Mar 8 21:45:02 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com

pysdkit.data._image

Created on 2025/02/02 13:01:46 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate samples for testing 2D image data

data._time_series#

Created on 2025/02/10 18:35:29 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate time series test examples

pysdkit.data._time_series.generate_time_series(duration: int = 300, periodicities: ndarray = array([10, 30, 50]), num_harmonics: ndarray = array([3, 2, 2]), std: ndarray = array([2, 3, 5]), seed: int | None = 42) ndarray[source]#

Generates a time series data by combining multiple seasonal components with different periodicities, numbers of harmonics, and noise levels. Each component represents a periodic signal, and the final series is the sum of these components.

Parameters:
  • duration – The length of the time series to generate, in terms of number of time steps.

  • periodicities – An array of the periodicities (number of time steps per cycle) for each seasonal component.

  • num_harmonics – An array specifying the number of harmonics (sinusoidal components) to use for each seasonal component.

  • std – An array of standard deviations of the noise for each seasonal component. The noise is added to each harmonic.

  • seed – A random seed for reproducibility. If None, a random seed is used.

Returns:

A numpy array representing the generated time series that combines all the seasonal components.

data.add_noise#

Created on Sat Mar 8 21:45:02 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com

pysdkit.data._add_noise.add_noise(N: int, Mean: float, STD: float) ndarray[source]#

Generate Gaussian white noise with mean values Mean and standard deviation STD.

Parameters:
  • N – The number of samples.

  • Mean – The mean value of the noise.

  • STD – The standard deviation of the noise.

Returns:

numpy.ndarray: Generated Gaussian white noise.

data.cube#

Created on 2025/02/11 00:19:03 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate 3D cube test sample

pysdkit.data._cube.test_multivariate_cube(case: List[int] | Tuple[int] | ndarray | None = None, low: int | ndarray = 0, high: int | ndarray = 10, sampling_rate: int = 30) ndarray[source]#

Generate 3D cubes data for testing 3D multivariate signal decomposition algorithms

Parameters:
  • case – The test cases to use are specified by inputting a list or tuple or ndarray in the range [1, 2, 3, 4, 5, 6], The default parameter settings are [1, 2, 3].

  • low – Minimum value of grid matrix, If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.

  • high – Maximum value of grid matrix, If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.

  • sampling_rate – The sampling rate of the grid matrix, which is the number of points in the matrix

Returns:

Get 3D cube data of multiple different channels

pysdkit.data._cube.test_univariate_cube(case: int = 1, low: int | ndarray = 0, high: int | ndarray = 10, sampling_rate: int = 30) ndarray[source]#

Generate a 3D cube data for testing 3D univariate signal decomposition algorithms

Parameters:
  • case – Test case, range in [1, 2, 3, 4, 5, 6]

  • low – Minimum value of grid matrix, If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.

  • high – Maximum value of grid matrix, If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.

  • sampling_rate – The sampling rate of the grid matrix, which is the number of points in the matrix

Returns:

Get a 3D cube data of a specified range

data.generator#

Created on Sat Mar 8 21:45:02 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com

pysdkit.data._generator.generate_am_signal(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.1, carrier_freq: float = 100.0, modulating_freq: float = 5.0, mod_index: float = 1.0, rand_state: int = 42) Tuple[array, array][source]#

Generate an Amplitude Modulated (AM) signal with Gaussian noise.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • carrier_freq – Frequency of the carrier signal.

  • modulating_freq – Frequency of the modulating signal.

  • mod_index – Modulation index.

  • rand_state – Random seed for the noise generation.

Returns:

Tuple containing time array and the AM signal with noise.

pysdkit.data._generator.generate_cos_signal(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.2, frequency: float = 10.0, rand_state: int = 42) Tuple[array, array][source]#

Generate a Cosine signal with Gaussian noise and a sinusoidal component.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • frequency – Frequency of the sinusoidal component.

  • rand_state – Random seed for the noise in signal.

Returns:

Array of the Cosine signal.

pysdkit.data._generator.generate_exponential_signal(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.1, decay_rate: float = 1.0, initial_amplitude: float = 1.0, rand_state: int = 42) Tuple[array, array][source]#

Generate an exponentially decaying signal with Gaussian noise.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • decay_rate – Exponential decay rate (larger values decay faster).

  • initial_amplitude – Initial amplitude of the signal.

  • rand_state – Random seed for the noise generation.

Returns:

Tuple containing time array and the exponentially decaying signal with noise.

pysdkit.data._generator.generate_sawtooth_wave(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.2, frequency: float = 10.0, rand_state: int = 42) Tuple[array, array][source]#

Generate a sawtooth wave signal with Gaussian noise.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • frequency – Frequency of the sawtooth wave component.

  • rand_state – Random seed for the noise in signal.

Returns:

Tuple containing time array and the sawtooth wave signal with noise.

pysdkit.data._generator.generate_sin_signal(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.2, frequency: float = 10.0, rand_state: int = 42) Tuple[array, array][source]#

Generate a Cosine signal with Gaussian noise and a sinusoidal component.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • frequency – Frequency of the sinusoidal component.

  • rand_state – Random seed for the noise in signal.

Returns:

Array of the Cosine signal.

pysdkit.data._generator.generate_square_wave(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.2, frequency: float = 10.0, rand_state: int = 42) Tuple[array, array][source]#

Generate a square wave signal with Gaussian noise.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • frequency – Frequency of the square wave component.

  • rand_state – Random seed for the noise in signal.

Returns:

Tuple containing time array and the square wave signal with noise.

pysdkit.data._generator.generate_triangle_wave(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.2, frequency: float = 10.0, rand_state: int = 42) Tuple[array, array][source]#

Generate a triangular wave signal with Gaussian noise.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • frequency – Frequency of the triangular wave component.

  • rand_state – Random seed for the noise in signal.

Returns:

Tuple containing time array and the triangular wave signal with noise.

pysdkit.data._generator.test_emd(duration: float = 1.0, sampling_rate: int = 1000, noise_level: float = 0.1, random_state: int = 42) Tuple[array, array][source]#

Generate cos(22 * pi * t ^ 2) + 6 * t ^ 2 for _emd test.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

  • noise_level – Standard deviation of the Gaussian noise.

  • random_state – Random seed for the noise generation.

Returns:

Tuple containing time array and the cos(22 * pi * t ^ 2) + 6 * t ^ 2 signal with noise.

pysdkit.data._generator.test_hht(duration: float = 2.0, sampling_rate: int = 1000)[source]#

Generate data generation function to verify Hilbert-Huang transform.

Parameters:
  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

Returns:

Tuple of time array and signal for hht testing.

pysdkit.data._generator.test_multivariate_signal(case: int = 1, duration: float = 1.0, sampling_rate: int = 1000) Tuple[array, array][source]#

Select a test case for a 1D multivariate signal based on the input case

Parameters:
  • case – the test number in [1, 2, 3]

  • duration – Length of the signal in seconds.

  • sampling_rate – Number of samples per second.

Returns:

Tuple containing time array and the generated signal.

Returns:

the generated signal for multivariate 1D.

data.image#

Created on 2025/02/02 13:01:46 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Generate samples for testing 2D image data

pysdkit.data._image.test_grayscale() ndarray | None[source]#

Load a sample 2D grayscale image for testing, the size is [256, 256]

We download the data from https://raw.githubusercontent.com/wwhenxuan/PySDKit/main/pysdkit/data/texture.txt

This data comes from https://www.mathworks.com/matlabcentral/fileexchange/45918-two-dimensional-variational-mode-decomposition Konstantin, Dragomiretskiy, and Dominique Zosso. “Two-dimensional variational mode decomposition.” Energy Minimization Methods in Computer Vision and Pattern Recognition. Vol. 8932. 2015.

pysdkit.data._image.test_multivariate_image(case: Tuple = (1, 2, 3), low: int = 0, high: int = 10, sampling_rate: int | None = 256) ndarray[source]#

Generate multivariate image for 2D decomposition, the number of image is len(case)

please input the case from 1 to 7

Parameters:
  • case – case number in 1~7

  • low – Minimum value of grid matrix

  • high – Maximum value of grid matrix

  • sampling_rate – The sampling rate of the grid matrix, which is the number of points in the matrix

Returns:

the generated image for 2D decomposition

pysdkit.data._image.test_univariate_image(case: int = 1, low: int = 0, high: int = 10, sampling_rate: int | None = 256) ndarray[source]#

Generate a single image for 2D decomposition

please input the case from 1 to 7

Parameters:
  • case – case number in 1~7

  • low – Minimum value of grid matrix

  • high – Maximum value of grid matrix

  • sampling_rate – The sampling rate of the grid matrix, which is the number of points in the matrix

Returns:

the generated image for 2D decomposition