0

hope you are doing well

I'm trying to process 2 sygnals, first I need to apply the nyquist theorem and then a filter, in my case Butterworth. I plot the normal signal as 'Normal_0' and the fault data 'IRDE12_0.mat', I take X097_DE_time and X105_DE_time, respectively.

Plot after compiling

Code:

`import scipy.io as sio
import matplotlib.pyplot as plt
from scipy import signal

# Cargar las señales desde archivos .mat diferentes
mat_data1 = sio.loadmat("Normal_0.mat")
mat_data2 = sio.loadmat("IRDE12_0.mat")
data1 = mat_data1["X097_DE_time"].T  # Obtener los datos de la señal 1
data2 = mat_data2["X105_DE_time"].T  # Obtener los datos de la señal 2

# Determinar la frecuencia de muestreo necesaria utilizando el teorema de Nyquist
frecuencia_de_la_senal = (
    48000  # Esto es un ejemplo, asegúrate de usar la frecuencia correcta
)
frecuencia_de_muestreo = 2 * frecuencia_de_la_senal

# Diseñar un filtro Butterworth de segundo orden con frecuencia de corte de 1000 Hz
orden_del_filtro = 4
frecuencia_de_corte = 8000
b, a = signal.butter(
    orden_del_filtro, frecuencia_de_corte / frecuencia_de_muestreo, "low"
)

# Aplicar el filtro a las señales
data1_filtrada = signal.filtfilt(b, a, data1)
data2_filtrada = signal.filtfilt(b, a, data2)

# Graficar las señales filtradas en dos subplots separados
# Señal normal
plt.subplot(2, 1, 1)
plt.plot(data1_filtrada)
plt.title("Normal")
plt.xlabel("Muestras")
plt.ylabel("Amplitud")

# Señal con falla
plt.subplot(2, 1, 2)
plt.plot(data2_filtrada)
plt.title("Falla")
plt.xlabel("Muestras")
plt.ylabel("Amplitud")

plt.show()`

Repository with sygnals: https://github.com/DantesHMS/DantesHMS

Kind regards, Luis H.

I tried changing the order for the filter, the frecuency, tried with chatgpt...

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Luis H
  • 1
  • 2

0 Answers0