### Install PyEMD from local clone Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Install PyEMD after cloning the repository by navigating to the package directory and running the pip install command. ```bash python -m pip install . ``` -------------------------------- ### Install PyEMD using pip Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Install the EMD-signal package from PyPI using pip. ```bash pip install EMD-signal ``` -------------------------------- ### Install PyEMD directly from GitHub Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Install PyEMD directly from the GitHub repository using a pip command. ```bash python -m pip install git+https://github.com/laszukdawid/PyEMD.git ``` -------------------------------- ### Verify PyEMD installation Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Verify the PyEMD installation by importing the library and printing its version. ```bash python -c "import PyEMD; print(PyEMD.__version__)" ``` -------------------------------- ### Install PyEMD from source using pip Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Installs PyEMD from the local source code after cloning the repository. ```sh python3 -m pip install . ``` -------------------------------- ### Install PyEMD using uv Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Installs PyEMD using the uv tool, which can be used for adding packages to a project. ```sh uv add emd-signal ``` -------------------------------- ### Install PyEMD using conda Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Install the emd-signal package from the conda-forge channel using conda. ```bash conda install -c conda-forge emd-signal ``` -------------------------------- ### Install PyEMD with JIT support Source: https://github.com/laszukdawid/pyemd/blob/master/doc/experimental.rst To use JitEMD, install PyEMD with the 'jit' option. This command is for pip users. ```shell pip install EMD-signal[jit] ``` -------------------------------- ### Install PyEMD from source using pip and git Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Installs the latest version of PyEMD directly from its GitHub repository using pip and git in a single command. ```sh python3 -m pip install git+https://github.com/laszukdawid/PyEMD.git ``` -------------------------------- ### Import PyEMD Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Import the EMD class from the PyEMD library after installation. ```python from PyEMD import EMD ``` -------------------------------- ### Visualize EMD Components and Frequencies Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Uses the Visualisation helper from PyEMD to plot Intrinsic Mode Functions (IMFs) and their instantaneous frequencies. This example requires NumPy and PyEMD's EMD and Visualisation modules. ```python import numpy as np from PyEMD import EMD, Visualisation t = np.arange(0, 3, 0.01) S = np.sin(13*t + 0.2*t**1.4) - np.cos(3*t) # Extract imfs and residue # In case of EMD emd = EMD() emd.emd(S) imfs, res = emd.get_imfs_and_residue() # In general: #components = EEMD()(S) #imfs, res = components[:-1], components[-1] vis = Visualisation() vis.plot_imfs(imfs=imfs, residue=res, t=t, include_residue=True) vis.plot_instant_freq(t, imfs=imfs) vis.show() ``` -------------------------------- ### EEMD with Custom Extrema Detection and Plotting Source: https://github.com/laszukdawid/pyemd/blob/master/doc/examples.rst Demonstrates using Ensemble Empirical Mode Decomposition (EEMD) with custom extrema detection ('parabol') and plotting the results. This example generates a complex signal and visualizes its decomposed IMFs. ```python from PyEMD import EEMD import numpy as np import pylab as plt # Define signal t = np.linspace(0, 1, 200) sin = lambda x,p: np.sin(2*np.pi*x*t+p) S = 3*sin(18,0.2)*(t-0.2)**2 S += 5*sin(11,2.7) S += 3*sin(14,1.6) S += 1*np.sin(4*2*np.pi*(t-0.8)**2) S += t**2.1 -t # Assign EEMD to `eemd` variable eemd = EEMD() # Say we want detect extrema using parabolic method emd = eemd.EMD emd.extrema_detection="parabol" # Execute EEMD on S eIMFs = eemd.eemd(S, t) nIMFs = eIMFs.shape[0] # Plot results plt.figure(figsize=(12,9)) plt.subplot(nIMFs+1, 1, 1) plt.plot(t, S, 'r') for n in range(nIMFs): plt.subplot(nIMFs+1, 1, n+2) plt.plot(t, eIMFs[n], 'g') plt.ylabel("eIMF %i" %(n+1)) plt.locator_params(axis='y', nbins=5) plt.xlabel("Time [s]") plt.tight_layout() plt.savefig('eemd_example', dpi=120) plt.show() ``` -------------------------------- ### Configure and use JitEMD class Source: https://github.com/laszukdawid/pyemd/blob/master/doc/experimental.rst Demonstrates configuring and using the JitEMD class, which is compatible with other PyEMD classes like EEMD. The configuration requires copying default settings and updating specific parameters. ```python from PyEMD.experimental.jitemd import default_emd_config, JitEMD, get_timeline rng = np.random.RandomState(4132) s = rng.random(500) t = get_timeline(len(s), s.dtype) config = default_emd_config config["FIXE"] = 4 emd = JitEMD(config=config, spline_kind="akima") imfs = emd(s, t) ``` -------------------------------- ### Configure and use JIT EMD function Source: https://github.com/laszukdawid/pyemd/blob/master/doc/experimental.rst Shows how to use the direct JIT EMD function, which returns only the IMFs. Configuration is passed directly to the method, differing from the class-based approach. ```python from PyEMD.experimental.jitemd import default_emd_config, emd, get_timeline s = rng.random(500) t = get_timeline(len(s), s.dtype) config = default_emd_config config["FIXE"] = 4 imfs = emd(s, t, spline_kind="cubic", config=config) ``` -------------------------------- ### Basic EMD Usage Source: https://github.com/laszukdawid/pyemd/blob/master/doc/examples.rst Demonstrates the simplest way to use the EMD class. Import EMD and pass a signal to the emd method with default settings. ```python from PyEMD import EMD s = np.random.random(100) emis = EMD() IMFs = emd.emd(s) ``` -------------------------------- ### Basic EMD Usage Source: https://github.com/laszukdawid/pyemd/blob/master/doc/usage.rst Demonstrates the standard workflow for applying Empirical Mode Decomposition (EMD) using the PyEMD library. This involves importing the EMD class, initializing an EMD object, and applying it to a signal. ```python from PyEMD import EMD emd = EMD() imfs = emd(s) ``` -------------------------------- ### Setting Minimum Iterations for IMF Convergence Source: https://github.com/laszukdawid/pyemd/blob/master/doc/usage.rst Ensures a minimum number of sifting iterations for each IMF, based on convergence criteria. Set the `FIXE_H` attribute to a positive integer to guarantee at least that many iterations before checking for IMF conditions. ```python emd = EMD() emd.FIXE_H = 5 imfs = emd(s) ``` -------------------------------- ### Use CEEMDAN with NumPy Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Demonstrates how to use the CEEMDAN class from PyEMD to decompose a random NumPy array. Ensure the code is within an `if __name__ == "__main__":` block. ```python from PyEMD import CEEMDAN import numpy as np if __name__ == "__main__": s = np.random.random(100) ceemdan = CEEMDAN() cIMFs = ceemdan(s) ``` -------------------------------- ### EMD with Plotting Source: https://github.com/laszukdawid/pyemd/blob/master/doc/examples.rst A complete script to perform EMD on a signal and plot the input signal along with its Intrinsic Mode Functions (IMFs). Requires numpy and pylab for signal generation and plotting. ```python from PyEMD import EMD import numpy as np import pylab as plt # Define signal t = np.linspace(0, 1, 200) s = np.cos(11*2*np.pi*t*t) + 6*t*t # Execute EMD on signal IMF = EMD().emd(s,t) N = IMF.shape[0]+1 # Plot results plt.subplot(N,1,1) plt.plot(t, s, 'r') plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$") plt.xlabel("Time [s]") for n, imf in enumerate(IMF): plt.subplot(N,1,n+2) plt.plot(t, imf, 'g') plt.title("IMF "+str(n+1)) plt.xlabel("Time [s]") plt.tight_layout() plt.savefig('simple_example') plt.show() ``` -------------------------------- ### Use EMD2D for 2D Signals Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Demonstrates the basic usage of the EMD2D class for decomposing a 2D monochromatic NumPy array, representing an image. This is an experimental feature. ```python from PyEMD.EMD2d import EMD2D #, BEMD import numpy as np x, y = np.arange(128), np.arange(128).reshape((-1,1)) img = np.sin(0.1*x)*np.cos(0.2*y) emd2d = EMD2D() # BEMD() also works IMFs_2D = emd2d(img) ``` -------------------------------- ### Clone PyEMD repository Source: https://github.com/laszukdawid/pyemd/blob/master/doc/intro.rst Clone the PyEMD GitHub repository to your local machine. ```bash git clone https://github.com/laszukdawid/PyEMD ``` -------------------------------- ### Basic EMD decomposition Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Performs Empirical Mode Decomposition (EMD) on a given signal using default settings. Requires numpy and PyEMD. ```python from PyEMD import EMD import numpy as np s = np.random.random(100) emd = EMD() IMFs = emd(s) ``` -------------------------------- ### Setting Noise Seed for Reproducible CEEMDAN Decomposition Source: https://github.com/laszukdawid/pyemd/blob/master/doc/ceemdan.rst To ensure reproducible results with CEEMDAN, set a specific seed for the random number generator and disable parallel execution. This is crucial because the addition of random noise inherently leads to different component sets in each decomposition. ```python ceemdan = CEEMDAN(parallel=False) ceemdan.noise_seed(12345) imfs = ceemdan(signal) ``` -------------------------------- ### Set Number of Trials in CEEMDAN Source: https://github.com/laszukdawid/pyemd/blob/master/doc/speedup.rst Demonstrates how to explicitly set the number of trials for CEEMDAN. This parameter controls how many times the EMD is performed on noise-perturbed signals, affecting convergence and computation time. ```python from PyEMD import CEEMDAN ceemdan = CEEMAN(trials=20) ``` -------------------------------- ### Control Parallel Execution in EEMD Source: https://github.com/laszukdawid/pyemd/blob/master/doc/speedup.rst Demonstrates how to control parallel processing for EEMD. By default, it uses all available CPU cores. Parallelization can be disabled for debugging or when using noise_seed for reproducibility. ```python from PyEMD import EEMD, CEEMDAN # Use all available CPUs (default behavior) eemd = EEMD(trials=100) # Use specific number of processes eemd = EEMD(trials=100, processes=4) # Disable parallelization (for reproducibility with seeds or debugging) eemd = EEMD(trials=100, parallel=False) ``` -------------------------------- ### CEEMDAN Class Source: https://github.com/laszukdawid/pyemd/blob/master/doc/ceemdan.rst The CEEMDAN class provides an implementation of the Complete Ensemble Empirical Mode Decomposition with Adaptive Noise algorithm. It supports parallel execution and allows for reproducible decompositions by setting a noise seed. ```APIDOC ## CEEMDAN Class ### Description Provides an implementation of the Complete Ensemble Empirical Mode Decomposition with Adaptive Noise (CEEMDAN) algorithm. It automatically uses available CPU cores for faster computation by default. Each decomposition is unique due to the random noise added, but reproducibility can be achieved by setting a seed for the random number generator and disabling parallel execution. ### Methods - **__init__(self, T=None, S=None, EMD_kw=None, parallel=True, n_jobs=1, max_iter=2000, tol=None, **kwargs)**: Initializes the CEEMDAN object. - `parallel` (bool): Enable or disable parallel execution. Defaults to True. - `n_jobs` (int): Number of CPU cores to use when `parallel` is True. Defaults to 1. - `max_iter` (int): Maximum number of iterations for the EMD algorithm. Defaults to 2000. - `tol` (float): Tolerance for the EMD algorithm. If None, it is set to 0.5/sqrt(N) where N is the number of samples. - **noise_seed(self, seed)**: Sets the seed for the random number generator used in CEEMDAN to ensure reproducible decompositions. - `seed` (int): The seed value for the random number generator. - **__call__(self, signal, S=None, T=None)**: Performs the CEEMDAN decomposition on the input signal. - `signal` (array-like): The input signal to decompose. - `S` (array-like, optional): The ensemble of noise signals. If None, it will be generated. - `T` (array-like, optional): The time vector. If None, it will be generated. - Returns: A list of Intrinsic Mode Functions (IMFs) and the residual. ### Notes - Parallel execution is enabled by default. - To make the decomposition reproducible, set `parallel=False` and use the `noise_seed` method. ``` -------------------------------- ### Basic EEMD decomposition Source: https://github.com/laszukdawid/pyemd/blob/master/README.md Performs Ensemble Empirical Mode Decomposition (EEMD) on a given signal. Ensure the code is within an `if __name__ == "__main__":` block, especially on Windows. ```python from PyEMD import EEMD import numpy as np if __name__ == "__main__": s = np.random.random(100) eemd = EEMD() eIMFs = eemd(s) ``` -------------------------------- ### Limit Number of Output IMFs in EEMD Source: https://github.com/laszukdawid/pyemd/blob/master/doc/speedup.rst Shows how to limit the number of intrinsic mode functions (IMFs) returned by EEMD. Setting 'max_imfs' can significantly speed up computation if only the first few components are needed. ```python from PyEMD import EEMD eemd = EEMD(max_imfs=2) ``` -------------------------------- ### Change Spline Method in EEMD Source: https://github.com/laszukdawid/pyemd/blob/master/doc/speedup.rst Illustrates how to change the spline interpolation method used for spanning envelopes in EEMD. Using 'akima' or 'piecewise cubic' can offer performance benefits over the default natural cubic spline for complex signals. ```python from PyEMD import EEMD eemd = EEMD(spline_kind='akima') ``` -------------------------------- ### Setting Fixed Iterations for IMFs Source: https://github.com/laszukdawid/pyemd/blob/master/doc/usage.rst Configures the EMD decomposition to perform a fixed number of sifting iterations for each Intrinsic Mode Function (IMF). Set the `FIXE` attribute to a positive integer to specify the exact number of iterations. ```python emd = EMD() emd.FIXE = 10 imfs = emd(s) ``` -------------------------------- ### Enforce Data Type in EMD Source: https://github.com/laszukdawid/pyemd/blob/master/doc/speedup.rst Shows how to enforce a specific data type, such as float16, for EMD computations to potentially reduce memory usage and improve performance. This avoids default upcasting to float64. ```python from PyEMD import EMD emd = EMD(DTYPE=np.float16) ``` -------------------------------- ### Reproducible EEMD Decomposition Source: https://github.com/laszukdawid/pyemd/blob/master/doc/eemd.rst To ensure reproducible results with EEMD, set a seed for the random number generator and disable parallel execution. This is useful for debugging or comparing results. ```python eemd = EEMD(parallel=False) eemd.noise_seed(12345) imfs = eemd(signal) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.