Avishek Banerjee
Avishek Banerjee

Reputation: 41

Median Filter Application in Python error using signal.medfilt

I am trying to minimize noise from the CSI values. I generated some fake CSI values and added some random error along with it.

I am giving the code

import numpy as np
#import tkinter as Tk
import scipy as sp
import matplotlib.pyplot as plt
from scipy import signal


from scipy.fftpack import fft

#Generate fake CSI values

 csi_values =np.array([0 + 0j]*64)

 print(csi_values)

 csi_values[13] = .5 + .2j
 csi_values[12] =  .75 + .25j
 csi_values[11] = 1 + .35j
 csi_values[10] = 1.5 + .5j

 print(csi_values[10:14:1])
 print(csi_values)



 fft_value = fft(csi_values)
 print(fft_value)
 print(len(fft_value))  
 #print(fft_value)
 real_csi= abs(csi_values)
 mean_csi= np.mean(real_csi)

 print(real_csi)
 print(mean_csi)


 x_axis = np.linspace(0.0, 63,64)
 print(x_axis.shape,fft_value.shape)
 plt.plot(abs(fft_value))
 plt.grid()
 plt.show()



 #CSI Subcarrier selection based on average amplitude of all subcarriers

 csi_truncated = csi_values[abs(csi_values) > mean_csi]
 print(csi_truncated)

 #Removal of noise using median filter
 csi_error= csi_values + np.random.rand(64)
 print(csi_error)
  trim_csi = sp.signal.medfilt(csi_error,5)

However I am getting the following error

   File "python_check.py", line 54, in <module>
   trim_csi = sp.signal.medfilt(csi_error,5)
    File "/home/avishek/venv3/lib/python3.5/site-packages/scipy/signal/signaltools.py", line 893, in medfilt
    return sigtools._order_filterND(volume, domain, order)
    ValueError: order_filterND not available for this type

What is the reason for this error? I am using the correct packages too I guess

Upvotes: 2

Views: 1666

Answers (1)

Maahk
Maahk

Reputation: 11

Still got the same problem with newest scipy/python. For other people coming here: You can switch to this function

scipy.ndimage.filters.median_filter

which does the same but works without this error.

Upvotes: 1

Related Questions