From 1eb006e9bd85542e6668be17313580011b1c87d1 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 22 Mar 2024 17:32:06 +0100 Subject: [PATCH] unix line endings --- peakfinder8/cython/peakfinder8.hh | 2 +- peakfinder8/cython/peakfinder8_extension.pyx | 236 +++++++++---------- setup.py | 30 +-- 3 files changed, 134 insertions(+), 134 deletions(-) diff --git a/peakfinder8/cython/peakfinder8.hh b/peakfinder8/cython/peakfinder8.hh index 2d5a971..9f03999 100644 --- a/peakfinder8/cython/peakfinder8.hh +++ b/peakfinder8/cython/peakfinder8.hh @@ -1 +1 @@ -int peakfinder8(tPeakList*, float*, char*, float*, long, long, long, long, float, float, long, long, long); +int peakfinder8(tPeakList*, float*, char*, float*, long, long, long, long, float, float, long, long, long); diff --git a/peakfinder8/cython/peakfinder8_extension.pyx b/peakfinder8/cython/peakfinder8_extension.pyx index bdb52b1..c934a36 100644 --- a/peakfinder8/cython/peakfinder8_extension.pyx +++ b/peakfinder8/cython/peakfinder8_extension.pyx @@ -1,118 +1,118 @@ -cimport numpy -from libcpp.vector cimport vector -from libc.stdlib cimport malloc, free - -# -# PEAKFINDER 8 -# - -cdef extern from "peakfinders.h": - - ctypedef struct tPeakList: - long nPeaks - long nHot - float peakResolution - float peakResolutionA - float peakDensity - float peakNpix - float peakTotal - int memoryAllocated - long nPeaks_max - - float *peak_maxintensity - float *peak_totalintensity - float *peak_sigma - float *peak_snr - float *peak_npix - float *peak_com_x - float *peak_com_y - long *peak_com_index - float *peak_com_x_assembled - float *peak_com_y_assembled - float *peak_com_r_assembled - float *peak_com_q - float *peak_com_res - - void allocatePeakList(tPeakList* peak_list, long max_num_peaks) - void freePeakList(tPeakList peak_list) - -cdef extern from "peakfinder8.hh": - - int peakfinder8( - tPeakList *peaklist, - float *data, - char *mask, - float *pix_r, - long asic_nx, - long asic_ny, - long nasics_x, - long nasics_y, - float ADCthresh, - float hitfinderMinSNR, - long hitfinderMinPixCount, - long hitfinderMaxPixCount, - long hitfinderLocalBGRadius - ) - -def peakfinder_8( - int max_num_peaks, - numpy.ndarray[numpy.float32_t, ndim=2, mode="c"] data, - numpy.ndarray[numpy.int8_t, ndim=2, mode="c"] mask, - numpy.ndarray[numpy.float32_t, ndim=2, mode="c"] pix_r, - long asic_nx, - long asic_ny, - long nasics_x, - long nasics_y, - float adc_thresh, - float hitfinder_min_snr, - long hitfinder_min_pix_count, - long hitfinder_max_pix_count, - long hitfinder_local_bg_radius - ): - - cdef numpy.int8_t *mask_pointer = &mask[0,0] - cdef char *mask_char_pointer = mask_pointer - - cdef tPeakList peak_list - allocatePeakList(&peak_list, max_num_peaks) - - peakfinder8( - &peak_list, - &data[0,0], - mask_char_pointer, - &pix_r[0,0], - asic_nx, - asic_ny, - nasics_x, - nasics_y, - adc_thresh, - hitfinder_min_snr, - hitfinder_min_pix_count, - hitfinder_max_pix_count, - hitfinder_local_bg_radius - ) - - cdef int i - cdef float peak_x, peak_y, peak_value - cdef vector[double] peak_list_x - cdef vector[double] peak_list_y - cdef vector[double] peak_list_value - - num_peaks = peak_list.nPeaks - - if num_peaks > max_num_peaks: - num_peaks = max_num_peaks - - for i in range(0, num_peaks): - - peak_x = peak_list.peak_com_x[i] - peak_y = peak_list.peak_com_y[i] - peak_value = peak_list.peak_totalintensity[i] - - peak_list_x.push_back(peak_x) - peak_list_y.push_back(peak_y) - peak_list_value.push_back(peak_value) - - freePeakList(peak_list) - - return (peak_list_x, peak_list_y, peak_list_value) +cimport numpy +from libcpp.vector cimport vector +from libc.stdlib cimport malloc, free + +# +# PEAKFINDER 8 +# + +cdef extern from "peakfinders.h": + + ctypedef struct tPeakList: + long nPeaks + long nHot + float peakResolution + float peakResolutionA + float peakDensity + float peakNpix + float peakTotal + int memoryAllocated + long nPeaks_max + + float *peak_maxintensity + float *peak_totalintensity + float *peak_sigma + float *peak_snr + float *peak_npix + float *peak_com_x + float *peak_com_y + long *peak_com_index + float *peak_com_x_assembled + float *peak_com_y_assembled + float *peak_com_r_assembled + float *peak_com_q + float *peak_com_res + + void allocatePeakList(tPeakList* peak_list, long max_num_peaks) + void freePeakList(tPeakList peak_list) + +cdef extern from "peakfinder8.hh": + + int peakfinder8( + tPeakList *peaklist, + float *data, + char *mask, + float *pix_r, + long asic_nx, + long asic_ny, + long nasics_x, + long nasics_y, + float ADCthresh, + float hitfinderMinSNR, + long hitfinderMinPixCount, + long hitfinderMaxPixCount, + long hitfinderLocalBGRadius + ) + +def peakfinder_8( + int max_num_peaks, + numpy.ndarray[numpy.float32_t, ndim=2, mode="c"] data, + numpy.ndarray[numpy.int8_t, ndim=2, mode="c"] mask, + numpy.ndarray[numpy.float32_t, ndim=2, mode="c"] pix_r, + long asic_nx, + long asic_ny, + long nasics_x, + long nasics_y, + float adc_thresh, + float hitfinder_min_snr, + long hitfinder_min_pix_count, + long hitfinder_max_pix_count, + long hitfinder_local_bg_radius + ): + + cdef numpy.int8_t *mask_pointer = &mask[0,0] + cdef char *mask_char_pointer = mask_pointer + + cdef tPeakList peak_list + allocatePeakList(&peak_list, max_num_peaks) + + peakfinder8( + &peak_list, + &data[0,0], + mask_char_pointer, + &pix_r[0,0], + asic_nx, + asic_ny, + nasics_x, + nasics_y, + adc_thresh, + hitfinder_min_snr, + hitfinder_min_pix_count, + hitfinder_max_pix_count, + hitfinder_local_bg_radius + ) + + cdef int i + cdef float peak_x, peak_y, peak_value + cdef vector[double] peak_list_x + cdef vector[double] peak_list_y + cdef vector[double] peak_list_value + + num_peaks = peak_list.nPeaks + + if num_peaks > max_num_peaks: + num_peaks = max_num_peaks + + for i in range(0, num_peaks): + + peak_x = peak_list.peak_com_x[i] + peak_y = peak_list.peak_com_y[i] + peak_value = peak_list.peak_totalintensity[i] + + peak_list_x.push_back(peak_x) + peak_list_y.push_back(peak_y) + peak_list_value.push_back(peak_value) + + freePeakList(peak_list) + + return (peak_list_x, peak_list_y, peak_list_value) diff --git a/setup.py b/setup.py index 90039b3..646f5cc 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,15 @@ -peakfinder8_include_dir = 'peakfinder8/' -peakfinder8_library_dir = 'peakfinder8/' - -from distutils.core import setup , Extension -from Cython.Build import cythonize -import numpy - -peakfinder8_ext = Extension ( "peakfinder8_extension" , sources = [ "peakfinder8/cython/peakfinder8_extension.pyx"] , - include_dirs = [ peakfinder8_include_dir, numpy.get_include() ], - library_dirs = [ peakfinder8_library_dir ], - libraries=["peakfinder8"], - language = "c++" ) - - -setup ( name = "peakfinder8_extension" , ext_modules = cythonize ( peakfinder8_ext )) +peakfinder8_include_dir = 'peakfinder8/' +peakfinder8_library_dir = 'peakfinder8/' + +from distutils.core import setup , Extension +from Cython.Build import cythonize +import numpy + +peakfinder8_ext = Extension ( "peakfinder8_extension" , sources = [ "peakfinder8/cython/peakfinder8_extension.pyx"] , + include_dirs = [ peakfinder8_include_dir, numpy.get_include() ], + library_dirs = [ peakfinder8_library_dir ], + libraries=["peakfinder8"], + language = "c++" ) + + +setup ( name = "peakfinder8_extension" , ext_modules = cythonize ( peakfinder8_ext ))