UoO Dataset Demonstration¶
Cloning the damavand repository¶
In [ ]:
Copied!
!git clone https://github.com/pydamavand/damavand
!git clone https://github.com/pydamavand/damavand
Cloning into 'damavand'... remote: Enumerating objects: 263, done. remote: Counting objects: 100% (263/263), done. remote: Compressing objects: 100% (197/197), done. remote: Total 263 (delta 132), reused 196 (delta 65), pack-reused 0 (from 0) Receiving objects: 100% (263/263), 6.62 MiB | 18.69 MiB/s, done. Resolving deltas: 100% (132/132), done.
In [2]:
Copied!
!pip install -r damavand/requirements.txt
!pip install -r damavand/requirements.txt
Collecting certifi==2024.7.4 (from -r damavand/requirements.txt (line 1)) Downloading certifi-2024.7.4-py3-none-any.whl.metadata (2.2 kB) Collecting charset-normalizer==3.3.2 (from -r damavand/requirements.txt (line 2)) Downloading charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB) Collecting idna==3.7 (from -r damavand/requirements.txt (line 3)) Downloading idna-3.7-py3-none-any.whl.metadata (9.9 kB) Collecting numpy==1.26.4 (from -r damavand/requirements.txt (line 4)) Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 4.4 MB/s eta 0:00:00 Collecting pandas==2.1.4 (from -r damavand/requirements.txt (line 5)) Downloading pandas-2.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (18 kB) Requirement already satisfied: python-dateutil==2.9.0.post0 in /usr/local/lib/python3.11/dist-packages (from -r damavand/requirements.txt (line 6)) (2.9.0.post0) Collecting pytz==2024.1 (from -r damavand/requirements.txt (line 7)) Downloading pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB) Collecting rarfile==4.2 (from -r damavand/requirements.txt (line 8)) Downloading rarfile-4.2-py3-none-any.whl.metadata (4.4 kB) Requirement already satisfied: requests==2.32.3 in /usr/local/lib/python3.11/dist-packages (from -r damavand/requirements.txt (line 9)) (2.32.3) Collecting scipy==1.13.1 (from -r damavand/requirements.txt (line 10)) Downloading scipy-1.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.6/60.6 kB 4.0 MB/s eta 0:00:00 Collecting six==1.16.0 (from -r damavand/requirements.txt (line 11)) Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB) Collecting tzdata==2024.1 (from -r damavand/requirements.txt (line 12)) Downloading tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB) Collecting urllib3==2.2.2 (from -r damavand/requirements.txt (line 13)) Downloading urllib3-2.2.2-py3-none-any.whl.metadata (6.4 kB) Downloading certifi-2024.7.4-py3-none-any.whl (162 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.0/163.0 kB 6.7 MB/s eta 0:00:00 Downloading charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (140 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.3/140.3 kB 10.6 MB/s eta 0:00:00 Downloading idna-3.7-py3-none-any.whl (66 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.8/66.8 kB 4.8 MB/s eta 0:00:00 Downloading numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 34.6 MB/s eta 0:00:00 Downloading pandas-2.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.2/12.2 MB 33.5 MB/s eta 0:00:00 Downloading pytz-2024.1-py2.py3-none-any.whl (505 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 505.5/505.5 kB 21.1 MB/s eta 0:00:00 Downloading rarfile-4.2-py3-none-any.whl (29 kB) Downloading scipy-1.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 38.6/38.6 MB 14.4 MB/s eta 0:00:00 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 14.1 MB/s eta 0:00:00 Downloading urllib3-2.2.2-py3-none-any.whl (121 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 121.4/121.4 kB 7.9 MB/s eta 0:00:00 Installing collected packages: pytz, urllib3, tzdata, six, rarfile, numpy, idna, charset-normalizer, certifi, scipy, pandas Attempting uninstall: pytz Found existing installation: pytz 2025.2 Uninstalling pytz-2025.2: Successfully uninstalled pytz-2025.2 Attempting uninstall: urllib3 Found existing installation: urllib3 2.5.0 Uninstalling urllib3-2.5.0: Successfully uninstalled urllib3-2.5.0 Attempting uninstall: tzdata Found existing installation: tzdata 2025.2 Uninstalling tzdata-2025.2: Successfully uninstalled tzdata-2025.2 Attempting uninstall: six Found existing installation: six 1.17.0 Uninstalling six-1.17.0: Successfully uninstalled six-1.17.0 Attempting uninstall: numpy Found existing installation: numpy 2.0.2 Uninstalling numpy-2.0.2: Successfully uninstalled numpy-2.0.2 Attempting uninstall: idna Found existing installation: idna 3.10 Uninstalling idna-3.10: Successfully uninstalled idna-3.10 Attempting uninstall: charset-normalizer Found existing installation: charset-normalizer 3.4.2 Uninstalling charset-normalizer-3.4.2: Successfully uninstalled charset-normalizer-3.4.2 Attempting uninstall: certifi Found existing installation: certifi 2025.7.14 Uninstalling certifi-2025.7.14: Successfully uninstalled certifi-2025.7.14 Attempting uninstall: scipy Found existing installation: scipy 1.16.0 Uninstalling scipy-1.16.0: Successfully uninstalled scipy-1.16.0 Attempting uninstall: pandas Found existing installation: pandas 2.2.2 Uninstalling pandas-2.2.2: Successfully uninstalled pandas-2.2.2 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-colab 1.0.0 requires pandas==2.2.2, but you have pandas 2.1.4 which is incompatible. opencv-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 1.26.4 which is incompatible. opencv-python-headless 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 1.26.4 which is incompatible. opencv-contrib-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 1.26.4 which is incompatible. plotnine 0.14.5 requires pandas>=2.2.0, but you have pandas 2.1.4 which is incompatible. tsfresh 0.21.0 requires scipy>=1.14.0; python_version >= "3.10", but you have scipy 1.13.1 which is incompatible. thinc 8.3.6 requires numpy<3.0.0,>=2.0.0, but you have numpy 1.26.4 which is incompatible. xarray 2025.7.1 requires pandas>=2.2, but you have pandas 2.1.4 which is incompatible. mizani 0.13.5 requires pandas>=2.2.0, but you have pandas 2.1.4 which is incompatible. Successfully installed certifi-2024.7.4 charset-normalizer-3.3.2 idna-3.7 numpy-1.26.4 pandas-2.1.4 pytz-2024.1 rarfile-4.2 scipy-1.13.1 six-1.16.0 tzdata-2024.1 urllib3-2.2.2
Importings¶
In [1]:
Copied!
from damavand.damavand.datasets.downloaders import read_addresses, ZipDatasetDownloader
from damavand.damavand.datasets.digestors import UoO
from damavand.damavand.signal_processing.transformations import *
from damavand.damavand.signal_processing.feature_extraction import *
from damavand.damavand.utils import *
import os
import pandas as pd
import numpy as np
import scipy
from damavand.damavand.datasets.downloaders import read_addresses, ZipDatasetDownloader
from damavand.damavand.datasets.digestors import UoO
from damavand.damavand.signal_processing.transformations import *
from damavand.damavand.signal_processing.feature_extraction import *
from damavand.damavand.utils import *
import os
import pandas as pd
import numpy as np
import scipy
Instantiating a downloader object¶
In [2]:
Copied!
addresses = read_addresses()
downloader = ZipDatasetDownloader(addresses['UoO'])
downloader.download_extract('UoO.zip', 'UoO/')
addresses = read_addresses()
downloader = ZipDatasetDownloader(addresses['UoO'])
downloader.download_extract('UoO.zip', 'UoO/')
Instantiating a digestor object¶
In [3]:
Copied!
dataset = UoO('UoO/', ['Channel_1', 'Channel_2'], [1])
mining_params = {'win_len': 10000, 'hop_len': 10000}
dataset.mine(mining_params)
dataset = UoO('UoO/', ['Channel_1', 'Channel_2'], [1])
mining_params = {'win_len': 10000, 'hop_len': 10000}
dataset.mine(mining_params)
Aggregating data over the first channel¶
In [4]:
Copied!
df = pd.concat(dataset.data['Channel_1']).reset_index(drop = True)
df
df = pd.concat(dataset.data['Channel_1']).reset_index(drop = True)
df
Out[4]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 9993 | 9994 | 9995 | 9996 | 9997 | 9998 | 9999 | state | loading | rep | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.002528 | -0.001213 | -0.001871 | -0.002199 | -0.002199 | -0.000555 | 0.001747 | 0.001747 | 0.000102 | -0.000226 | ... | -0.007461 | -0.008448 | -0.010092 | -0.011078 | -0.011407 | -0.010092 | -0.008448 | O | C | 1 |
1 | -0.009105 | -0.008448 | -0.008776 | -0.008448 | -0.007461 | -0.006474 | -0.007132 | -0.008119 | -0.008448 | -0.007132 | ... | -0.000226 | 0.002733 | 0.003720 | 0.005693 | 0.007008 | 0.007995 | 0.007008 | O | C | 1 |
2 | 0.006022 | 0.005364 | 0.004706 | 0.004706 | 0.003062 | 0.002076 | 0.001747 | 0.000431 | -0.000226 | -0.000555 | ... | -0.010749 | -0.011736 | -0.011407 | -0.011407 | -0.010092 | -0.009763 | -0.008119 | O | C | 1 |
3 | -0.007461 | -0.007461 | -0.006146 | -0.005488 | -0.003515 | -0.002857 | -0.003515 | -0.002857 | -0.005488 | -0.005159 | ... | 0.007666 | 0.007666 | 0.007337 | 0.007008 | -0.001213 | 0.002076 | 0.002404 | O | C | 1 |
4 | 0.003062 | 0.003391 | 0.003062 | 0.002076 | 0.000760 | 0.000431 | 0.001747 | 0.002733 | -0.000226 | 0.001747 | ... | 0.003720 | 0.003391 | 0.003391 | 0.002733 | 0.002404 | 0.000431 | 0.000431 | O | C | 1 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2395 | 0.005693 | 0.003062 | 0.005693 | 0.006679 | 0.008324 | 0.011941 | 0.016545 | 0.018189 | 0.017860 | 0.015229 | ... | -0.016998 | -0.012394 | -0.008119 | -0.008119 | -0.007461 | -0.011078 | -0.005488 | O | D | 1 |
2396 | 0.000102 | 0.003720 | 0.001747 | -0.001871 | -0.005159 | -0.005488 | -0.005159 | -0.004501 | -0.006146 | -0.009763 | ... | -0.007132 | -0.007790 | -0.009434 | -0.009434 | -0.007790 | -0.004830 | -0.002199 | O | D | 1 |
2397 | -0.000555 | 0.001418 | 0.001747 | 0.007008 | 0.011612 | 0.014572 | 0.014243 | 0.014572 | 0.014572 | 0.015558 | ... | 0.000431 | 0.001747 | 0.000431 | -0.000884 | -0.000884 | -0.003844 | 0.001418 | O | D | 1 |
2398 | 0.002733 | 0.003720 | 0.002076 | 0.001089 | 0.001418 | 0.005035 | 0.006679 | 0.007995 | 0.006351 | 0.003720 | ... | -0.025219 | -0.054486 | -0.028178 | -0.027192 | -0.025876 | -0.023903 | -0.025876 | O | D | 1 |
2399 | -0.024561 | -0.024561 | -0.023575 | -0.022259 | -0.020944 | -0.021273 | -0.022259 | -0.021930 | -0.022259 | -0.021930 | ... | 0.017203 | 0.014901 | 0.011612 | 0.009639 | 0.009310 | 0.007995 | 0.001747 | O | D | 1 |
2400 rows × 10003 columns
Signals-Metadata declaration¶
In [5]:
Copied!
signals, metadata = df.iloc[:, : -3], df.iloc[:, -3 :]
signals
signals, metadata = df.iloc[:, : -3], df.iloc[:, -3 :]
signals
Out[5]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 9990 | 9991 | 9992 | 9993 | 9994 | 9995 | 9996 | 9997 | 9998 | 9999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.002528 | -0.001213 | -0.001871 | -0.002199 | -0.002199 | -0.000555 | 0.001747 | 0.001747 | 0.000102 | -0.000226 | ... | -0.006474 | -0.005817 | -0.007461 | -0.007461 | -0.008448 | -0.010092 | -0.011078 | -0.011407 | -0.010092 | -0.008448 |
1 | -0.009105 | -0.008448 | -0.008776 | -0.008448 | -0.007461 | -0.006474 | -0.007132 | -0.008119 | -0.008448 | -0.007132 | ... | -0.004501 | -0.005488 | -0.001871 | -0.000226 | 0.002733 | 0.003720 | 0.005693 | 0.007008 | 0.007995 | 0.007008 |
2 | 0.006022 | 0.005364 | 0.004706 | 0.004706 | 0.003062 | 0.002076 | 0.001747 | 0.000431 | -0.000226 | -0.000555 | ... | -0.008448 | -0.009434 | -0.010749 | -0.010749 | -0.011736 | -0.011407 | -0.011407 | -0.010092 | -0.009763 | -0.008119 |
3 | -0.007461 | -0.007461 | -0.006146 | -0.005488 | -0.003515 | -0.002857 | -0.003515 | -0.002857 | -0.005488 | -0.005159 | ... | 0.011612 | 0.010954 | 0.009310 | 0.007666 | 0.007666 | 0.007337 | 0.007008 | -0.001213 | 0.002076 | 0.002404 |
4 | 0.003062 | 0.003391 | 0.003062 | 0.002076 | 0.000760 | 0.000431 | 0.001747 | 0.002733 | -0.000226 | 0.001747 | ... | 0.004706 | 0.004706 | 0.003720 | 0.003720 | 0.003391 | 0.003391 | 0.002733 | 0.002404 | 0.000431 | 0.000431 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2395 | 0.005693 | 0.003062 | 0.005693 | 0.006679 | 0.008324 | 0.011941 | 0.016545 | 0.018189 | 0.017860 | 0.015229 | ... | -0.016011 | -0.018971 | -0.019957 | -0.016998 | -0.012394 | -0.008119 | -0.008119 | -0.007461 | -0.011078 | -0.005488 |
2396 | 0.000102 | 0.003720 | 0.001747 | -0.001871 | -0.005159 | -0.005488 | -0.005159 | -0.004501 | -0.006146 | -0.009763 | ... | -0.006474 | -0.007132 | -0.006474 | -0.007132 | -0.007790 | -0.009434 | -0.009434 | -0.007790 | -0.004830 | -0.002199 |
2397 | -0.000555 | 0.001418 | 0.001747 | 0.007008 | 0.011612 | 0.014572 | 0.014243 | 0.014572 | 0.014572 | 0.015558 | ... | 0.000431 | 0.000102 | -0.000226 | 0.000431 | 0.001747 | 0.000431 | -0.000884 | -0.000884 | -0.003844 | 0.001418 |
2398 | 0.002733 | 0.003720 | 0.002076 | 0.001089 | 0.001418 | 0.005035 | 0.006679 | 0.007995 | 0.006351 | 0.003720 | ... | -0.021930 | -0.023575 | -0.023903 | -0.025219 | -0.054486 | -0.028178 | -0.027192 | -0.025876 | -0.023903 | -0.025876 |
2399 | -0.024561 | -0.024561 | -0.023575 | -0.022259 | -0.020944 | -0.021273 | -0.022259 | -0.021930 | -0.022259 | -0.021930 | ... | 0.007995 | 0.011941 | 0.015887 | 0.017203 | 0.014901 | 0.011612 | 0.009639 | 0.009310 | 0.007995 | 0.001747 |
2400 rows × 10000 columns
In [6]:
Copied!
metadata
metadata
Out[6]:
state | loading | rep | |
---|---|---|---|
0 | O | C | 1 |
1 | O | C | 1 |
2 | O | C | 1 |
3 | O | C | 1 |
4 | O | C | 1 |
... | ... | ... | ... |
2395 | O | D | 1 |
2396 | O | D | 1 |
2397 | O | D | 1 |
2398 | O | D | 1 |
2399 | O | D | 1 |
2400 rows × 3 columns
In [7]:
Copied!
metadata['comb'] = metadata['state'] + '_' + metadata['loading']
metadata['comb'].value_counts()
metadata['comb'] = metadata['state'] + '_' + metadata['loading']
metadata['comb'].value_counts()
Out[7]:
count | |
---|---|
comb | |
O_C | 200 |
I_B | 200 |
I_D | 200 |
H_C | 200 |
O_A | 200 |
H_B | 200 |
O_B | 200 |
H_D | 200 |
I_A | 200 |
I_C | 200 |
H_A | 200 |
O_D | 200 |
Signal Processing¶
Envelope Extraction¶
In [8]:
Copied!
signals_env = env(signals)
signals_env.shape
signals_env = env(signals)
signals_env.shape
Out[8]:
(2400, 10000)
FFT¶
In [9]:
Copied!
window = scipy.signal.windows.hann(signals_env.shape[1])
freq_filter = scipy.signal.butter(25, [5, 95000], 'bandpass', fs = 200000, output='sos')
window = scipy.signal.windows.hann(signals_env.shape[1])
freq_filter = scipy.signal.butter(25, [5, 95000], 'bandpass', fs = 200000, output='sos')
In [10]:
Copied!
signals_env_fft = fft(signals_env, freq_filter = freq_filter, window = window)
signals_env_fft.shape
signals_env_fft = fft(signals_env, freq_filter = freq_filter, window = window)
signals_env_fft.shape
Out[10]:
(2400, 5000)
ZoomedFFT¶
In [11]:
Copied!
signals_env_ZoomedFFT = zoomed_fft(signals_env, 0, 1000, 2000, 200000, freq_filter = freq_filter, window = window)
signals_env_ZoomedFFT.shape
signals_env_ZoomedFFT = zoomed_fft(signals_env, 0, 1000, 2000, 200000, freq_filter = freq_filter, window = window)
signals_env_ZoomedFFT.shape
Out[11]:
(2400, 2000)
STFT¶
In [12]:
Copied!
STFT_window = scipy.signal.windows.hann(1024)
STFT_freq_filter = scipy.signal.butter(25, [5, 95000], 'bandpass', fs = 200000, output='sos')
signals_env_STFT = stft(signals_env, 1024, 200, STFT_freq_filter, STFT_window)
signals_env_STFT.shape
STFT_window = scipy.signal.windows.hann(1024)
STFT_freq_filter = scipy.signal.butter(25, [5, 95000], 'bandpass', fs = 200000, output='sos')
signals_env_STFT = stft(signals_env, 1024, 200, STFT_freq_filter, STFT_window)
signals_env_STFT.shape
Out[12]:
(2400, 45, 512)
Statistical Features¶
In [13]:
Copied!
# Defining the feature-set to be extracted
features = {'mean': (np.mean, (), {}), 'var': (np.var, (), {}), 'rms': (rms, (), {})}
# Defining the feature-set to be extracted
features = {'mean': (np.mean, (), {}), 'var': (np.var, (), {}), 'rms': (rms, (), {})}
In [14]:
Copied!
# Extracting the desired feature-set from time-domain signals
features_df = feature_extractor(signals, features)
features_df
# Extracting the desired feature-set from time-domain signals
features_df = feature_extractor(signals, features)
features_df
Out[14]:
mean | var | rms | |
---|---|---|---|
0 | 0.001243 | 0.000042 | 0.006595 |
1 | 0.002147 | 0.000039 | 0.006611 |
2 | 0.001401 | 0.000041 | 0.006567 |
3 | 0.001226 | 0.000046 | 0.006917 |
4 | 0.001823 | 0.000051 | 0.007366 |
... | ... | ... | ... |
2395 | 0.000709 | 0.000113 | 0.010639 |
2396 | 0.000366 | 0.000145 | 0.012040 |
2397 | 0.001220 | 0.000139 | 0.011851 |
2398 | 0.000523 | 0.000104 | 0.010229 |
2399 | 0.000303 | 0.000140 | 0.011821 |
2400 rows × 3 columns
Visualization¶
In [15]:
Copied!
import seaborn as sns
from matplotlib import pyplot as plt
sns.set()
fig, axes = plt.subplots(4, 1, figsize = (16, 10))
sns.lineplot(ax=axes[0], x=range(len(signals.iloc[0,:])), y = signals.iloc[0,:])
axes[0].set_title("Original Time Signal")
axes[0].set_ylabel("Amplitude")
axes[0].set_xlabel("sample")
axes[0].set_xlim(0, 10000)
sns.lineplot(ax=axes[1], x=range(len(signals_env.iloc[0,:])), y = signals_env.iloc[0, :])
axes[1].set_title("Envelope")
axes[1].set_ylabel("Amplitude")
axes[1].set_xlabel("sample")
axes[1].set_xlim(0, 10000)
sns.lineplot(ax=axes[2], x = fft_freq_axis(10000, 200000), y = signals_env_fft.iloc[0, :])
axes[2].set_title("FFT")
axes[2].set_ylabel("Amplitude")
axes[2].set_xlabel("Frequency (Hz)")
axes[2].set_xlim(0, 5000)
sns.lineplot(ax=axes[3], x = zoomed_fft_freq_axis(0, 1000, 2000), y = signals_env_ZoomedFFT.iloc[0, :])
axes[3].set_title("Zoomed FFT")
axes[3].set_ylabel("Amplitude")
axes[3].set_xlabel("Frequency (Hz)")
axes[3].set_xlim(0, 1000)
plt.subplots_adjust(hspace = 0.75)
fig.show()
import seaborn as sns
from matplotlib import pyplot as plt
sns.set()
fig, axes = plt.subplots(4, 1, figsize = (16, 10))
sns.lineplot(ax=axes[0], x=range(len(signals.iloc[0,:])), y = signals.iloc[0,:])
axes[0].set_title("Original Time Signal")
axes[0].set_ylabel("Amplitude")
axes[0].set_xlabel("sample")
axes[0].set_xlim(0, 10000)
sns.lineplot(ax=axes[1], x=range(len(signals_env.iloc[0,:])), y = signals_env.iloc[0, :])
axes[1].set_title("Envelope")
axes[1].set_ylabel("Amplitude")
axes[1].set_xlabel("sample")
axes[1].set_xlim(0, 10000)
sns.lineplot(ax=axes[2], x = fft_freq_axis(10000, 200000), y = signals_env_fft.iloc[0, :])
axes[2].set_title("FFT")
axes[2].set_ylabel("Amplitude")
axes[2].set_xlabel("Frequency (Hz)")
axes[2].set_xlim(0, 5000)
sns.lineplot(ax=axes[3], x = zoomed_fft_freq_axis(0, 1000, 2000), y = signals_env_ZoomedFFT.iloc[0, :])
axes[3].set_title("Zoomed FFT")
axes[3].set_ylabel("Amplitude")
axes[3].set_xlabel("Frequency (Hz)")
axes[3].set_xlim(0, 1000)
plt.subplots_adjust(hspace = 0.75)
fig.show()
In [16]:
Copied!
t = np.linspace(0, 1/20, 45)
f = fft_freq_axis(1024, 200000)
fig, ax = plt.subplots(figsize = (16, 8))
ax = sns.heatmap(signals_env_STFT[0, :, :], xticklabels = np.round(f, decimals = 2), yticklabels = np.round(t, decimals = 2), annot = False, cbar = False)
ax.set(xlabel = 'Frequency (Hz)', ylabel = 'Time (sec)')
ax.set_title('STFT')
ax.set_xticks(ax.get_xticks()[::20])
ax.set_yticks(ax.get_yticks()[::5])
fig.show()
t = np.linspace(0, 1/20, 45)
f = fft_freq_axis(1024, 200000)
fig, ax = plt.subplots(figsize = (16, 8))
ax = sns.heatmap(signals_env_STFT[0, :, :], xticklabels = np.round(f, decimals = 2), yticklabels = np.round(t, decimals = 2), annot = False, cbar = False)
ax.set(xlabel = 'Frequency (Hz)', ylabel = 'Time (sec)')
ax.set_title('STFT')
ax.set_xticks(ax.get_xticks()[::20])
ax.set_yticks(ax.get_yticks()[::5])
fig.show()