From 3823d5107417a4db9bcde756d9c433838c2bf59b Mon Sep 17 00:00:00 2001 From: "J.A. de Jong" Date: Sun, 1 Apr 2018 19:06:50 +0200 Subject: [PATCH] Changed default window for AvPowerSpectra to Hann. Bugfix in AvPowerSpectra. Finished and tseted SPLowpass. --- lasp/c/lasp_sp_lowpass.c | 4 +++- lasp/c/lasp_sp_lowpass.h | 2 +- lasp/wrappers.pyx | 21 ++++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lasp/c/lasp_sp_lowpass.c b/lasp/c/lasp_sp_lowpass.c index bc617ae..2242d0f 100644 --- a/lasp/c/lasp_sp_lowpass.c +++ b/lasp/c/lasp_sp_lowpass.c @@ -50,7 +50,9 @@ vd SPLowpass_filter(SPLowpass* lp, fsTRACE(15); dbgassert(lp && input,NULLPTRDEREF); - us input_size = input->size; + assert_vx(input); + us input_size = input->n_rows; + if(input_size == 0) { return vd_alloc(0); } diff --git a/lasp/c/lasp_sp_lowpass.h b/lasp/c/lasp_sp_lowpass.h index c2e9801..1229968 100644 --- a/lasp/c/lasp_sp_lowpass.h +++ b/lasp/c/lasp_sp_lowpass.h @@ -11,7 +11,7 @@ #ifndef LASP_SP_LOWPASS_H #define LASP_SP_LOWPASS_H #include "lasp_types.h" -#include "lasp_math.h" +#include "lasp_mat.h" typedef struct SPLowpass_s SPLowpass; diff --git a/lasp/wrappers.pyx b/lasp/wrappers.pyx index 185f403..f59c68f 100644 --- a/lasp/wrappers.pyx +++ b/lasp/wrappers.pyx @@ -207,7 +207,7 @@ cdef class AvPowerSpectra: def __cinit__(self,us nfft, us nchannels, d overlap_percentage, - us window=Window.rectangular, + us window=Window.hann, d[:] weighting = np.array([])): @@ -266,11 +266,13 @@ cdef class AvPowerSpectra: result = np.empty((self.nfft//2+1,nchannels,nchannels), dtype = NUMPY_COMPLEX_TYPE, order='F') + cdef c[::1,:,:] result_view = result + cdef cmat res = cmat_foreign_data(self.nfft//2+1, nchannels*nchannels, &result_view[0,0,0], - True) + False) # Copy result cmat_copy(&res,result_ptr) @@ -374,14 +376,15 @@ cdef class SPLowpass: SPLowpass_free(self.lp) def filter_(self,d[:] input_): - # cdef vd input_vd = vd_foreign(input_.size,&input_[0]) - # cdef dmat output = FilterBank_filter(self.fb,&input_vd) + cdef vd input_vd = dmat_foreign_data(input_.shape[0],1, + &input_[0],False) + + cdef dmat output = SPLowpass_filter(self.lp,&input_vd) # # Steal the pointer from output - # result = dmat_to_ndarray(&output,True) + result = dmat_to_ndarray(&output,True) - # dmat_free(&output) - # vd_free(&input_vd) + dmat_free(&output) + vd_free(&input_vd) - # return result - pass + return result