| @@ 327-347 (lines=21) @@ | ||
| 324 | return y_base |
|
| 325 | ||
| 326 | ||
| 327 | def linear_background(vec_x, vec_y): |
|
| 328 | """ |
|
| 329 | This function is wrapping function for calculating linear fitted line. |
|
| 330 | It takes x and y values of the cv data, returns the fitted baseline. |
|
| 331 | ---------- |
|
| 332 | Parameters |
|
| 333 | ---------- |
|
| 334 | x : Output of the split vector function. x value of the cyclic voltammetry data. |
|
| 335 | y : Output of the split vector function. y value of the cyclic voltammetry data. |
|
| 336 | ------- |
|
| 337 | Returns |
|
| 338 | ------- |
|
| 339 | List of constructed y_labels. |
|
| 340 | """ |
|
| 341 | assert isinstance(vec_x, np.ndarray), "Input of the function should be numpy array" |
|
| 342 | assert isinstance(vec_y, np.ndarray), "Input of the function should be numpy array" |
|
| 343 | idx = critical_idx(vec_x, vec_y) + 5 #this is also arbitrary number we can play with. |
|
| 344 | m_val, b_val = (linear_coeff(vec_x[(idx - int(0.5 * idx)) : (idx + int(0.5 * idx))], |
|
| 345 | vec_y[(idx - int(0.5 * idx)) : (idx + int(0.5 * idx))])) |
|
| 346 | y_base = y_fitted_line(m_val, b_val, vec_x) |
|
| 347 | return y_base |
|
| 348 | ||
| 349 | ||
| 350 | def peak_detection_fxn(data_y): |
|
| @@ 168-188 (lines=21) @@ | ||
| 165 | return y_base |
|
| 166 | ||
| 167 | ||
| 168 | def linear_background(vec_x, vec_y): |
|
| 169 | """ |
|
| 170 | This function is wrapping function for calculating linear fitted line. |
|
| 171 | It takes x and y values of the cv data, returns the fitted baseline. |
|
| 172 | ---------- |
|
| 173 | Parameters |
|
| 174 | ---------- |
|
| 175 | x : Output of the split vector function. x value of the cyclic voltammetry data. |
|
| 176 | y : Output of the split vector function. y value of the cyclic voltammetry data. |
|
| 177 | ------- |
|
| 178 | Returns |
|
| 179 | ------- |
|
| 180 | List of constructed y_labels. |
|
| 181 | """ |
|
| 182 | assert isinstance(vec_x, np.ndarray), "Input of the function should be numpy array" |
|
| 183 | assert isinstance(vec_y, np.ndarray), "Input of the function should be numpy array" |
|
| 184 | idx = critical_idx(vec_x, vec_y) + 5 #this is also arbitrary number we can play with. |
|
| 185 | m_val, b_val = (linear_coeff(vec_x[(idx - int(0.5 * idx)) : (idx + int(0.5 * idx))], |
|
| 186 | vec_y[(idx - int(0.5 * idx)) : (idx + int(0.5 * idx))])) |
|
| 187 | y_base = y_fitted_line(m_val, b_val, vec_x) |
|
| 188 | return y_base |
|
| 189 | ||