Skip to content

Commit

Permalink
Merge pull request #69 from iguinn/main
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
iguinn authored Apr 28, 2024
2 parents 174eda7 + d3fec03 commit 904b6d9
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 422 deletions.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ install_requires =
parse
pint
pyarrow
pyfftw
scipy
tqdm>=4.27
python_requires = >=3.9
Expand Down
6 changes: 0 additions & 6 deletions src/dspeed/processing_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,6 @@ def _parse_expr(
else:
ProcessingChainError("only 1D arrays are supported: " + expr)

elif isinstance(node, ast.Num):
return node.n

elif isinstance(node, ast.Str):
return node.s

elif isinstance(node, ast.Constant):
return node.value

Expand Down
4 changes: 0 additions & 4 deletions src/dspeed/processors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
from .convolutions import convolve_wf, fft_convolve_wf
from .dwt import discrete_wavelet_transform
from .energy_kernels import cusp_filter, dplms, zac_filter
from .fftw import dft, inv_dft, psd
from .fixed_time_pickoff import fixed_time_pickoff
from .gaussian_filter1d import gaussian_filter1d
from .get_multi_local_extrema import get_multi_local_extrema
Expand Down Expand Up @@ -115,9 +114,6 @@
"t0_filter",
"zac_filter",
"discrete_wavelet_transform",
"dft",
"inv_dft",
"psd",
"fixed_time_pickoff",
"gaussian_filter1d",
"get_multi_local_extrema",
Expand Down
280 changes: 0 additions & 280 deletions src/dspeed/processors/fftw.py

This file was deleted.

27 changes: 16 additions & 11 deletions src/dspeed/processors/time_point_thresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ def multi_time_point_thresh(

@guvectorize(
[
"void(float32[:], float32, float32, float32, float32, float32[:], float32[:])",
"void(float64[:], float64, float64, float64, float64, float64[:], float64[:])",
"void(float32[:], float32, float32, float32, float32, uint32[:], float32[:], float32[:])",
"void(float64[:], float64, float64, float64, float64, uint32[:], float64[:], float64[:])",
],
"(n),(),(),(),(),(m),(m)",
"(n),(),(),(),(),(),(m),(m)",
**nb_kwargs,
)
def bi_level_zero_crossing_time_points(
Expand All @@ -383,6 +383,7 @@ def bi_level_zero_crossing_time_points(
a_neg_threshold_in: float,
gate_time_in: int,
t_start_in: int,
n_crossings_out: int,
polarity_out: np.array,
t_trig_times_out: np.array,
) -> None:
Expand All @@ -403,6 +404,8 @@ def bi_level_zero_crossing_time_points(
The number of samples that the next threshold crossing has to be within in order to count a 0 crossing
t_start_in
the starting index.
n_crossings_out
the number of zero-crossings found. Note: if there are more zeros than elements in output arrays, this will continue to increment but the polarity and trigger time will not be added to the output buffers
polarity_out
An array holding the polarity of identified pulses. 0 for negative and 1 for positive
t_trig_times_out
Expand All @@ -418,7 +421,7 @@ def bi_level_zero_crossing_time_points(
"trig_times_out": {
"function": "multi_trigger_time",
"module": "dspeed.processors",
"args": ["wf_rc_cr2", "5", "-10", 0, "polarity_out(20)", "trig_times_out(20)"],
"args": ["wf_rc_cr2", "5", "-10", 0, "n_crossings", "polarity_out(20, vector_len=n_crossings)", "trig_times_out(20, vector_len=n_crossings)"],
"unit": "ns"
}
"""
Expand Down Expand Up @@ -449,7 +452,7 @@ def bi_level_zero_crossing_time_points(
is_above_thresh = False
is_below_thresh = False
crossed_zero = False
trig_array_idx = 0
n_crossings_out[0] = 0
for i in range(int(t_start_in), len(w_in) - 1, 1):
if is_below_thresh and (w_in[i] <= 0 < w_in[i + 1]):
crossed_zero = True
Expand All @@ -459,9 +462,10 @@ def bi_level_zero_crossing_time_points(
if w_in[i] <= a_pos_threshold_in < w_in[i + 1]:
if crossed_zero and is_below_thresh:
if i - is_below_thresh < gate_time_in:
t_trig_times_out[trig_array_idx] = neg_trig_time_candidate
polarity_out[trig_array_idx] = 0
trig_array_idx += 1
if n_crossings_out[0] < len(polarity_out):
t_trig_times_out[n_crossings_out[0]] = neg_trig_time_candidate
polarity_out[n_crossings_out[0]] = 0
n_crossings_out[0] += 1
else:
is_above_thresh = i

Expand All @@ -478,9 +482,10 @@ def bi_level_zero_crossing_time_points(
if w_in[i] >= a_neg_threshold_in > w_in[i + 1]:
if crossed_zero and is_above_thresh:
if i - is_above_thresh < gate_time_in:
t_trig_times_out[trig_array_idx] = pos_trig_time_candidate
polarity_out[trig_array_idx] = 1
trig_array_idx += 1
if n_crossings_out[0] < len(polarity_out):
t_trig_times_out[n_crossings_out[0]] = pos_trig_time_candidate
polarity_out[n_crossings_out[0]] = 1
n_crossings_out[0] += 1
else:
is_below_thresh = i
is_above_thresh = False
Expand Down
Loading

0 comments on commit 904b6d9

Please sign in to comment.