Infrastructure for better spherical projection

This commit is contained in:
Guilhem Lavaux 2014-06-04 16:25:24 +02:00
parent 1693c222e1
commit be03931328
2 changed files with 151 additions and 36 deletions

View file

@ -9,6 +9,11 @@ DTYPE=np.float64
__all__=["project_cic","line_of_sight_projection","spherical_projection","DTYPE","interp3d","interp2d"]
cdef extern from "project_tools.hpp" namespace "":
DTYPE_t compute_projection(DTYPE_t *vertex_value, DTYPE_t *u, DTYPE_t *u0, DTYPE_t rho)
@cython.boundscheck(False)
@cython.cdivision(True)
cdef DTYPE_t interp3d_INTERNAL_periodic(DTYPE_t x, DTYPE_t y,
@ -520,49 +525,46 @@ cdef DTYPE_t cube_integral(DTYPE_t u[3], DTYPE_t u0[3], int r[1]):
return alpha_max
#cdef DTYPE_t cube_integral_trilin(DTYPE_t u[3], DTYPE_t u0[3], int r[1], DTYPE_t vertex_value[8]):
# cdef DTYPE_t alpha_max
# cdef DTYPE_t tmp_a
# cdef DTYPE_t v[3], term[4]
# cdef int i, j, q
@cython.boundscheck(False)
@cython.cdivision(True)
cdef DTYPE_t mysum(DTYPE_t *v, int q) nogil:
cdef int i
cdef DTYPE_t s
s = 0
for i in xrange(q):
s += v[i]
return s
# alpha_max = 10.0 # A big number
@cython.boundscheck(False)
@cython.cdivision(True)
cdef DTYPE_t cube_integral_trilin(DTYPE_t u[3], DTYPE_t u0[3], int r[1], DTYPE_t vertex_value[8]):
cdef DTYPE_t alpha_max
cdef DTYPE_t tmp_a
cdef DTYPE_t v[3], term[4]
cdef int i, j, q
# j = 0
# for i in range(3):
# if u[i] == 0.:
# continue
alpha_max = 10.0 # A big number
# if u[i] < 0:
# tmp_a = -u0[i]/u[i]
# else:
# tmp_a = (1-u0[i])/u[i]
j = 0
for i in range(3):
if u[i] == 0.:
continue
# if tmp_a < alpha_max:
# alpha_max = tmp_a
# j = i
if u[i] < 0:
tmp_a = -u0[i]/u[i]
else:
tmp_a = (1-u0[i])/u[i]
if tmp_a < alpha_max:
alpha_max = tmp_a
j = i
# alpha_max is the integration length
# now we compute the integration of a trilinearly interpolated field
# There are four terms.
# we integrate between 0 and alpha_max (curvilinear coordinates)
# First term
# term[0]= (u0[0]*u0[1]*u0[2])*sum(vertex_value)
# Second term
# term[1] = 0
#
# for q in range(3):
# for r in range(8):
# pass
# for i in range(3):
# u0[i] += u[i]*alpha_max
# r[0] = j
# return 0#alpha_max
return compute_projection(vertex_value, u, u0, alpha_max)
@cython.boundscheck(False)
def line_of_sight_projection(npx.ndarray[DTYPE_t, ndim=3] density,