def filter_data(data, filter_name, filter_file, bits, filterbank_off=False, swstat_channel_name=None): ''' A naive function to determine if the filter was on at the time and then filter the data. ''' # if filterbank is off then return a time series of zeroes if filterbank_off: return numpy.zeros(len(data)) # loop over the 10 filters in the filterbank for i in range(10): # read the filter filter = Filter(filter_file[filter_name][i]) # if bit is on then filter the data bit = int(bits[-(i+1)]) if bit: logging.info('filtering with filter module %d', i) # if there are second-order sections then filter with them if len(filter.sections): data = filter.apply(data) # else it is a filter with only gain so apply the gain else: try: gain = float(filter.design.design.split(')')[0].strip('gain(')) except ValueError as e: print 'ValueError', e, 'using gain of 1' data = gain * data return data
def filter_data(data, filter_name, filter_file, bits, filterbank_off=False, swstat_channel_name=None): ''' A naive function to determine if the filter was on at the time and then filter the data. ''' # if filterbank is off then return a time series of zeroes if filterbank_off: return numpy.zeros(len(data)) # loop over the 10 filters in the filterbank for i in range(10): # read the filter filter = Filter(filter_file[filter_name][i]) # if bit is on then filter the data bit = int(bits[-(i + 1)]) if bit: logging.info('filtering with filter module %d', i) # if there are second-order sections then filter with them if len(filter.sections): data = filter.apply(data) # else it is a filter with only gain so apply the gain else: coeffs = iir2z(filter_file[filter_name][i]) if len(coeffs) > 1: logging.info( 'Gain-only filter module return more than one number') sys.exit() gain = coeffs[0] data = gain * data return data
def filter_data(data, filter_name, filter_file, bits, filterbank_off=False, swstat_channel_name=None): ''' A naive function to determine if the filter was on at the time and then filter the data. ''' # if filterbank is off then return a time series of zeroes if filterbank_off: return numpy.zeros(len(data)) # loop over the 10 filters in the filterbank for i in range(10): # read the filter filter = Filter(filter_file[filter_name][i]) # if bit is on then filter the data bit = int(bits[-(i+1)]) if bit: logging.info('filtering with filter module %d', i) # if there are second-order sections then filter with them if len(filter.sections): data = filter.apply(data) # else it is a filter with only gain so apply the gain else: coeffs = iir2z(filter_file[filter_name][i]) if len(coeffs) > 1: logging.info('Gain-only filter module return more than one number') sys.exit() gain = coeffs[0] data = gain * data return data