Update to allow accumulators in CIC projection
This commit is contained in:
parent
a16ae60382
commit
6cafdd50b2
@ -116,8 +116,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cosmotool/config.py.in ${CMAKE_CURREN
|
||||
|
||||
INSTALL(TARGETS
|
||||
${ct_TARGETS}
|
||||
COMPONENT python
|
||||
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}/cosmotool
|
||||
)
|
||||
|
||||
INSTALL(DIRECTORY cosmotool ${CMAKE_CURRENT_BINARY_DIR}/cosmotool DESTINATION ${PYTHON_SITE_PACKAGES}
|
||||
INSTALL(DIRECTORY cosmotool ${CMAKE_CURRENT_BINARY_DIR}/cosmotool
|
||||
COMPONENT python DESTINATION ${PYTHON_SITE_PACKAGES}
|
||||
FILES_MATCHING PATTERN "*.py")
|
||||
|
||||
add_custom_target(
|
||||
python-install
|
||||
DEPENDS ${ct_TARGETS}
|
||||
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=python -P
|
||||
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
||||
|
||||
|
@ -247,6 +247,9 @@ class PySimulationAdaptor(PySimulationBase):
|
||||
def __init__(self,sim):
|
||||
self.simu = sim
|
||||
|
||||
def getNumParticles(self):
|
||||
return self.simu.numParticles
|
||||
|
||||
def getBoxsize(self):
|
||||
return self.simu.BoxSize
|
||||
|
||||
|
@ -533,12 +533,13 @@ cdef void INTERNAL_project_cic_with_mass_periodic(DTYPE_t[:,:,:] g,
|
||||
|
||||
|
||||
def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, ndim=1] mass, int Ngrid,
|
||||
double Lbox, bool periodic = False, centered=True):
|
||||
double Lbox, bool periodic = False, centered=True, output=None):
|
||||
"""
|
||||
project_cic(x array (N,3), mass (may be None), Ngrid, Lbox, periodict, centered=True)
|
||||
project_cic(x array (N,3), mass (may be None), Ngrid, Lbox, periodict, centered=True, output=None)
|
||||
|
||||
This function does a Cloud-In-Cell projection of a 3d unstructured dataset. First argument is a Nx3 array of coordinates.
|
||||
Second argument is an optinal mass. Ngrid is the size output grid and Lbox is the physical size of the grid.
|
||||
if output is not None, it must be a numpy array with dimension NgridxNgridxNgrid. The result will be accumulated in that array.
|
||||
"""
|
||||
cdef npx.ndarray[DTYPE_t, ndim=3] g
|
||||
cdef double shifter
|
||||
@ -558,7 +559,13 @@ def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, nd
|
||||
if mass is not None and mass.shape[0] != x.shape[0]:
|
||||
raise ValueError("Mass array and coordinate array must have the same number of elements")
|
||||
|
||||
if output is None:
|
||||
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
|
||||
else:
|
||||
if type(output) != np.ndarray:
|
||||
raise ValueError("Invalid array type")
|
||||
g = output
|
||||
|
||||
cdef DTYPE_t[:,:,:] d_g = g
|
||||
cdef DTYPE_t[:,:] d_x = x
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user