Generated by Cython 0.29.32
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: _generic.cpp
+01: # This file is part of OM.
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
02: #
03: # OM is free software: you can redistribute it and/or modify it under the terms of
04: # the GNU General Public License as published by the Free Software Foundation, either
05: # version 3 of the License, or (at your option) any later version.
06: #
07: # OM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
08: # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
09: # PURPOSE. See the GNU General Public License for more details.
10: #
11: # You should have received a copy of the GNU General Public License along with OnDA.
12: # If not, see <http://www.gnu.org/licenses/>.
13: #
14: # Copyright 2020 -2023 SLAC National Accelerator Laboratory
15: #
16: # Based on OnDA - Copyright 2014-2019 Deutsches Elektronen-Synchrotron DESY,
17: # a research centre of the Helmholtz Association.
18: """
19: Peakfinder8 extension.
20:
21: This extension contains an implementation of Cheetah's 'peakfinder8' peak detection
22: algorithm.
23: """
24:
25: cdef extern from "binning.hh":
26:
27: void c_bin_detector_data(double *data, double *binned_data, char *mask, int bin_size,
28: int min_good_pixel_count, double bad_pixel_value,
29: double saturation_value, int asic_size_fs,
30: int asic_size_ss, int num_asics_fs, int num_asics_ss);
31:
+32: def bin_detector_data(double[:,::1] data, double[:,::1] binned_data, char[:,::1] mask,
/* Python wrapper */
static PyObject *__pyx_pw_2om_10algorithms_8_generic_1bin_detector_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_2om_10algorithms_8_generic_bin_detector_data[] = "\n Docstring here\n ";
static PyMethodDef __pyx_mdef_2om_10algorithms_8_generic_1bin_detector_data = {"bin_detector_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_2om_10algorithms_8_generic_1bin_detector_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_2om_10algorithms_8_generic_bin_detector_data};
static PyObject *__pyx_pw_2om_10algorithms_8_generic_1bin_detector_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
__Pyx_memviewslice __pyx_v_data = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_binned_data = { 0, 0, { 0 }, { 0 }, { 0 } };
__Pyx_memviewslice __pyx_v_mask = { 0, 0, { 0 }, { 0 }, { 0 } };
int __pyx_v_bin_size;
int __pyx_v_min_good_pixel_count;
double __pyx_v_bad_pixel_value;
double __pyx_v_saturation_value;
int __pyx_v_asic_size_fs;
int __pyx_v_asic_size_ss;
int __pyx_v_num_asics_fs;
int __pyx_v_num_asics_ss;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("bin_detector_data (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_binned_data,&__pyx_n_s_mask,&__pyx_n_s_bin_size,&__pyx_n_s_min_good_pixel_count,&__pyx_n_s_bad_pixel_value,&__pyx_n_s_saturation_value,&__pyx_n_s_asic_size_fs,&__pyx_n_s_asic_size_ss,&__pyx_n_s_num_asics_fs,&__pyx_n_s_num_asics_ss,0};
PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
CYTHON_FALLTHROUGH;
case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
CYTHON_FALLTHROUGH;
case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
CYTHON_FALLTHROUGH;
case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
CYTHON_FALLTHROUGH;
case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
CYTHON_FALLTHROUGH;
case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binned_data)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 1); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 2); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bin_size)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 3); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_good_pixel_count)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 4); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 5:
if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bad_pixel_value)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 5); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 6:
if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_saturation_value)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 6); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 7:
if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_asic_size_fs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 7); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 8:
if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_asic_size_ss)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 8); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 9:
if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_asics_fs)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 9); __PYX_ERR(0, 32, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 10:
if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_num_asics_ss)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, 10); __PYX_ERR(0, 32, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bin_detector_data") < 0)) __PYX_ERR(0, 32, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
}
__pyx_v_data = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_data.memview)) __PYX_ERR(0, 32, __pyx_L3_error)
__pyx_v_binned_data = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_binned_data.memview)) __PYX_ERR(0, 32, __pyx_L3_error)
__pyx_v_mask = __Pyx_PyObject_to_MemoryviewSlice_d_dc_char(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mask.memview)) __PYX_ERR(0, 32, __pyx_L3_error)
__pyx_v_bin_size = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_bin_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 33, __pyx_L3_error)
__pyx_v_min_good_pixel_count = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_min_good_pixel_count == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 33, __pyx_L3_error)
__pyx_v_bad_pixel_value = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_bad_pixel_value == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 33, __pyx_L3_error)
__pyx_v_saturation_value = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_saturation_value == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 34, __pyx_L3_error)
__pyx_v_asic_size_fs = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_asic_size_fs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 34, __pyx_L3_error)
__pyx_v_asic_size_ss = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_asic_size_ss == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error)
__pyx_v_num_asics_fs = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_num_asics_fs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error)
__pyx_v_num_asics_ss = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_num_asics_ss == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("bin_detector_data", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 32, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("om.algorithms._generic.bin_detector_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_2om_10algorithms_8_generic_bin_detector_data(__pyx_self, __pyx_v_data, __pyx_v_binned_data, __pyx_v_mask, __pyx_v_bin_size, __pyx_v_min_good_pixel_count, __pyx_v_bad_pixel_value, __pyx_v_saturation_value, __pyx_v_asic_size_fs, __pyx_v_asic_size_ss, __pyx_v_num_asics_fs, __pyx_v_num_asics_ss);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_2om_10algorithms_8_generic_bin_detector_data(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_data, __Pyx_memviewslice __pyx_v_binned_data, __Pyx_memviewslice __pyx_v_mask, int __pyx_v_bin_size, int __pyx_v_min_good_pixel_count, double __pyx_v_bad_pixel_value, double __pyx_v_saturation_value, int __pyx_v_asic_size_fs, int __pyx_v_asic_size_ss, int __pyx_v_num_asics_fs, int __pyx_v_num_asics_ss) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("bin_detector_data", 0);
/* … */
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_AddTraceback("om.algorithms._generic.bin_detector_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__PYX_XDEC_MEMVIEW(&__pyx_v_data, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_binned_data, 1);
__PYX_XDEC_MEMVIEW(&__pyx_v_mask, 1);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__20 = PyTuple_Pack(11, __pyx_n_s_data, __pyx_n_s_binned_data, __pyx_n_s_mask, __pyx_n_s_bin_size, __pyx_n_s_min_good_pixel_count, __pyx_n_s_bad_pixel_value, __pyx_n_s_saturation_value, __pyx_n_s_asic_size_fs, __pyx_n_s_asic_size_ss, __pyx_n_s_num_asics_fs, __pyx_n_s_num_asics_ss); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 32, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__20);
__Pyx_GIVEREF(__pyx_tuple__20);
/* … */
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_2om_10algorithms_8_generic_1bin_detector_data, NULL, __pyx_n_s_om_algorithms__generic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_bin_detector_data, __pyx_t_1) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(11, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cython__generic_pyx, __pyx_n_s_bin_detector_data, 32, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 32, __pyx_L1_error)
33: int bin_size, int min_good_pixel_count, double bad_pixel_value,
34: double saturation_value, int asic_size_fs,
35: int asic_size_ss, int num_asics_fs, int num_asics_ss):
36: """
37: Docstring here
38: """
39:
+40: c_bin_detector_data(&data[0, 0], &binned_data[0,0], &mask[0, 0], bin_size,
__pyx_t_1 = 0;
__pyx_t_2 = 0;
__pyx_t_3 = -1;
if (__pyx_t_1 < 0) {
__pyx_t_1 += __pyx_v_data.shape[0];
if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
} else if (unlikely(__pyx_t_1 >= __pyx_v_data.shape[0])) __pyx_t_3 = 0;
if (__pyx_t_2 < 0) {
__pyx_t_2 += __pyx_v_data.shape[1];
if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
} else if (unlikely(__pyx_t_2 >= __pyx_v_data.shape[1])) __pyx_t_3 = 1;
if (unlikely(__pyx_t_3 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_3);
__PYX_ERR(0, 40, __pyx_L1_error)
}
__pyx_t_4 = 0;
__pyx_t_5 = 0;
__pyx_t_3 = -1;
if (__pyx_t_4 < 0) {
__pyx_t_4 += __pyx_v_binned_data.shape[0];
if (unlikely(__pyx_t_4 < 0)) __pyx_t_3 = 0;
} else if (unlikely(__pyx_t_4 >= __pyx_v_binned_data.shape[0])) __pyx_t_3 = 0;
if (__pyx_t_5 < 0) {
__pyx_t_5 += __pyx_v_binned_data.shape[1];
if (unlikely(__pyx_t_5 < 0)) __pyx_t_3 = 1;
} else if (unlikely(__pyx_t_5 >= __pyx_v_binned_data.shape[1])) __pyx_t_3 = 1;
if (unlikely(__pyx_t_3 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_3);
__PYX_ERR(0, 40, __pyx_L1_error)
}
__pyx_t_6 = 0;
__pyx_t_7 = 0;
__pyx_t_3 = -1;
if (__pyx_t_6 < 0) {
__pyx_t_6 += __pyx_v_mask.shape[0];
if (unlikely(__pyx_t_6 < 0)) __pyx_t_3 = 0;
} else if (unlikely(__pyx_t_6 >= __pyx_v_mask.shape[0])) __pyx_t_3 = 0;
if (__pyx_t_7 < 0) {
__pyx_t_7 += __pyx_v_mask.shape[1];
if (unlikely(__pyx_t_7 < 0)) __pyx_t_3 = 1;
} else if (unlikely(__pyx_t_7 >= __pyx_v_mask.shape[1])) __pyx_t_3 = 1;
if (unlikely(__pyx_t_3 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_3);
__PYX_ERR(0, 40, __pyx_L1_error)
}
/* … */
c_bin_detector_data((&(*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_data.data + __pyx_t_1 * __pyx_v_data.strides[0]) )) + __pyx_t_2)) )))), (&(*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_binned_data.data + __pyx_t_4 * __pyx_v_binned_data.strides[0]) )) + __pyx_t_5)) )))), (&(*((char *) ( /* dim=1 */ ((char *) (((char *) ( /* dim=0 */ (__pyx_v_mask.data + __pyx_t_6 * __pyx_v_mask.strides[0]) )) + __pyx_t_7)) )))), __pyx_v_bin_size, __pyx_v_min_good_pixel_count, __pyx_v_bad_pixel_value, __pyx_v_saturation_value, __pyx_v_asic_size_fs, __pyx_v_asic_size_ss, __pyx_v_num_asics_fs, __pyx_v_num_asics_ss);
41: min_good_pixel_count, bad_pixel_value,
42: saturation_value, asic_size_fs,
43: asic_size_ss, num_asics_fs, num_asics_ss)