Esempio n. 1
0
    def test_specgram_band_pass(self):
        time_points = 10000
        sampling_frequency = 100.0
        data = numpy.zeros((time_points,1))
        for time_index in range(time_points):
            data[time_index,0] = numpy.sin(2.0 * numpy.pi * 5.0 * (time_index / sampling_frequency))
            data[time_index,0] += numpy.sin(2.0 * numpy.pi * 15.0 * (time_index / sampling_frequency))
            data[time_index,0] += numpy.sin(2.0 * numpy.pi * 25.0 * (time_index / sampling_frequency))
            data[time_index,0] += numpy.sin(2.0 * numpy.pi * 35.0 * (time_index / sampling_frequency))
            data[time_index,0] += numpy.sin(2.0 * numpy.pi * 45.0 * (time_index / sampling_frequency))

        pass_band=(20.,30.)

        #Generate a time series build out of the data
        from pySPACE.resources.data_types.time_series import TimeSeries
        test_data = TimeSeries(input_array = data,
                               channel_names = ["test_channel_1"],
                               sampling_frequency = sampling_frequency,
                               start_time = 0,
                               end_time = float(time_points) / sampling_frequency)

        lpf_node = filtering.FFTBandPassFilterNode(pass_band=pass_band)
        filtered_time_series = lpf_node.execute(test_data)

        lpf_node_fir = filtering.FIRFilterNode(pass_band=pass_band)
        filtered_time_series_fir = lpf_node_fir.execute(test_data)

        lpf_node_fir2 = filtering.FIRFilterNode(pass_band=pass_band,window='hann')
        filtered_time_series_fir2 = lpf_node_fir2.execute(test_data)

        lpf_node_iir = filtering.IIRFilterNode(pass_band=pass_band,stop_band_rifle=90)
        filtered_time_series_iir = lpf_node_iir.execute(test_data)
Esempio n. 2
0
 def create_filter(self,target_frequency,downsampling_factor,transition_region_width):
             
     return filtering.IIRFilterNode([target_frequency], 
                                      comp_type = self.comp_type)