From f2ca7dadb4a60d9fdbdc1c9c0fffae6480ca98e8 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Fri, 1 Dec 2023 02:13:36 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- SVD_data_cleaning/README.md | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/SVD_data_cleaning/README.md b/SVD_data_cleaning/README.md index 0b4346d..f695c50 100644 --- a/SVD_data_cleaning/README.md +++ b/SVD_data_cleaning/README.md @@ -56,6 +56,8 @@ plt.xlabel("Time [s]") plt.ylabel("Dirty data ") plt.show() ``` +Let us look at the first three of the 100 channels. + We get three fully random time series ![figure 1](image1.png) @@ -70,4 +72,52 @@ Both combined with random mixing coefficients ## Estimating the common signal +```python +import numpy as np +import scipy +import matplotlib.pyplot as plt + +file = np.load("data.npz") + +clean_data = file["clean_data"] +perturbation = file["perturbation"] +dirty_data = file["dirty_data"].copy() +t: np.ndarray = np.arange(0, dirty_data.shape[0]) / 1000 + +dirty_data -= dirty_data.mean(axis=0, keepdims=True) +u, s, Vh = scipy.linalg.svd(dirty_data, full_matrices=False) + +to_remove = u[:, 0][..., np.newaxis] * Vh[0, :][np.newaxis, ...] * s[0] + +dirty_data = file["dirty_data"].copy() +dirty_data -= to_remove + +for i in range(0, 3): + plt.subplot(3, 1, 1 + i) + plt.plot(t, perturbation[:, i], label="original") + plt.plot(t, to_remove[:, i], "--", label="reconstructed") + plt.xlabel("Time [s]") + plt.ylabel("Perturbation ") + plt.legend(loc="upper right") +plt.show() + +for i in range(0, 3): + plt.subplot(3, 1, 1 + i) + plt.plot(t, clean_data[:, i], label="original") + plt.plot(t, dirty_data[:, i], "--", label="reconstructed") + plt.xlabel("Time [s]") + plt.ylabel("clean data waveform") + plt.legend(loc="upper right") +plt.show() +``` + +This is the original and the reconstructed pertubation for the first three channels + +![figure 4](image4.png) + + +This is the original clean data and the reconstructed clean data for the first three channels + +![figure 5](image5.png) +