Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dspeed/processing_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2632,8 +2632,10 @@ def resolve_dependencies(
init_kwargs = {}
for arg in init_args_in:
if not isinstance(arg, str):
pass
init_args.append(arg)
continue

# find and replace db values
for db_var in db_parser.findall(arg):
try:
db_node = db_dict
Expand Down
6 changes: 3 additions & 3 deletions src/dspeed/processors/iir_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def iir_filter(
wf_lp:
function: iir_filter
module: dspeed.processors
args_in:
init_args:
- "15*MHz"
- 4
- wf
Expand Down Expand Up @@ -138,7 +138,7 @@ def notch_filter(
wf_notch:
function: notch_filter
module: dspeed.processors
args_in:
init_args:
- "15*MHz"
- "1.5*MHz"
- wf
Expand Down Expand Up @@ -196,7 +196,7 @@ def peak_filter(
wf_peak:
function: peak_filter
module: dspeed.processors
args_in:
init_args:
- "15*MHz"
- "1.5*MHz"
- wf
Expand Down
13 changes: 12 additions & 1 deletion src/dspeed/processors/poly_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ def _poly_fitter(w_in: np.ndarray, inv: np.ndarray, poly_pars: np.ndarray) -> No

def poly_fit(length, deg):
"""Factory function for generating a polynomial fitter for an input of length
`length` to a polynomial of order `deg`."""
`length` to a polynomial of order `deg`.

YAML Configuration Example
--------------------------

.. code-block:: yaml

fit_pars:
function: dspeed.processors.poly_fit
args: ["wf_logged", "fit_pars(shape=4)"]
init_args: ["len(wf_logged)", 3]
"""

vals_array = np.zeros(2 * deg + 1, dtype="float64")

Expand Down
39 changes: 39 additions & 0 deletions tests/test_processing_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,42 @@ def test_database_params(geds_raw_tbl):
geds_raw_tbl, dsp_config=dsp_config, database={"a": 2, "c": 0}, n_entries=1
)
assert lh5_out["test"][0] == 3

def test_init_args(geds_raw_tbl):
dsp_config = {
"outputs": ["test"],
"processors": {
"test": {
"function": "dspeed.processors.poly_fit",
"args": ["waveform", "test(shape=4)"],
"init_args": ["len(waveform)", 3],
}
},
}
build_dsp(geds_raw_tbl, dsp_config=dsp_config, n_entries=1)

dsp_config = {
"outputs": ["test"],
"processors": {
"test": {
"function": "dspeed.processors.poly_fit",
"args": ["waveform", "test(shape=3)"],
"init_args": ["len(waveform)", 3],
}
},
}
with pytest.raises(ProcessingChainError):
build_dsp(geds_raw_tbl, dsp_config=dsp_config, n_entries=1)

dsp_config = {
"outputs": ["test"],
"processors": {
"test": {
"function": "dspeed.processors.poly_fit",
"args": ["waveform", "test(shape=4)"],
"init_args": ["len(waveform)", "db.deg"],
"defaults": {"db.deg": 3},
}
},
}
build_dsp(geds_raw_tbl, dsp_config=dsp_config, n_entries=1)