CWRU 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 | 14.71 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 1.8 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 2.4 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 1.6 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 5.0 MB/s eta 0:00:00 Downloading idna-3.7-py3-none-any.whl (66 kB) āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 66.8/66.8 kB 3.9 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 35.5 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 35.9 MB/s eta 0:00:00 Downloading pytz-2024.1-py2.py3-none-any.whl (505 kB) āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 505.5/505.5 kB 34.4 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 16.6 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 26.0 MB/s eta 0:00:00 Downloading urllib3-2.2.2-py3-none-any.whl (121 kB) āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 121.4/121.4 kB 9.6 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, CwruDownloader
from damavand.damavand.datasets.digestors import CWRU
from damavand.damavand.signal_processing.transformations import *
from damavand.damavand.signal_processing.feature_extraction import *
from damavand.damavand.utils import *
import pandas as pd
import numpy as np
import scipy
from damavand.damavand.datasets.downloaders import read_addresses, CwruDownloader
from damavand.damavand.datasets.digestors import CWRU
from damavand.damavand.signal_processing.transformations import *
from damavand.damavand.signal_processing.feature_extraction import *
from damavand.damavand.utils import *
import pandas as pd
import numpy as np
import scipy
Instantiating a downloader object¶
InĀ [2]:
Copied!
addresses = read_addresses()
downloader = CwruDownloader(addresses['CWRU'])
downloader.download('CWRU/')
while len(list(downloader.undownloaded.keys())) > 0:
downloader.redownload()
print(downloader.undownloaded)
addresses = read_addresses()
downloader = CwruDownloader(addresses['CWRU'])
downloader.download('CWRU/')
while len(list(downloader.undownloaded.keys())) > 0:
downloader.redownload()
print(downloader.undownloaded)
Downloading: normal_1797_12K.mat Downloaded: normal_1797_12K.mat Downloading: normal_1772_12K.mat Downloaded: normal_1772_12K.mat Downloading: normal_1750_12K.mat Downloaded: normal_1750_12K.mat Downloading: normal_1730_12K.mat Downloaded: normal_1730_12K.mat Downloading: DE_IR_007_1797_12K.mat Downloaded: DE_IR_007_1797_12K.mat Downloading: DE_IR_007_1772_12K.mat Downloaded: DE_IR_007_1772_12K.mat Downloading: DE_IR_007_1750_12K.mat Downloaded: DE_IR_007_1750_12K.mat Downloading: DE_IR_007_1730_12K.mat Downloaded: DE_IR_007_1730_12K.mat Downloading: DE_IR_014_1797_12K.mat Downloaded: DE_IR_014_1797_12K.mat Downloading: DE_IR_014_1772_12K.mat Downloaded: DE_IR_014_1772_12K.mat Downloading: DE_IR_014_1750_12K.mat Downloaded: DE_IR_014_1750_12K.mat Downloading: DE_IR_014_1730_12K.mat Downloaded: DE_IR_014_1730_12K.mat Downloading: DE_IR_021_1797_12K.mat Downloaded: DE_IR_021_1797_12K.mat Downloading: DE_IR_021_1772_12K.mat Downloaded: DE_IR_021_1772_12K.mat Downloading: DE_IR_021_1750_12K.mat Downloaded: DE_IR_021_1750_12K.mat Downloading: DE_IR_021_1730_12K.mat Downloaded: DE_IR_021_1730_12K.mat Downloading: DE_IR_028_1797_12K.mat Downloaded: DE_IR_028_1797_12K.mat Downloading: DE_IR_028_1772_12K.mat Downloaded: DE_IR_028_1772_12K.mat Downloading: DE_IR_028_1750_12K.mat Downloaded: DE_IR_028_1750_12K.mat Downloading: DE_IR_028_1730_12K.mat Downloaded: DE_IR_028_1730_12K.mat Downloading: DE_Ball_007_1797_12K.mat Downloaded: DE_Ball_007_1797_12K.mat Downloading: DE_Ball_007_1772_12K.mat Downloaded: DE_Ball_007_1772_12K.mat Downloading: DE_Ball_007_1750_12K.mat Downloaded: DE_Ball_007_1750_12K.mat Downloading: DE_Ball_007_1730_12K.mat Downloaded: DE_Ball_007_1730_12K.mat Downloading: DE_Ball_014_1797_12K.mat Downloaded: DE_Ball_014_1797_12K.mat Downloading: DE_Ball_014_1772_12K.mat Downloaded: DE_Ball_014_1772_12K.mat Downloading: DE_Ball_014_1750_12K.mat Downloaded: DE_Ball_014_1750_12K.mat Downloading: DE_Ball_014_1730_12K.mat Downloaded: DE_Ball_014_1730_12K.mat Downloading: DE_Ball_021_1797_12K.mat Downloaded: DE_Ball_021_1797_12K.mat Downloading: DE_Ball_021_1772_12K.mat Downloaded: DE_Ball_021_1772_12K.mat Downloading: DE_Ball_021_1750_12K.mat Downloaded: DE_Ball_021_1750_12K.mat Downloading: DE_Ball_021_1730_12K.mat Downloaded: DE_Ball_021_1730_12K.mat Downloading: DE_Ball_028_1797_12K.mat Downloaded: DE_Ball_028_1797_12K.mat Downloading: DE_Ball_028_1772_12K.mat Downloaded: DE_Ball_028_1772_12K.mat Downloading: DE_Ball_028_1750_12K.mat Downloaded: DE_Ball_028_1750_12K.mat Downloading: DE_Ball_028_1730_12K.mat Downloaded: DE_Ball_028_1730_12K.mat Downloading: DE_OR@6_007_1797_12K.mat Downloaded: DE_OR@6_007_1797_12K.mat Downloading: DE_OR@6_007_1772_12K.mat Downloaded: DE_OR@6_007_1772_12K.mat Downloading: DE_OR@6_007_1750_12K.mat Downloaded: DE_OR@6_007_1750_12K.mat Downloading: DE_OR@6_007_1730_12K.mat Downloaded: DE_OR@6_007_1730_12K.mat Downloading: DE_OR@6_014_1797_12K.mat Downloaded: DE_OR@6_014_1797_12K.mat Downloading: DE_OR@6_014_1772_12K.mat Downloaded: DE_OR@6_014_1772_12K.mat Downloading: DE_OR@6_014_1750_12K.mat Downloaded: DE_OR@6_014_1750_12K.mat Downloading: DE_OR@6_014_1730_12K.mat Downloaded: DE_OR@6_014_1730_12K.mat Downloading: DE_OR@6_021_1797_12K.mat Downloaded: DE_OR@6_021_1797_12K.mat Downloading: DE_OR@6_021_1772_12K.mat Downloaded: DE_OR@6_021_1772_12K.mat Downloading: DE_OR@6_021_1750_12K.mat Downloaded: DE_OR@6_021_1750_12K.mat Downloading: DE_OR@6_021_1730_12K.mat Downloaded: DE_OR@6_021_1730_12K.mat Downloading: DE_OR@3_007_1797_12K.mat Downloaded: DE_OR@3_007_1797_12K.mat Downloading: DE_OR@3_007_1772_12K.mat Downloaded: DE_OR@3_007_1772_12K.mat Downloading: DE_OR@3_007_1750_12K.mat Downloaded: DE_OR@3_007_1750_12K.mat Downloading: DE_OR@3_007_1730_12K.mat Downloaded: DE_OR@3_007_1730_12K.mat Downloading: DE_OR@3_021_1797_12K.mat Downloaded: DE_OR@3_021_1797_12K.mat Downloading: DE_OR@3_021_1772_12K.mat Downloaded: DE_OR@3_021_1772_12K.mat Downloading: DE_OR@3_021_1750_12K.mat Downloaded: DE_OR@3_021_1750_12K.mat Downloading: DE_OR@3_021_1730_12K.mat Downloaded: DE_OR@3_021_1730_12K.mat Downloading: DE_OR@12_007_1797_12K.mat Downloaded: DE_OR@12_007_1797_12K.mat Downloading: DE_OR@12_007_1772_12K.mat Downloaded: DE_OR@12_007_1772_12K.mat Downloading: DE_OR@12_007_1750_12K.mat Downloaded: DE_OR@12_007_1750_12K.mat Downloading: DE_OR@12_007_1730_12K.mat Downloaded: DE_OR@12_007_1730_12K.mat Downloading: DE_OR@12_021_1797_12K.mat Downloaded: DE_OR@12_021_1797_12K.mat Downloading: DE_OR@12_021_1772_12K.mat Downloaded: DE_OR@12_021_1772_12K.mat Downloading: DE_OR@12_021_1750_12K.mat Downloaded: DE_OR@12_021_1750_12K.mat Downloading: DE_OR@12_021_1730_12K.mat Downloaded: DE_OR@12_021_1730_12K.mat Downloading: DE_IR_007_1797_48K.mat Downloaded: DE_IR_007_1797_48K.mat Downloading: DE_IR_007_1772_48K.mat Downloaded: DE_IR_007_1772_48K.mat Downloading: DE_IR_007_1750_48K.mat Downloaded: DE_IR_007_1750_48K.mat Downloading: DE_IR_007_1730_48K.mat Downloaded: DE_IR_007_1730_48K.mat Downloading: DE_IR_014_1797_48K.mat Downloaded: DE_IR_014_1797_48K.mat Downloading: DE_IR_014_1772_48K.mat Downloaded: DE_IR_014_1772_48K.mat Downloading: DE_IR_014_1750_48K.mat Downloaded: DE_IR_014_1750_48K.mat Downloading: DE_IR_014_1730_48K.mat Downloaded: DE_IR_014_1730_48K.mat Downloading: DE_IR_021_1797_48K.mat Downloaded: DE_IR_021_1797_48K.mat Downloading: DE_IR_021_1772_48K.mat Downloaded: DE_IR_021_1772_48K.mat Downloading: DE_IR_021_1750_48K.mat Downloaded: DE_IR_021_1750_48K.mat Downloading: DE_IR_021_1730_48K.mat Downloaded: DE_IR_021_1730_48K.mat Downloading: DE_Ball_007_1797_48K.mat Downloaded: DE_Ball_007_1797_48K.mat Downloading: DE_Ball_007_1772_48K.mat Downloaded: DE_Ball_007_1772_48K.mat Downloading: DE_Ball_007_1750_48K.mat Downloaded: DE_Ball_007_1750_48K.mat Downloading: DE_Ball_007_1730_48K.mat Downloaded: DE_Ball_007_1730_48K.mat Downloading: DE_Ball_014_1797_48K.mat Downloaded: DE_Ball_014_1797_48K.mat Downloading: DE_Ball_014_1772_48K.mat Downloading: DE_Ball_014_1750_48K.mat Downloaded: DE_Ball_014_1750_48K.mat Downloading: DE_Ball_014_1730_48K.mat Downloaded: DE_Ball_014_1730_48K.mat Downloading: DE_Ball_021_1797_48K.mat Downloaded: DE_Ball_021_1797_48K.mat Downloading: DE_Ball_021_1772_48K.mat Downloaded: DE_Ball_021_1772_48K.mat Downloading: DE_Ball_021_1750_48K.mat Downloaded: DE_Ball_021_1750_48K.mat Downloading: DE_Ball_021_1730_48K.mat Downloaded: DE_Ball_021_1730_48K.mat Downloading: DE_OR@6_007_1797_48K.mat Downloaded: DE_OR@6_007_1797_48K.mat Downloading: DE_OR@6_007_1772_48K.mat Downloaded: DE_OR@6_007_1772_48K.mat Downloading: DE_OR@6_007_1750_48K.mat Downloaded: DE_OR@6_007_1750_48K.mat Downloading: DE_OR@6_007_1730_48K.mat Downloaded: DE_OR@6_007_1730_48K.mat Downloading: DE_OR@6_014_1797_48K.mat Downloaded: DE_OR@6_014_1797_48K.mat Downloading: DE_OR@6_014_1772_48K.mat Downloaded: DE_OR@6_014_1772_48K.mat Downloading: DE_OR@6_014_1750_48K.mat Downloaded: DE_OR@6_014_1750_48K.mat Downloading: DE_OR@6_014_1730_48K.mat Downloaded: DE_OR@6_014_1730_48K.mat Downloading: DE_OR@6_021_1797_48K.mat Downloaded: DE_OR@6_021_1797_48K.mat Downloading: DE_OR@6_021_1772_48K.mat Downloaded: DE_OR@6_021_1772_48K.mat Downloading: DE_OR@6_021_1750_48K.mat Downloaded: DE_OR@6_021_1750_48K.mat Downloading: DE_OR@6_021_1730_48K.mat Downloaded: DE_OR@6_021_1730_48K.mat Downloading: DE_OR@3_007_1797_48K.mat Downloaded: DE_OR@3_007_1797_48K.mat Downloading: DE_OR@3_007_1772_48K.mat Downloaded: DE_OR@3_007_1772_48K.mat Downloading: DE_OR@3_007_1750_48K.mat Downloaded: DE_OR@3_007_1750_48K.mat Downloading: DE_OR@3_007_1730_48K.mat Downloaded: DE_OR@3_007_1730_48K.mat Downloading: DE_OR@3_021_1797_48K.mat Downloaded: DE_OR@3_021_1797_48K.mat Downloading: DE_OR@3_021_1772_48K.mat Downloaded: DE_OR@3_021_1772_48K.mat Downloading: DE_OR@3_021_1750_48K.mat Downloaded: DE_OR@3_021_1750_48K.mat Downloading: DE_OR@3_021_1730_48K.mat Downloaded: DE_OR@3_021_1730_48K.mat Downloading: DE_OR@12_007_1797_48K.mat Downloaded: DE_OR@12_007_1797_48K.mat Downloading: DE_OR@12_007_1772_48K.mat Downloaded: DE_OR@12_007_1772_48K.mat Downloading: DE_OR@12_007_1750_48K.mat Downloaded: DE_OR@12_007_1750_48K.mat Downloading: DE_OR@12_007_1730_48K.mat Downloaded: DE_OR@12_007_1730_48K.mat Downloading: DE_OR@12_021_1797_48K.mat Downloaded: DE_OR@12_021_1797_48K.mat Downloading: DE_OR@12_021_1772_48K.mat Downloaded: DE_OR@12_021_1772_48K.mat Downloading: DE_OR@12_021_1750_48K.mat Downloaded: DE_OR@12_021_1750_48K.mat Downloading: DE_OR@12_021_1730_48K.mat Downloaded: DE_OR@12_021_1730_48K.mat Downloading: FE_IR_007_1797_12K.mat Downloaded: FE_IR_007_1797_12K.mat Downloading: FE_IR_007_1772_12K.mat Downloaded: FE_IR_007_1772_12K.mat Downloading: FE_IR_007_1750_12K.mat Downloaded: FE_IR_007_1750_12K.mat Downloading: FE_IR_007_1730_12K.mat Downloaded: FE_IR_007_1730_12K.mat Downloading: FE_IR_014_1797_12K.mat Downloaded: FE_IR_014_1797_12K.mat Downloading: FE_IR_014_1772_12K.mat Downloaded: FE_IR_014_1772_12K.mat Downloading: FE_IR_014_1750_12K.mat Downloaded: FE_IR_014_1750_12K.mat Downloading: FE_IR_014_1730_12K.mat Downloaded: FE_IR_014_1730_12K.mat Downloading: FE_IR_021_1797_12K.mat Downloaded: FE_IR_021_1797_12K.mat Downloading: FE_IR_021_1772_12K.mat Downloaded: FE_IR_021_1772_12K.mat Downloading: FE_IR_021_1750_12K.mat Downloaded: FE_IR_021_1750_12K.mat Downloading: FE_IR_021_1730_12K.mat Downloaded: FE_IR_021_1730_12K.mat Downloading: FE_Ball_007_1797_12K.mat Downloaded: FE_Ball_007_1797_12K.mat Downloading: FE_Ball_007_1772_12K.mat Downloaded: FE_Ball_007_1772_12K.mat Downloading: FE_Ball_007_1750_12K.mat Downloaded: FE_Ball_007_1750_12K.mat Downloading: FE_Ball_007_1730_12K.mat Downloaded: FE_Ball_007_1730_12K.mat Downloading: FE_Ball_014_1797_12K.mat Downloaded: FE_Ball_014_1797_12K.mat Downloading: FE_Ball_014_1772_12K.mat Downloaded: FE_Ball_014_1772_12K.mat Downloading: FE_Ball_014_1750_12K.mat Downloaded: FE_Ball_014_1750_12K.mat Downloading: FE_Ball_014_1730_12K.mat Downloaded: FE_Ball_014_1730_12K.mat Downloading: FE_Ball_021_1797_12K.mat Downloaded: FE_Ball_021_1797_12K.mat Downloading: FE_Ball_021_1772_12K.mat Downloaded: FE_Ball_021_1772_12K.mat Downloading: FE_Ball_021_1750_12K.mat Downloaded: FE_Ball_021_1750_12K.mat Downloading: FE_Ball_021_1730_12K.mat Downloaded: FE_Ball_021_1730_12K.mat Downloading: FE_OR@6_007_1797_12K.mat Downloaded: FE_OR@6_007_1797_12K.mat Downloading: FE_OR@6_007_1772_12K.mat Downloaded: FE_OR@6_007_1772_12K.mat Downloading: FE_OR@6_007_1750_12K.mat Downloaded: FE_OR@6_007_1750_12K.mat Downloading: FE_OR@6_007_1730_12K.mat Downloaded: FE_OR@6_007_1730_12K.mat Downloading: FE_OR@6_014_1797_12K.mat Downloaded: FE_OR@6_014_1797_12K.mat Downloading: FE_OR@6_021_1797_12K.mat Downloaded: FE_OR@6_021_1797_12K.mat Downloading: FE_OR@3_007_1797_12K.mat Downloaded: FE_OR@3_007_1797_12K.mat Downloading: FE_OR@3_007_1772_12K.mat Downloaded: FE_OR@3_007_1772_12K.mat Downloading: FE_OR@3_007_1750_12K.mat Downloaded: FE_OR@3_007_1750_12K.mat Downloading: FE_OR@3_007_1730_12K.mat Downloaded: FE_OR@3_007_1730_12K.mat Downloading: FE_OR@3_014_1797_12K.mat Downloaded: FE_OR@3_014_1797_12K.mat Downloading: FE_OR@3_014_1772_12K.mat Downloaded: FE_OR@3_014_1772_12K.mat Downloading: FE_OR@3_014_1750_12K.mat Downloaded: FE_OR@3_014_1750_12K.mat Downloading: FE_OR@3_014_1730_12K.mat Downloaded: FE_OR@3_014_1730_12K.mat Downloading: FE_OR@3_021_1772_12K.mat Downloaded: FE_OR@3_021_1772_12K.mat Downloading: FE_OR@3_021_1750_12K.mat Downloaded: FE_OR@3_021_1750_12K.mat Downloading: FE_OR@3_021_1730_12K.mat Downloaded: FE_OR@3_021_1730_12K.mat Downloading: FE_OR@12_007_1797_12K.mat Downloaded: FE_OR@12_007_1797_12K.mat Downloading: FE_OR@12_007_1772_12K.mat Downloaded: FE_OR@12_007_1772_12K.mat Downloading: FE_OR@12_007_1750_12K.mat Downloaded: FE_OR@12_007_1750_12K.mat Downloading: FE_OR@12_007_1730_12K.mat Downloaded: FE_OR@12_007_1730_12K.mat
Instantiating a digestor object¶
InĀ [3]:
Copied!
mining_params = {
'12K': {'win_len': 12000, 'hop_len': 3000},
'48K': {'win_len': 48000, 'hop_len': 16000},
}
cwru = CWRU('CWRU/')
cwru.mine(mining_params, synchronous_only = True)
mining_params = {
'12K': {'win_len': 12000, 'hop_len': 3000},
'48K': {'win_len': 48000, 'hop_len': 16000},
}
cwru = CWRU('CWRU/')
cwru.mine(mining_params, synchronous_only = True)
InĀ [4]:
Copied!
cwru.data.keys()
cwru.data.keys()
Out[4]:
dict_keys(['FE', 'DE'])
InĀ [5]:
Copied!
cwru.data['FE'].keys()
cwru.data['FE'].keys()
Out[5]:
dict_keys(['12K', '48K'])
InĀ [6]:
Copied!
print(len(cwru.data['FE']['12K']), ' - ', len(cwru.data['FE']['48K']), '\n',
len(cwru.data['DE']['12K']), ' - ', len(cwru.data['DE']['48K']))
print(len(cwru.data['FE']['12K']), ' - ', len(cwru.data['FE']['48K']), '\n',
len(cwru.data['DE']['12K']), ' - ', len(cwru.data['DE']['48K']))
101 - 52 101 - 52
Aggregating Drive-End data recorded at 12 kHz¶
InĀ [7]:
Copied!
df = pd.concat(cwru.data['DE']['12K']).reset_index(drop = True)
df
df = pd.concat(cwru.data['DE']['12K']).reset_index(drop = True)
df
Out[7]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 11995 | 11996 | 11997 | 11998 | 11999 | state | defected_bearing | severity | rot_speed | fs | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1.189431 | -0.177866 | -0.774816 | 0.501518 | 0.993697 | -0.348017 | -0.811363 | 0.424362 | 0.988012 | 0.089339 | ... | -0.520605 | -0.530757 | 0.244465 | 0.147410 | -0.780907 | IR | DE | 021 | 1797 | 12K |
1 | -0.068629 | 0.294414 | 0.136852 | -0.341114 | -0.238780 | 0.232282 | 0.006903 | -0.444260 | 0.123857 | 0.719994 | ... | -0.023147 | -0.305784 | -0.127512 | 0.177866 | 0.084466 | IR | DE | 021 | 1797 | 12K |
2 | 0.770755 | -0.434920 | -0.674918 | 0.679791 | 1.179685 | -0.180303 | -0.758978 | 0.390656 | 0.934408 | -0.152283 | ... | 0.437763 | -0.450351 | -0.537254 | 0.128730 | -0.076751 | IR | DE | 021 | 1797 | 12K |
3 | 0.034517 | -0.164466 | 0.175024 | 0.291977 | -0.102740 | -0.330555 | -0.026802 | 0.242841 | -0.049137 | -0.370758 | ... | 0.015431 | -0.360606 | -0.196140 | 0.165684 | -0.100710 | IR | DE | 021 | 1797 | 12K |
4 | -0.418677 | 0.707811 | 0.378068 | -0.569741 | -0.200201 | 1.194710 | 0.927911 | -0.470250 | -0.257866 | 0.823140 | ... | 0.858064 | 0.634309 | -0.640400 | -0.449133 | 0.775628 | IR | DE | 021 | 1797 | 12K |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4136 | -0.022532 | -0.014940 | 0.090820 | 0.108805 | -0.032479 | -0.060330 | 0.016889 | 0.028866 | -0.029800 | -0.066176 | ... | 0.065242 | 0.048231 | 0.085988 | 0.052819 | 0.029312 | OR@3 | FE | 007 | 1797 | 12K |
4137 | 0.008851 | -0.059640 | -0.084851 | 0.049368 | 0.038650 | -0.020178 | 0.076204 | 0.141162 | 0.019650 | -0.014940 | ... | -0.003694 | 0.164182 | -0.046567 | -0.244283 | 0.038082 | OR@3 | FE | 007 | 1797 | 12K |
4138 | 0.006171 | -0.011571 | -0.031667 | 0.037960 | 0.053550 | -0.010596 | -0.019893 | 0.131581 | 0.111850 | -0.109048 | ... | -0.041208 | 0.034225 | 0.133489 | 0.028176 | -0.085339 | OR@3 | FE | 007 | 1797 | 12K |
4139 | 0.004385 | -0.025983 | 0.018066 | 0.015752 | -0.043197 | -0.122730 | -0.086881 | -0.064146 | -0.095691 | -0.063537 | ... | -0.210627 | 0.015022 | 0.143436 | 0.007633 | -0.112824 | OR@3 | FE | 007 | 1797 | 12K |
4140 | 0.008729 | -0.043116 | -0.015062 | -0.029272 | -0.063821 | -0.007470 | 0.037310 | 0.038082 | -0.003491 | -0.010190 | ... | -0.039909 | -0.067394 | 0.090860 | 0.116762 | -0.100929 | OR@3 | FE | 007 | 1797 | 12K |
4141 rows Ć 12005 columns
Signals-Metadata declaration¶
InĀ [8]:
Copied!
signals, metadata = df.iloc[:, : -5], df.iloc[:, -5 :]
signals
signals, metadata = df.iloc[:, : -5], df.iloc[:, -5 :]
signals
Out[8]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 11990 | 11991 | 11992 | 11993 | 11994 | 11995 | 11996 | 11997 | 11998 | 11999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1.189431 | -0.177866 | -0.774816 | 0.501518 | 0.993697 | -0.348017 | -0.811363 | 0.424362 | 0.988012 | 0.089339 | ... | 0.673294 | -0.183552 | -0.681415 | 0.108425 | 0.295632 | -0.520605 | -0.530757 | 0.244465 | 0.147410 | -0.780907 |
1 | -0.068629 | 0.294414 | 0.136852 | -0.341114 | -0.238780 | 0.232282 | 0.006903 | -0.444260 | 0.123857 | 0.719994 | ... | 0.040609 | 0.207105 | -0.270048 | -0.426392 | -0.032081 | -0.023147 | -0.305784 | -0.127512 | 0.177866 | 0.084466 |
2 | 0.770755 | -0.434920 | -0.674918 | 0.679791 | 1.179685 | -0.180303 | -0.758978 | 0.390656 | 0.934408 | -0.152283 | ... | 0.262333 | 0.704968 | -0.175836 | -0.538879 | 0.260708 | 0.437763 | -0.450351 | -0.537254 | 0.128730 | -0.076751 |
3 | 0.034517 | -0.164466 | 0.175024 | 0.291977 | -0.102740 | -0.330555 | -0.026802 | 0.242841 | -0.049137 | -0.370758 | ... | 0.046294 | 0.249744 | -0.306190 | -0.383347 | 0.082030 | 0.015431 | -0.360606 | -0.196140 | 0.165684 | -0.100710 |
4 | -0.418677 | 0.707811 | 0.378068 | -0.569741 | -0.200201 | 1.194710 | 0.927911 | -0.470250 | -0.257866 | 0.823140 | ... | 0.104771 | 0.671669 | 0.063756 | -0.820297 | -0.407306 | 0.858064 | 0.634309 | -0.640400 | -0.449133 | 0.775628 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4136 | -0.022532 | -0.014940 | 0.090820 | 0.108805 | -0.032479 | -0.060330 | 0.016889 | 0.028866 | -0.029800 | -0.066176 | ... | 0.007633 | -0.045186 | 0.006496 | 0.002111 | 0.030246 | 0.065242 | 0.048231 | 0.085988 | 0.052819 | 0.029312 |
4137 | 0.008851 | -0.059640 | -0.084851 | 0.049368 | 0.038650 | -0.020178 | 0.076204 | 0.141162 | 0.019650 | -0.014940 | ... | -0.068815 | -0.074702 | 0.162720 | 0.086638 | -0.153098 | -0.003694 | 0.164182 | -0.046567 | -0.244283 | 0.038082 |
4138 | 0.006171 | -0.011571 | -0.031667 | 0.037960 | 0.053550 | -0.010596 | -0.019893 | 0.131581 | 0.111850 | -0.109048 | ... | -0.081076 | -0.023750 | -0.060452 | -0.018310 | 0.035240 | -0.041208 | 0.034225 | 0.133489 | 0.028176 | -0.085339 |
4139 | 0.004385 | -0.025983 | 0.018066 | 0.015752 | -0.043197 | -0.122730 | -0.086881 | -0.064146 | -0.095691 | -0.063537 | ... | 0.072347 | -0.177092 | -0.102553 | 0.174291 | 0.009825 | -0.210627 | 0.015022 | 0.143436 | 0.007633 | -0.112824 |
4140 | 0.008729 | -0.043116 | -0.015062 | -0.029272 | -0.063821 | -0.007470 | 0.037310 | 0.038082 | -0.003491 | -0.010190 | ... | 0.012098 | 0.009216 | 0.012626 | 0.070764 | 0.056067 | -0.039909 | -0.067394 | 0.090860 | 0.116762 | -0.100929 |
4141 rows Ć 12000 columns
InĀ [9]:
Copied!
metadata
metadata
Out[9]:
state | defected_bearing | severity | rot_speed | fs | |
---|---|---|---|---|---|
0 | IR | DE | 021 | 1797 | 12K |
1 | IR | DE | 021 | 1797 | 12K |
2 | IR | DE | 021 | 1797 | 12K |
3 | IR | DE | 021 | 1797 | 12K |
4 | IR | DE | 021 | 1797 | 12K |
... | ... | ... | ... | ... | ... |
4136 | OR@3 | FE | 007 | 1797 | 12K |
4137 | OR@3 | FE | 007 | 1797 | 12K |
4138 | OR@3 | FE | 007 | 1797 | 12K |
4139 | OR@3 | FE | 007 | 1797 | 12K |
4140 | OR@3 | FE | 007 | 1797 | 12K |
4141 rows Ć 5 columns
InĀ [10]:
Copied!
metadata['comb'] = metadata['state'] + '_' + metadata['defected_bearing'] + '_' + metadata['severity'] + '_' + metadata['rot_speed']
metadata['comb'].value_counts()
metadata['comb'] = metadata['state'] + '_' + metadata['defected_bearing'] + '_' + metadata['severity'] + '_' + metadata['rot_speed']
metadata['comb'].value_counts()
Out[10]:
count | |
---|---|
comb | |
normal_-_-_1750 | 158 |
normal_-_-_1730 | 158 |
normal_-_-_1772 | 158 |
normal_-_-_1797 | 78 |
IR_DE_021_1797 | 37 |
... | ... |
Ball_FE_021_1730 | 37 |
IR_DE_014_1750 | 37 |
OR@6_DE_021_1772 | 37 |
Ball_FE_014_1750 | 37 |
OR@3_FE_007_1797 | 37 |
101 rows Ć 1 columns
Signal Processing¶
Envelope Extraction¶
InĀ [11]:
Copied!
signals_env = env(signals)
signals_env.shape
signals_env = env(signals)
signals_env.shape
Out[11]:
(4141, 12000)
FFT¶
InĀ [12]:
Copied!
window = scipy.signal.windows.hann(signals_env.shape[1])
freq_filter = scipy.signal.butter(25, [5, 5500], 'bandpass', fs = 12000, output='sos')
window = scipy.signal.windows.hann(signals_env.shape[1])
freq_filter = scipy.signal.butter(25, [5, 5500], 'bandpass', fs = 12000, output='sos')
InĀ [13]:
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[13]:
(4141, 6000)
Zoomed FFT¶
InĀ [14]:
Copied!
signals_env_ZoomedFFT = zoomed_fft(signals_env, 0, 1000, 2000, 12000, freq_filter = freq_filter, window = window)
signals_env_ZoomedFFT.shape
signals_env_ZoomedFFT = zoomed_fft(signals_env, 0, 1000, 2000, 12000, freq_filter = freq_filter, window = window)
signals_env_ZoomedFFT.shape
Out[14]:
(4141, 2000)
STFT¶
InĀ [15]:
Copied!
STFT_window = scipy.signal.windows.hann(1024)
STFT_freq_filter = scipy.signal.butter(25, [5, 5500], 'bandpass', fs = 12000, 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, 5500], 'bandpass', fs = 12000, output='sos')
signals_env_STFT = stft(signals_env, 1024, 200, STFT_freq_filter, STFT_window)
signals_env_STFT.shape
Out[15]:
(4141, 55, 512)
Statistical Features¶
InĀ [16]:
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Ā [17]:
Copied!
features_df = feature_extractor(signals, features)
features_df
features_df = feature_extractor(signals, features)
features_df
Out[17]:
mean | var | rms | |
---|---|---|---|
0 | 0.019769 | 0.267842 | 0.517912 |
1 | 0.019584 | 0.261590 | 0.511833 |
2 | 0.019419 | 0.260970 | 0.511221 |
3 | 0.019047 | 0.258746 | 0.509027 |
4 | 0.018798 | 0.254876 | 0.505202 |
... | ... | ... | ... |
4136 | 0.002500 | 0.007554 | 0.086951 |
4137 | 0.002516 | 0.007271 | 0.085306 |
4138 | 0.002493 | 0.007095 | 0.084266 |
4139 | 0.002426 | 0.007193 | 0.084844 |
4140 | 0.002341 | 0.007462 | 0.086413 |
4141 rows Ć 3 columns
Visualization¶
InĀ [18]:
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, 12000)
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, 12000)
sns.lineplot(ax=axes[2], x = fft_freq_axis(12000, 12000), 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, 6000)
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, 12000)
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, 12000)
sns.lineplot(ax=axes[2], x = fft_freq_axis(12000, 12000), 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, 6000)
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Ā [19]:
Copied!
t = np.linspace(0, 1, 55)
f = fft_freq_axis(1024, 12000)
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, 55)
f = fft_freq_axis(1024, 12000)
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()
InĀ [19]:
Copied!