Reactivate parallel for sphrical projection, add some auxiliary attribute in ctpv.
This commit is contained in:
parent
897427436e
commit
18c81baac9
@ -874,11 +874,11 @@ def spherical_projection(int Nside,
|
|||||||
job_done = view.array(shape=(N,), format="i", itemsize=sizeof(int))
|
job_done = view.array(shape=(N,), format="i", itemsize=sizeof(int))
|
||||||
job_done[:] = 0
|
job_done[:] = 0
|
||||||
theta,phi = hp.pix2ang(Nside, np.arange(N0))
|
theta,phi = hp.pix2ang(Nside, np.arange(N0))
|
||||||
if True:#nogil, parallel():
|
with nogil, parallel():
|
||||||
tid = smp_get_thread_id()
|
tid = smp_get_thread_id()
|
||||||
for i in range(N0):#prange(N0,schedule='dynamic',chunksize=256):
|
for i in prange(N0,schedule='dynamic',chunksize=256):
|
||||||
if progress != 0 and (i%booster) == 0:
|
if progress != 0 and (i%booster) == 0:
|
||||||
# with gil:
|
with gil:
|
||||||
p.update(_mysum(job_done))
|
p.update(_mysum(job_done))
|
||||||
outm[i] = _spherical_projloop(theta[i], phi[i], density_view, min_distance, max_distance, shifter, integrator_id)
|
outm[i] = _spherical_projloop(theta[i], phi[i], density_view, min_distance, max_distance, shifter, integrator_id)
|
||||||
job_done[tid] += 1
|
job_done[tid] += 1
|
||||||
|
@ -4,7 +4,7 @@ from contextlib import contextmanager
|
|||||||
class ProgrammableParticleLoad(object):
|
class ProgrammableParticleLoad(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def main_script(source, particles, aname="default"):
|
def main_script(source, particles, aname="default", aux=None):
|
||||||
import vtk
|
import vtk
|
||||||
from vtk.util import numpy_support as ns
|
from vtk.util import numpy_support as ns
|
||||||
|
|
||||||
@ -20,6 +20,15 @@ class ProgrammableParticleLoad(object):
|
|||||||
out.Allocate(1,1)
|
out.Allocate(1,1)
|
||||||
out.SetPoints(vv)
|
out.SetPoints(vv)
|
||||||
|
|
||||||
|
if aux is not None:
|
||||||
|
for n,a in aux:
|
||||||
|
a_vtk = ns.numpy_to_vtk(
|
||||||
|
np.ascontiguousarray(a.astype(np.float64)
|
||||||
|
),
|
||||||
|
deep=1)
|
||||||
|
a_vtk.SetName(n)
|
||||||
|
out.GetPointData().AddArray(a_vtk)
|
||||||
|
|
||||||
out.InsertNextCell(vtk.VTK_VERTEX, particles.shape[0], range(particles.shape[0]))
|
out.InsertNextCell(vtk.VTK_VERTEX, particles.shape[0], range(particles.shape[0]))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user