filter
Filter design and application.
Functions:
| Name | Description |
|---|---|
fir_least_squares |
Apply a least-squares optimised FIR filter to some data. |
matched_filter |
Apply a matched filter to some data. |
fir_least_squares
fir_least_squares(data, low_edge, high_edge, transition_width, taps=151, dim='time')
Apply a least-squares optimised FIR filter to some data.
This uses scipy.signal.firls to calculate the coefficients for each tap. The filter is applied using scipy.signal.filtfilt which applies the filter both forward and backwards to avoid phase shifts from the filtering. Note that this results in a filter order of twice the original design.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
The data to apply the filter to. |
required |
low_edge
|
float | None
|
The low edge of the passband in Hertz. If None, a low-pass filter is generated. |
required |
high_edge
|
float | None
|
The high edge of the passband in Hertz. If None, a high-pass filter is
generated. Cannot be None if |
required |
transition_width
|
float
|
The desired transition width at each edge in Hertz. The ideal filter would be zero below (low_edge - transition_width) and above (high_edge + transition_width). |
required |
taps
|
int
|
The number of taps in the filter. This must be positive and odd. |
151
|
dim
|
str
|
The dimension to filter along. The coordinates are assumed to be equally spaced along this dimension. |
'time'
|
Returns:
| Name | Type | Description |
|---|---|---|
filtered |
DataArray
|
The filtered data. This will have the same coordinates as the input data. |
Source code in src/airsonar/processing/filter.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
matched_filter
matched_filter(data, signal, method='fft', data_dim='time', signal_dim='time')
Apply a matched filter to some data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
The data to apply the matched filter to. |
required |
signal
|
DataArray
|
The signal to match. |
required |
method
|
Literal['fft']
|
The implementation method. Currently only |
'fft'
|
data_dim
|
str
|
The dimension of |
'time'
|
signal_dim
|
str
|
The dimension of |
'time'
|
Returns:
| Name | Type | Description |
|---|---|---|
matched |
DataArray
|
An array with the broadcast dimensions of |
Source code in src/airsonar/processing/filter.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |