<jupyter_start><jupyter_text>ENVELOPE SPECTRUM - INNER RACE (Fault Diameter 0.007")<jupyter_code>import scipy.io as sio
import numpy as np
import matplotlib.pyplot as plt
import lee_dataset_CWRU
from lee_dataset_CWRU import *
import envelope_spectrum
from envelope_spectrum import *
faultRates = [3.585, 5.415, 1] #[outer, inner, shaft]
Fs = 12000
DE_I1, FE_I1, t_DE_I1, t_FE_I1, RPM_I1, samples_s_DE_I1, samples_s_FE_I1 = lee_dataset('../DataCWRU/105.mat')
DE_I2, FE_I2, t_DE_I2, t_FE_I2, RPM_I2, samples_s_DE_I2, samples_s_FE_I2 = lee_dataset('../DataCWRU/106.mat')
DE_I3, FE_I3, t_DE_I3, t_FE_I3, RPM_I3, samples_s_DE_I3, samples_s_FE_I3 = lee_dataset('../DataCWRU/107.mat')
DE_I4, FE_I4, t_DE_I4, t_FE_I4, RPM_I4, samples_s_DE_I4, samples_s_FE_I4 = lee_dataset('../DataCWRU/108.mat')
fr_I1 = RPM_I1 / 60
BPFI_I1 = 5.4152 * fr_I1
BPFO_I1 = 3.5848 * fr_I1
fr_I2 = RPM_I2 / 60
BPFI_I2 = 5.4152 * fr_I2
BPFO_I2 = 3.5848 * fr_I2
fr_I3 = RPM_I3 / 60
BPFI_I3 = 5.4152 * fr_I3
BPFO_I3 = 3.5848 * fr_I3
fr_I4 = RPM_I4 / 60
BPFI_I4 = 5.4152 * fr_I4
BPFO_I4 = 3.5848 * fr_I4
fSpec_I1, xSpec_I1 = envelope_spectrum2(DE_I1, Fs)
fSpec_I2, xSpec_I2 = envelope_spectrum2(DE_I2, Fs)
fSpec_I3, xSpec_I3 = envelope_spectrum2(DE_I3, Fs)
fSpec_I4, xSpec_I4 = envelope_spectrum2(DE_I4, Fs)
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
fig.set_size_inches(14, 10)
ax1.plot(fSpec_I1, xSpec_I1, label = 'Env. spectrum')
ax1.axvline(x = fr_I1, color = 'k', linestyle = '--', lw = 1.5, label = 'fr', alpha = 0.6)
ax1.axvline(x = BPFI_I1, color = 'r', linestyle = '--', lw = 1.5, label = 'BPFI', alpha = 0.6)
ax1.axvline(x = BPFO_I1, color = 'g', linestyle = '--', lw = 1.5, label = 'BPFO', alpha = 0.6)
ax1.set_xlim(0,200)
ax1.set_xlabel('Frequency')
ax1.set_ylabel('Env. spectrum')
ax1.set_title('Inner race. Fault Diameter 0.007", 1797 RPM')
ax1.legend(loc = 2)
ax2.plot(fSpec_I2, xSpec_I2, label = 'Env. spectrum')
ax2.axvline(x = fr_I2, color = 'k', linestyle = '--', lw = 1.5, label = 'fr', alpha = 0.6)
ax2.axvline(x = BPFI_I2, color = 'r', linestyle = '--', lw = 1.5, label = 'BPFI', alpha = 0.6)
ax2.axvline(x = BPFO_I2, color = 'g', linestyle = '--', lw = 1.5, label = 'BPFO', alpha = 0.6)
ax2.set_xlim(0,200)
ax2.legend(loc = 2)
ax2.set_xlabel('Frequency')
ax2.set_ylabel('Env. spectrum')
ax2.set_title('Inner race. Fault Diameter 0.007", 1772 RPM')
ax3.plot(fSpec_I3, xSpec_I3, label = 'Env. spectrum')
ax3.axvline(x = fr_I3, color = 'k', linestyle = '--', lw = 1.5, label = 'fr', alpha = 0.6)
ax3.axvline(x = BPFI_I3, color = 'r', linestyle = '--', lw = 1.5, label = 'BPFI', alpha = 0.6)
ax3.axvline(x = BPFO_I3, color = 'g', linestyle = '--', lw = 1.5, label = 'BPFO', alpha = 0.6)
ax3.set_xlim(0,200)
ax3.legend(loc = 2)
ax3.set_xlabel('Frequency')
ax3.set_ylabel('Env. spectrum')
ax3.set_title('Inner race. Fault Diameter 0.007", 1750 RPM')
ax4.plot(fSpec_I4, xSpec_I4, label = 'Env. spectrum')
ax4.axvline(x = fr_I4, color = 'k', linestyle = '--', lw = 1.5, label = 'fr', alpha = 0.6)
ax4.axvline(x = BPFI_I4, color = 'r', linestyle = '--', lw = 1.5, label = 'BPFI', alpha = 0.6)
ax4.axvline(x = BPFO_I4, color = 'g', linestyle = '--', lw = 1.5, label = 'BPFO', alpha = 0.6)
ax4.set_xlim(0,200)
ax4.legend(loc = 2)
ax4.set_xlabel('Frequency')
ax4.set_ylabel('Env. spectrum')
ax4.set_title('Inner race. Fault Diameter 0.007", 1730 RPM')
clasificacion_inner = pd.DataFrame({'Señal': ['105.mat', '106.mat', '107.mat', '108.mat'],
                                   'Estado': ['Fallo Inner Race'] * 4,
                                   'Predicción': [clasificacion_envelope(fSpec_I1, xSpec_I1, fr_I1, BPFO_I1, BPFI_I1),
                                                 clasificacion_envelope(fSpec_I2, xSpec_I2, fr_I2, BPFO_I2, BPFI_I2),
                                                 clasificacion_envelope(fSpec_I3, xSpec_I3, fr_I3, BPFO_I3, BPFI_I3),
                                                 clasificacion_envelope(fSpec_I4, xSpec_I4, fr_I4, BPFO_I4, BPFI_I4)]})
clasificacion_inner<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16687391196219845, 'fraction_numerical': 0.08579955235016165, 'mean_word_length': 3.671312427409988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '56843', 'license': 'MIT', 'n_tokens_mistral': 2034, 'n_tokens_neox': 1876, 'n_words': 367, 'path': 'FailurePrediction/ConstantRotationalSpeed/EnvelopeSpectrum/Envelope_Inner_007.ipynb', 'repo_name': 'judithspd/predictive-maintenance', 'size': '4021'}