diff --git a/lasp/wrappers.pyx b/lasp/wrappers.pyx index 8d7d350..3c2698f 100644 --- a/lasp/wrappers.pyx +++ b/lasp/wrappers.pyx @@ -430,7 +430,9 @@ cdef extern from "lasp_sosfilterbank.h": cdef class SosFilterBank: cdef: c_Sosfilterbank* fb + us nsections def __cinit__(self,const us filterbank_size, const us nsections): + self.nsections = nsections self.fb = Sosfilterbank_create(0, filterbank_size,nsections) @@ -441,11 +443,18 @@ cdef class SosFilterBank: filter_no: Filter number of the filterbank to set the filter for sos: Second axis are the filter coefficients, first axis - is the section + is the section, second axis are the coefficients for that section. + Storage is in agreement with specification from Scipy: first axis + is the section, second axis are the coefficients for that section. """ + if sos.shape[0] != self.nsections: + raise RuntimeError('Invalid number of sections in filter data, should be {self.nsections.}') + elif sos.shape[1] != 6: + raise RuntimeError('Illegal number of filter coefficients in section. Should be 6.') cdef dmat coefs = dmat_foreign_data(sos.size,1, - &sos[0, 0],False) + &sos[0, 0],False # No copying + ) Sosfilterbank_setFilter(self.fb,filter_no, coefs) def __dealloc__(self):