From 51d38798c3bf4a8e2ba16b0fee840aac72284e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Wed, 13 Mar 2019 22:35:35 +0200 Subject: [PATCH] Some useful ScatteringSystem class functionality. Former-commit-id: c7ae5dcd3f601b79781b685804dae5262fc2a93d --- qpms/qpms_c.pyx | 26 ++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index 5a0c85b..f6ce56e 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -1116,6 +1116,9 @@ cdef class TMatrixInterpolator: free(self.tmdata) free(self.freqs_su) free(self.freqs) + property freq_interval: + def __get__(self): + return [self.freqs[0], self.freqs[self.nfreqs-1]] cdef class CTMatrix: # N.B. there is another type called TMatrix in tmatrices.py! ''' @@ -1479,8 +1482,31 @@ cdef class ScatteringSystem: cdef cdouble[:,::1] target_view = target qpms_scatsys_build_translation_matrix_full(&target_view[0][0], self.s, k) return target + + def fullvec_psizes(self): + cdef np.ndarray[int32_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.int32) + cdef int32_t[::1] ar_view = ar + for pi in range(self.s[0].p_count): + ar_view[pi] = self.s[0].tm[self.s[0].p[pi].tmatrix_id].spec[0].n + return ar + def fullvec_poffsets(self): + cdef np.ndarray[intptr_t, ndim=1] ar = np.empty((self.s[0].p_count,), dtype=np.intp) + cdef intptr_t[::1] ar_view = ar + cdef intptr_t offset = 0 + for pi in range(self.s[0].p_count): + ar_view[pi] = offset + offset += self.s[0].tm[self.s[0].p[pi].tmatrix_id].spec[0].n + return ar + def positions(self): + cdef np.ndarray[np.double_t, ndim=2] ar = np.empty((self.s[0].p_count, 3), dtype=float) + cdef np.double_t[:,::1] ar_view = ar + for pi in range(self.s[0].p_count): + ar_view[pi,0] = self.s[0].p[pi].pos.x + ar_view[pi,1] = self.s[0].p[pi].pos.y + ar_view[pi,2] = self.s[0].p[pi].pos.z + return ar def tlm2uvswfi(t, l, m): ''' TODO doc diff --git a/setup.py b/setup.py index 7d652a4..5541387 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ qpms_c = Extension('qpms_c', 'qpms/legendre.c', 'qpms/tmatrix_io.c', 'qpms/error.c'], - extra_compile_args=['-std=c99','-ggdb', '-O0', + extra_compile_args=['-std=c99','-ggdb', '-O3', '-DQPMS_COMPILE_PYTHON_EXTENSIONS', # this is required #'-DQPMS_USE_OMP', '-DDISABLE_NDEBUG', # uncomment to enable assertions in the modules