Despike utils
goring_nikora
goring_nikora(u, remaining_spikes=5, max_iter=10, robust_statistics=False)
Implements the Goring & Nikora (2002) phase-space de-spiking algorithm, returning modified velocity array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ndarray
|
N-D array with |
required |
remaining_spikes
|
int
|
Iterations will stop once there are |
5
|
max_iter
|
int
|
Maximum number of iterations |
10
|
robust_statistics
|
bool
|
If True, ellipsoid centers will be based on the median and axis lengths will be based on median absolute deviation as suggested by Wahl (2003). If False, mean and standard deviation are used, consistent with the original Goring & Nikora implementation. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
References
Goring, D. G., & Nikora, V. I. (2002). Despiking acoustic Doppler velocimeter data. Journal of hydraulic engineering, 128(1), 117-126.
Wahl, T. L. (2003). Discussion of "Despiking acoustic doppler velocimeter data" by Derek G. Goring and Vladimir I. Nikora. Journal of Hydraulic Engineering, 129(6), 484-487.
Source code in src/pytoast/utils/despike_utils.py
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 117 118 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
recursive_gaussian
recursive_gaussian(u, alpha=3.0, max_iter=10)
Despike each row of u by iteratively flagging samples beyond
alpha * sigma of a Gaussian fit, replacing them with NaN, and
interpolating along the time axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ndarray
|
N-D array with |
required |
alpha
|
float
|
Standard-deviation multiplier defining the spike threshold. |
3.0
|
max_iter
|
int
|
Maximum number of refit/replace iterations per row. |
10
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Source code in src/pytoast/utils/despike_utils.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
threshold
threshold(u, threshold_min=-3.0, threshold_max=3.0)
Threshold-based despiking.
Samples outside [threshold_min, threshold_max] are set to NaN and
linearly interpolated over along the time axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ndarray
|
N-D array with |
required |
threshold_min
|
float
|
Value below which samples are flagged. |
-3.0
|
threshold_max
|
float
|
Value above which samples are flagged. |
3.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Source code in src/pytoast/utils/despike_utils.py
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 | |