[yt-svn] commit/yt: 3 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Apr 8 10:23:27 PDT 2014


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/7ea355912acb/
Changeset:   7ea355912acb
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-23 18:28:19
Summary:     A few updates to the rockstar_groupies file
Affected #:  1 file

diff -r 8837ee7c34661a606808d55b17878207f9e8da36 -r 7ea355912acb4334a8e25ce85533bf4922db6e08 yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
@@ -11,234 +11,232 @@
 # Importing relevant rockstar data types particle, fof halo, halo
 
 cdef import from "particle.h":
-	struct particle:
-		np.int64_t id
-		float pos[6]
+    struct particle:
+        np.int64_t id
+        float pos[6]
 
 cdef import from "fof.h":
-	struct fof:
-		np.int64_t num_p
-		particle *particles
+    struct fof:
+        np.int64_t num_p
+        particle *particles
 
 cdef import from "halo.h":
-	struct halo:
-		np.int64_t id
-		float pos[6], corevel[3], bulkvel[3]
-		float m, r, child_r, vmax_r, mgrav,	vmax, rvmax, rs, klypin_rs, vrms
-		float J[3], energy, spin, alt_m[4], Xoff, Voff, b_to_a, c_to_a, A[3]
-		float bullock_spin, kin_to_pot
-		np.int64_t num_p, num_child_particles, p_start, desc, flags, n_core
-		float min_pos_err, min_vel_err, min_bulkvel_err
+    struct halo:
+        np.int64_t id
+        float pos[6], corevel[3], bulkvel[3]
+        float m, r, child_r, vmax_r, mgrav,    vmax, rvmax, rs, klypin_rs, vrms
+        float J[3], energy, spin, alt_m[4], Xoff, Voff, b_to_a, c_to_a, A[3]
+        float bullock_spin, kin_to_pot
+        np.int64_t num_p, num_child_particles, p_start, desc, flags, n_core
+        float min_pos_err, min_vel_err, min_bulkvel_err
 
 # For finding sub halos import finder function and global variable
 # rockstar uses to store the results
 
 cdef import from "groupies.h":
-	void find_subs(fof *f) 
-	halo *halos
-	np.int64_t num_halos
-	void calc_mass_definition()
+    void find_subs(fof *f) nogil
+    halo *halos
+    np.int64_t num_halos
+    void calc_mass_definition() nogil
 
 # For outputing halos, rockstar style
 
 cdef import from "meta_io.h":
-	void output_halos(np.int64_t id_offset, np.int64_t snap, np.int64_t chunk, float *bounds) 
+    void output_halos(np.int64_t id_offset, np.int64_t snap, np.int64_t chunk, float *bounds) nogil
 
 # For setting up the configuration of rockstar
 
 cdef import from "config.h":
-	void setup_config()
+    void setup_config() nogil
 
 cdef import from "config_vars.h":
-	# Rockstar cleverly puts all of the config variables inside a templated
-	# definition of their vaiables.
-	char *FILE_FORMAT
-	np.float64_t PARTICLE_MASS
+    # Rockstar cleverly puts all of the config variables inside a templated
+    # definition of their vaiables.
+    char *FILE_FORMAT
+    np.float64_t PARTICLE_MASS
 
-	char *MASS_DEFINITION
-	np.int64_t MIN_HALO_OUTPUT_SIZE
-	np.float64_t FORCE_RES
+    char *MASS_DEFINITION
+    np.int64_t MIN_HALO_OUTPUT_SIZE
+    np.float64_t FORCE_RES
 
-	np.float64_t SCALE_NOW
-	np.float64_t h0
-	np.float64_t Ol
-	np.float64_t Om
+    np.float64_t SCALE_NOW
+    np.float64_t h0
+    np.float64_t Ol
+    np.float64_t Om
 
-	np.int64_t GADGET_ID_BYTES
-	np.float64_t GADGET_MASS_CONVERSION
-	np.float64_t GADGET_LENGTH_CONVERSION
-	np.int64_t GADGET_SKIP_NON_HALO_PARTICLES
-	np.int64_t RESCALE_PARTICLE_MASS
+    np.int64_t GADGET_ID_BYTES
+    np.float64_t GADGET_MASS_CONVERSION
+    np.float64_t GADGET_LENGTH_CONVERSION
+    np.int64_t GADGET_SKIP_NON_HALO_PARTICLES
+    np.int64_t RESCALE_PARTICLE_MASS
 
-	np.int64_t PARALLEL_IO
-	char *PARALLEL_IO_SERVER_ADDRESS
-	char *PARALLEL_IO_SERVER_PORT
-	np.int64_t PARALLEL_IO_WRITER_PORT
-	char *PARALLEL_IO_SERVER_INTERFACE
-	char *RUN_ON_SUCCESS
+    np.int64_t PARALLEL_IO
+    char *PARALLEL_IO_SERVER_ADDRESS
+    char *PARALLEL_IO_SERVER_PORT
+    np.int64_t PARALLEL_IO_WRITER_PORT
+    char *PARALLEL_IO_SERVER_INTERFACE
+    char *RUN_ON_SUCCESS
 
-	char *INBASE
-	char *FILENAME
-	np.int64_t STARTING_SNAP
-	np.int64_t NUM_SNAPS
-	np.int64_t NUM_BLOCKS
-	np.int64_t NUM_READERS
-	np.int64_t PRELOAD_PARTICLES
-	char *SNAPSHOT_NAMES
-	char *LIGHTCONE_ALT_SNAPS
-	char *BLOCK_NAMES
+    char *INBASE
+    char *FILENAME
+    np.int64_t STARTING_SNAP
+    np.int64_t NUM_SNAPS
+    np.int64_t NUM_BLOCKS
+    np.int64_t NUM_READERS
+    np.int64_t PRELOAD_PARTICLES
+    char *SNAPSHOT_NAMES
+    char *LIGHTCONE_ALT_SNAPS
+    char *BLOCK_NAMES
 
-	char *OUTBASE
-	np.float64_t OVERLAP_LENGTH
-	np.int64_t NUM_WRITERS
-	np.int64_t FORK_READERS_FROM_WRITERS
-	np.int64_t FORK_PROCESSORS_PER_MACHINE
+    char *OUTBASE
+    np.float64_t OVERLAP_LENGTH
+    np.int64_t NUM_WRITERS
+    np.int64_t FORK_READERS_FROM_WRITERS
+    np.int64_t FORK_PROCESSORS_PER_MACHINE
 
-	char *OUTPUT_FORMAT
-	np.int64_t DELETE_BINARY_OUTPUT_AFTER_FINISHED
-	np.int64_t FULL_PARTICLE_CHUNKS
-	char *BGC2_SNAPNAMES
+    char *OUTPUT_FORMAT
+    np.int64_t DELETE_BINARY_OUTPUT_AFTER_FINISHED
+    np.int64_t FULL_PARTICLE_CHUNKS
+    char *BGC2_SNAPNAMES
 
-	np.int64_t BOUND_PROPS
-	np.int64_t BOUND_OUT_TO_HALO_EDGE
-	np.int64_t DO_MERGER_TREE_ONLY
-	np.int64_t IGNORE_PARTICLE_IDS
-	np.float64_t TRIM_OVERLAP
-	np.float64_t ROUND_AFTER_TRIM
-	np.int64_t LIGHTCONE
-	np.int64_t PERIODIC
+    np.int64_t BOUND_PROPS
+    np.int64_t BOUND_OUT_TO_HALO_EDGE
+    np.int64_t DO_MERGER_TREE_ONLY
+    np.int64_t IGNORE_PARTICLE_IDS
+    np.float64_t TRIM_OVERLAP
+    np.float64_t ROUND_AFTER_TRIM
+    np.int64_t LIGHTCONE
+    np.int64_t PERIODIC
 
-	np.float64_t LIGHTCONE_ORIGIN[3]
-	np.float64_t LIGHTCONE_ALT_ORIGIN[3]
+    np.float64_t LIGHTCONE_ORIGIN[3]
+    np.float64_t LIGHTCONE_ALT_ORIGIN[3]
 
-	np.float64_t LIMIT_CENTER[3]
-	np.float64_t LIMIT_RADIUS
+    np.float64_t LIMIT_CENTER[3]
+    np.float64_t LIMIT_RADIUS
 
-	np.int64_t SWAP_ENDIANNESS
-	np.int64_t GADGET_VARIANT
+    np.int64_t SWAP_ENDIANNESS
+    np.int64_t GADGET_VARIANT
 
-	np.float64_t FOF_FRACTION
-	np.float64_t FOF_LINKING_LENGTH
-	np.float64_t INCLUDE_HOST_POTENTIAL_RATIO
-	np.float64_t DOUBLE_COUNT_SUBHALO_MASS_RATIO
-	np.int64_t TEMPORAL_HALO_FINDING
-	np.int64_t MIN_HALO_PARTICLES
-	np.float64_t UNBOUND_THRESHOLD
-	np.int64_t ALT_NFW_METRIC
+    np.float64_t FOF_FRACTION
+    np.float64_t FOF_LINKING_LENGTH
+    np.float64_t INCLUDE_HOST_POTENTIAL_RATIO
+    np.float64_t DOUBLE_COUNT_SUBHALO_MASS_RATIO
+    np.int64_t TEMPORAL_HALO_FINDING
+    np.int64_t MIN_HALO_PARTICLES
+    np.float64_t UNBOUND_THRESHOLD
+    np.int64_t ALT_NFW_METRIC
 
-	np.int64_t TOTAL_PARTICLES
-	np.float64_t BOX_SIZE
-	np.int64_t OUTPUT_HMAD
-	np.int64_t OUTPUT_PARTICLES
-	np.int64_t OUTPUT_LEVELS
-	np.float64_t DUMP_PARTICLES[3]
+    np.int64_t TOTAL_PARTICLES
+    np.float64_t BOX_SIZE
+    np.int64_t OUTPUT_HMAD
+    np.int64_t OUTPUT_PARTICLES
+    np.int64_t OUTPUT_LEVELS
+    np.float64_t DUMP_PARTICLES[3]
 
-	np.float64_t AVG_PARTICLE_SPACING
-	np.int64_t SINGLE_SNAP
+    np.float64_t AVG_PARTICLE_SPACING
+    np.int64_t SINGLE_SNAP
 
 
 
 cdef class RockstarGroupiesInterface:
-	
-	cdef public object pf
-	cdef public object fof
+    
+    cdef public object pf
+    cdef public object fof
 
-	# For future use/consistency
-	def __cinit__(self,pf):
-		self.pf = pf
+    # For future use/consistency
+    def __cinit__(self,pf):
+        self.pf = pf
 
-	def setup_rockstar(self,
-						particle_mass,
-						int periodic = 1, force_res=None,
-						int min_halo_size = 25, outbase = "None",
-						callbacks = None):
-		global FILENAME, FILE_FORMAT, NUM_SNAPS, STARTING_SNAP, h0, Ol, Om
-		global BOX_SIZE, PERIODIC, PARTICLE_MASS, NUM_BLOCKS, NUM_READERS
-		global FORK_READERS_FROM_WRITERS, PARALLEL_IO_WRITER_PORT, NUM_WRITERS
-		global rh, SCALE_NOW, OUTBASE, MIN_HALO_OUTPUT_SIZE
-		global OVERLAP_LENGTH, TOTAL_PARTICLES, FORCE_RES
-		
+    def setup_rockstar(self,
+                        particle_mass,
+                        int periodic = 1, force_res=None,
+                        int min_halo_size = 25, outbase = "None",
+                        callbacks = None):
+        global FILENAME, FILE_FORMAT, NUM_SNAPS, STARTING_SNAP, h0, Ol, Om
+        global BOX_SIZE, PERIODIC, PARTICLE_MASS, NUM_BLOCKS, NUM_READERS
+        global FORK_READERS_FROM_WRITERS, PARALLEL_IO_WRITER_PORT, NUM_WRITERS
+        global rh, SCALE_NOW, OUTBASE, MIN_HALO_OUTPUT_SIZE
+        global OVERLAP_LENGTH, TOTAL_PARTICLES, FORCE_RES
+        
 
-		if force_res is not None:
-			FORCE_RES=np.float64(force_res)
+        if force_res is not None:
+            FORCE_RES=np.float64(force_res)
 
-		OVERLAP_LENGTH = 0.0
-		
-		FILENAME = "inline.<block>"
-		FILE_FORMAT = "GENERIC"
-		OUTPUT_FORMAT = "ASCII"
-		MIN_HALO_OUTPUT_SIZE=min_halo_size
-		
-		pf = self.pf
+        OVERLAP_LENGTH = 0.0
+        
+        FILENAME = "inline.<block>"
+        FILE_FORMAT = "GENERIC"
+        OUTPUT_FORMAT = "ASCII"
+        MIN_HALO_OUTPUT_SIZE=min_halo_size
+        
+        pf = self.pf
 
-		h0 = pf.hubble_constant
-		Ol = pf.omega_lambda
-		Om = pf.omega_matter
-		
-		SCALE_NOW = 1.0/(pf.current_redshift+1.0)
-		
-		if not outbase =='None'.decode('UTF-8'):
-			#output directory. since we can't change the output filenames
-			#workaround is to make a new directory
-			OUTBASE = outbase 
+        h0 = pf.hubble_constant
+        Ol = pf.omega_lambda
+        Om = pf.omega_matter
+        
+        SCALE_NOW = 1.0/(pf.current_redshift+1.0)
+        
+        if not outbase =='None'.decode('UTF-8'):
+            #output directory. since we can't change the output filenames
+            #workaround is to make a new directory
+            OUTBASE = outbase 
 
 
-		PARTICLE_MASS = particle_mass.in_units('Msun/h')
-		PERIODIC = periodic
-		BOX_SIZE = pf.domain_width.in_units('Mpccm/h')[0]
+        PARTICLE_MASS = particle_mass.in_units('Msun/h')
+        PERIODIC = periodic
+        BOX_SIZE = pf.domain_width.in_units('Mpccm/h')[0]
 
-		# Set up the configuration options
-		setup_config()
+        # Set up the configuration options
+        setup_config()
 
-		# Needs to be called so rockstar can use the particle mass parameter
-		# to calculate virial quantities properly
-		calc_mass_definition()
+        # Needs to be called so rockstar can use the particle mass parameter
+        # to calculate virial quantities properly
+        calc_mass_definition()
 
+    def output_halos(self):
+        output_halos(0, 0, 0, NULL) 
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
+    def make_rockstar_fof(self, np.ndarray[np.int64_t, ndim=1] pid,
+                                np.ndarray[np.float64_t, ndim=2] pos,
+                                np.ndarray[np.float64_t, ndim=2] vel,
+                                np.ndarray[np.int64_t, ndim=1] fof_tags,
+                                np.int64_t nfof,
+                                np.int64_t npart_max):
 
-	def make_rockstar_fof(self,fof_ids, pos, vel):
+        # Define fof object
 
-		# Turn positions and velocities into units we want
-		pos = pos.in_units('Mpccm/h')
-		vel = vel.in_units('km/s')
+        # Find number of particles
+        cdef np.int64_t i, j
+        cdef np.int64_t num_particles = pid.shape[0]
 
-		# Define fof object
-		cdef fof fof_obj
+        # Allocate space for correct number of particles
+        cdef particle* particles = <particle*> malloc(npart_max * sizeof(particle))
+        cdef fof fof_obj
+        fof_obj.particles = particles
 
-		# Find number of particles
-		cdef np.int64_t num_particles = len(fof_ids)
+        cdef np.int64_t last_fof_tag = 1
+        cdef np.int64_t k = 0
+        for i in range(num_particles):
+            if fof_tags[i] == 0:
+                continue
+            if fof_tags[i] != last_fof_tag:
+                last_fof_tag = fof_tags[i]
+                if k > 16:
+                    print "Finding subs", k, i
+                    fof_obj.num_p = k
+                    find_subs(&fof_obj)
+                k = 0
+            particles[k].id = pid[i]
 
-		# Allocate space for correct number of particles
-		cdef particle* particles = <particle*> malloc(num_particles * sizeof(particle))
+            # fill in locations & velocities
+            for j in range(3):
+                particles[k].pos[j] = pos[i,j]
+                particles[k].pos[j+3] = vel[i,j]
+            k += 1
+        free(particles)
 
-		# Fill in array of particles with particle that fof identified
-		# This is possibly the slowest way to code this, but for now
-		# I just want it to work
-		for i,id in enumerate(fof_ids):
-			particles[i].id = id
 
-			# fill in locations & velocities
-			for j in range(3):
-				particles[i].pos[j] = pos[id][j]
-				particles[i].pos[j+3] = vel[id][j]
 
-
-		# Assign pointer to particles into FOF object 
-		fof_obj.particles = particles
-
-		# Assign number of particles into FOF object
-		fof_obj.num_p = num_particles
-
-		# Make pointer to fof object
-		cdef fof* fof_pointer = & fof_obj
-
-		# Find the sub halos using rockstar by passing a pointer to the fof object
-		find_subs( fof_pointer)
-
-		# Output the halos, rockstar style
-		output_halos(0, 0, 0, NULL) 
-
-		free(particles)
-
-
-


https://bitbucket.org/yt_analysis/yt/commits/7acb9512c76e/
Changeset:   7acb9512c76e
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-23 18:30:19
Summary:     Updating setup.py
Affected #:  1 file

diff -r 7ea355912acb4334a8e25ce85533bf4922db6e08 -r 7acb9512c76ec78ebadf37aea196687b6daaf905 yt/analysis_modules/halo_finding/rockstar/setup.py
--- a/yt/analysis_modules/halo_finding/rockstar/setup.py
+++ b/yt/analysis_modules/halo_finding/rockstar/setup.py
@@ -24,5 +24,12 @@
                          include_dirs=[rd,
                                        os.path.join(rd, "io"),
                                        os.path.join(rd, "util")])
+    config.add_extension("rockstar_groupies",
+                         "yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx",
+                         library_dirs=[rd],
+                         libraries=["rockstar"],
+                         include_dirs=[rd,
+                                       os.path.join(rd, "io"),
+                                       os.path.join(rd, "util")])
     return config
 


https://bitbucket.org/yt_analysis/yt/commits/bf628d9eec62/
Changeset:   bf628d9eec62
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-04-08 19:23:21
Summary:     Merged in MatthewTurk/yt/yt-3.0 (pull request #740)

A few updates to Rockstar's groupies interface
Affected #:  2 files

diff -r 689fca64a1840a993c017e2578eb3c5412cd4c38 -r bf628d9eec62eb47e086acc690d045f89b31ce4e yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx
@@ -11,234 +11,232 @@
 # Importing relevant rockstar data types particle, fof halo, halo
 
 cdef import from "particle.h":
-	struct particle:
-		np.int64_t id
-		float pos[6]
+    struct particle:
+        np.int64_t id
+        float pos[6]
 
 cdef import from "fof.h":
-	struct fof:
-		np.int64_t num_p
-		particle *particles
+    struct fof:
+        np.int64_t num_p
+        particle *particles
 
 cdef import from "halo.h":
-	struct halo:
-		np.int64_t id
-		float pos[6], corevel[3], bulkvel[3]
-		float m, r, child_r, vmax_r, mgrav,	vmax, rvmax, rs, klypin_rs, vrms
-		float J[3], energy, spin, alt_m[4], Xoff, Voff, b_to_a, c_to_a, A[3]
-		float bullock_spin, kin_to_pot
-		np.int64_t num_p, num_child_particles, p_start, desc, flags, n_core
-		float min_pos_err, min_vel_err, min_bulkvel_err
+    struct halo:
+        np.int64_t id
+        float pos[6], corevel[3], bulkvel[3]
+        float m, r, child_r, vmax_r, mgrav,    vmax, rvmax, rs, klypin_rs, vrms
+        float J[3], energy, spin, alt_m[4], Xoff, Voff, b_to_a, c_to_a, A[3]
+        float bullock_spin, kin_to_pot
+        np.int64_t num_p, num_child_particles, p_start, desc, flags, n_core
+        float min_pos_err, min_vel_err, min_bulkvel_err
 
 # For finding sub halos import finder function and global variable
 # rockstar uses to store the results
 
 cdef import from "groupies.h":
-	void find_subs(fof *f) 
-	halo *halos
-	np.int64_t num_halos
-	void calc_mass_definition()
+    void find_subs(fof *f) nogil
+    halo *halos
+    np.int64_t num_halos
+    void calc_mass_definition() nogil
 
 # For outputing halos, rockstar style
 
 cdef import from "meta_io.h":
-	void output_halos(np.int64_t id_offset, np.int64_t snap, np.int64_t chunk, float *bounds) 
+    void output_halos(np.int64_t id_offset, np.int64_t snap, np.int64_t chunk, float *bounds) nogil
 
 # For setting up the configuration of rockstar
 
 cdef import from "config.h":
-	void setup_config()
+    void setup_config() nogil
 
 cdef import from "config_vars.h":
-	# Rockstar cleverly puts all of the config variables inside a templated
-	# definition of their vaiables.
-	char *FILE_FORMAT
-	np.float64_t PARTICLE_MASS
+    # Rockstar cleverly puts all of the config variables inside a templated
+    # definition of their vaiables.
+    char *FILE_FORMAT
+    np.float64_t PARTICLE_MASS
 
-	char *MASS_DEFINITION
-	np.int64_t MIN_HALO_OUTPUT_SIZE
-	np.float64_t FORCE_RES
+    char *MASS_DEFINITION
+    np.int64_t MIN_HALO_OUTPUT_SIZE
+    np.float64_t FORCE_RES
 
-	np.float64_t SCALE_NOW
-	np.float64_t h0
-	np.float64_t Ol
-	np.float64_t Om
+    np.float64_t SCALE_NOW
+    np.float64_t h0
+    np.float64_t Ol
+    np.float64_t Om
 
-	np.int64_t GADGET_ID_BYTES
-	np.float64_t GADGET_MASS_CONVERSION
-	np.float64_t GADGET_LENGTH_CONVERSION
-	np.int64_t GADGET_SKIP_NON_HALO_PARTICLES
-	np.int64_t RESCALE_PARTICLE_MASS
+    np.int64_t GADGET_ID_BYTES
+    np.float64_t GADGET_MASS_CONVERSION
+    np.float64_t GADGET_LENGTH_CONVERSION
+    np.int64_t GADGET_SKIP_NON_HALO_PARTICLES
+    np.int64_t RESCALE_PARTICLE_MASS
 
-	np.int64_t PARALLEL_IO
-	char *PARALLEL_IO_SERVER_ADDRESS
-	char *PARALLEL_IO_SERVER_PORT
-	np.int64_t PARALLEL_IO_WRITER_PORT
-	char *PARALLEL_IO_SERVER_INTERFACE
-	char *RUN_ON_SUCCESS
+    np.int64_t PARALLEL_IO
+    char *PARALLEL_IO_SERVER_ADDRESS
+    char *PARALLEL_IO_SERVER_PORT
+    np.int64_t PARALLEL_IO_WRITER_PORT
+    char *PARALLEL_IO_SERVER_INTERFACE
+    char *RUN_ON_SUCCESS
 
-	char *INBASE
-	char *FILENAME
-	np.int64_t STARTING_SNAP
-	np.int64_t NUM_SNAPS
-	np.int64_t NUM_BLOCKS
-	np.int64_t NUM_READERS
-	np.int64_t PRELOAD_PARTICLES
-	char *SNAPSHOT_NAMES
-	char *LIGHTCONE_ALT_SNAPS
-	char *BLOCK_NAMES
+    char *INBASE
+    char *FILENAME
+    np.int64_t STARTING_SNAP
+    np.int64_t NUM_SNAPS
+    np.int64_t NUM_BLOCKS
+    np.int64_t NUM_READERS
+    np.int64_t PRELOAD_PARTICLES
+    char *SNAPSHOT_NAMES
+    char *LIGHTCONE_ALT_SNAPS
+    char *BLOCK_NAMES
 
-	char *OUTBASE
-	np.float64_t OVERLAP_LENGTH
-	np.int64_t NUM_WRITERS
-	np.int64_t FORK_READERS_FROM_WRITERS
-	np.int64_t FORK_PROCESSORS_PER_MACHINE
+    char *OUTBASE
+    np.float64_t OVERLAP_LENGTH
+    np.int64_t NUM_WRITERS
+    np.int64_t FORK_READERS_FROM_WRITERS
+    np.int64_t FORK_PROCESSORS_PER_MACHINE
 
-	char *OUTPUT_FORMAT
-	np.int64_t DELETE_BINARY_OUTPUT_AFTER_FINISHED
-	np.int64_t FULL_PARTICLE_CHUNKS
-	char *BGC2_SNAPNAMES
+    char *OUTPUT_FORMAT
+    np.int64_t DELETE_BINARY_OUTPUT_AFTER_FINISHED
+    np.int64_t FULL_PARTICLE_CHUNKS
+    char *BGC2_SNAPNAMES
 
-	np.int64_t BOUND_PROPS
-	np.int64_t BOUND_OUT_TO_HALO_EDGE
-	np.int64_t DO_MERGER_TREE_ONLY
-	np.int64_t IGNORE_PARTICLE_IDS
-	np.float64_t TRIM_OVERLAP
-	np.float64_t ROUND_AFTER_TRIM
-	np.int64_t LIGHTCONE
-	np.int64_t PERIODIC
+    np.int64_t BOUND_PROPS
+    np.int64_t BOUND_OUT_TO_HALO_EDGE
+    np.int64_t DO_MERGER_TREE_ONLY
+    np.int64_t IGNORE_PARTICLE_IDS
+    np.float64_t TRIM_OVERLAP
+    np.float64_t ROUND_AFTER_TRIM
+    np.int64_t LIGHTCONE
+    np.int64_t PERIODIC
 
-	np.float64_t LIGHTCONE_ORIGIN[3]
-	np.float64_t LIGHTCONE_ALT_ORIGIN[3]
+    np.float64_t LIGHTCONE_ORIGIN[3]
+    np.float64_t LIGHTCONE_ALT_ORIGIN[3]
 
-	np.float64_t LIMIT_CENTER[3]
-	np.float64_t LIMIT_RADIUS
+    np.float64_t LIMIT_CENTER[3]
+    np.float64_t LIMIT_RADIUS
 
-	np.int64_t SWAP_ENDIANNESS
-	np.int64_t GADGET_VARIANT
+    np.int64_t SWAP_ENDIANNESS
+    np.int64_t GADGET_VARIANT
 
-	np.float64_t FOF_FRACTION
-	np.float64_t FOF_LINKING_LENGTH
-	np.float64_t INCLUDE_HOST_POTENTIAL_RATIO
-	np.float64_t DOUBLE_COUNT_SUBHALO_MASS_RATIO
-	np.int64_t TEMPORAL_HALO_FINDING
-	np.int64_t MIN_HALO_PARTICLES
-	np.float64_t UNBOUND_THRESHOLD
-	np.int64_t ALT_NFW_METRIC
+    np.float64_t FOF_FRACTION
+    np.float64_t FOF_LINKING_LENGTH
+    np.float64_t INCLUDE_HOST_POTENTIAL_RATIO
+    np.float64_t DOUBLE_COUNT_SUBHALO_MASS_RATIO
+    np.int64_t TEMPORAL_HALO_FINDING
+    np.int64_t MIN_HALO_PARTICLES
+    np.float64_t UNBOUND_THRESHOLD
+    np.int64_t ALT_NFW_METRIC
 
-	np.int64_t TOTAL_PARTICLES
-	np.float64_t BOX_SIZE
-	np.int64_t OUTPUT_HMAD
-	np.int64_t OUTPUT_PARTICLES
-	np.int64_t OUTPUT_LEVELS
-	np.float64_t DUMP_PARTICLES[3]
+    np.int64_t TOTAL_PARTICLES
+    np.float64_t BOX_SIZE
+    np.int64_t OUTPUT_HMAD
+    np.int64_t OUTPUT_PARTICLES
+    np.int64_t OUTPUT_LEVELS
+    np.float64_t DUMP_PARTICLES[3]
 
-	np.float64_t AVG_PARTICLE_SPACING
-	np.int64_t SINGLE_SNAP
+    np.float64_t AVG_PARTICLE_SPACING
+    np.int64_t SINGLE_SNAP
 
 
 
 cdef class RockstarGroupiesInterface:
-	
-	cdef public object pf
-	cdef public object fof
+    
+    cdef public object pf
+    cdef public object fof
 
-	# For future use/consistency
-	def __cinit__(self,pf):
-		self.pf = pf
+    # For future use/consistency
+    def __cinit__(self,pf):
+        self.pf = pf
 
-	def setup_rockstar(self,
-						particle_mass,
-						int periodic = 1, force_res=None,
-						int min_halo_size = 25, outbase = "None",
-						callbacks = None):
-		global FILENAME, FILE_FORMAT, NUM_SNAPS, STARTING_SNAP, h0, Ol, Om
-		global BOX_SIZE, PERIODIC, PARTICLE_MASS, NUM_BLOCKS, NUM_READERS
-		global FORK_READERS_FROM_WRITERS, PARALLEL_IO_WRITER_PORT, NUM_WRITERS
-		global rh, SCALE_NOW, OUTBASE, MIN_HALO_OUTPUT_SIZE
-		global OVERLAP_LENGTH, TOTAL_PARTICLES, FORCE_RES
-		
+    def setup_rockstar(self,
+                        particle_mass,
+                        int periodic = 1, force_res=None,
+                        int min_halo_size = 25, outbase = "None",
+                        callbacks = None):
+        global FILENAME, FILE_FORMAT, NUM_SNAPS, STARTING_SNAP, h0, Ol, Om
+        global BOX_SIZE, PERIODIC, PARTICLE_MASS, NUM_BLOCKS, NUM_READERS
+        global FORK_READERS_FROM_WRITERS, PARALLEL_IO_WRITER_PORT, NUM_WRITERS
+        global rh, SCALE_NOW, OUTBASE, MIN_HALO_OUTPUT_SIZE
+        global OVERLAP_LENGTH, TOTAL_PARTICLES, FORCE_RES
+        
 
-		if force_res is not None:
-			FORCE_RES=np.float64(force_res)
+        if force_res is not None:
+            FORCE_RES=np.float64(force_res)
 
-		OVERLAP_LENGTH = 0.0
-		
-		FILENAME = "inline.<block>"
-		FILE_FORMAT = "GENERIC"
-		OUTPUT_FORMAT = "ASCII"
-		MIN_HALO_OUTPUT_SIZE=min_halo_size
-		
-		pf = self.pf
+        OVERLAP_LENGTH = 0.0
+        
+        FILENAME = "inline.<block>"
+        FILE_FORMAT = "GENERIC"
+        OUTPUT_FORMAT = "ASCII"
+        MIN_HALO_OUTPUT_SIZE=min_halo_size
+        
+        pf = self.pf
 
-		h0 = pf.hubble_constant
-		Ol = pf.omega_lambda
-		Om = pf.omega_matter
-		
-		SCALE_NOW = 1.0/(pf.current_redshift+1.0)
-		
-		if not outbase =='None'.decode('UTF-8'):
-			#output directory. since we can't change the output filenames
-			#workaround is to make a new directory
-			OUTBASE = outbase 
+        h0 = pf.hubble_constant
+        Ol = pf.omega_lambda
+        Om = pf.omega_matter
+        
+        SCALE_NOW = 1.0/(pf.current_redshift+1.0)
+        
+        if not outbase =='None'.decode('UTF-8'):
+            #output directory. since we can't change the output filenames
+            #workaround is to make a new directory
+            OUTBASE = outbase 
 
 
-		PARTICLE_MASS = particle_mass.in_units('Msun/h')
-		PERIODIC = periodic
-		BOX_SIZE = pf.domain_width.in_units('Mpccm/h')[0]
+        PARTICLE_MASS = particle_mass.in_units('Msun/h')
+        PERIODIC = periodic
+        BOX_SIZE = pf.domain_width.in_units('Mpccm/h')[0]
 
-		# Set up the configuration options
-		setup_config()
+        # Set up the configuration options
+        setup_config()
 
-		# Needs to be called so rockstar can use the particle mass parameter
-		# to calculate virial quantities properly
-		calc_mass_definition()
+        # Needs to be called so rockstar can use the particle mass parameter
+        # to calculate virial quantities properly
+        calc_mass_definition()
 
+    def output_halos(self):
+        output_halos(0, 0, 0, NULL) 
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
+    def make_rockstar_fof(self, np.ndarray[np.int64_t, ndim=1] pid,
+                                np.ndarray[np.float64_t, ndim=2] pos,
+                                np.ndarray[np.float64_t, ndim=2] vel,
+                                np.ndarray[np.int64_t, ndim=1] fof_tags,
+                                np.int64_t nfof,
+                                np.int64_t npart_max):
 
-	def make_rockstar_fof(self,fof_ids, pos, vel):
+        # Define fof object
 
-		# Turn positions and velocities into units we want
-		pos = pos.in_units('Mpccm/h')
-		vel = vel.in_units('km/s')
+        # Find number of particles
+        cdef np.int64_t i, j
+        cdef np.int64_t num_particles = pid.shape[0]
 
-		# Define fof object
-		cdef fof fof_obj
+        # Allocate space for correct number of particles
+        cdef particle* particles = <particle*> malloc(npart_max * sizeof(particle))
+        cdef fof fof_obj
+        fof_obj.particles = particles
 
-		# Find number of particles
-		cdef np.int64_t num_particles = len(fof_ids)
+        cdef np.int64_t last_fof_tag = 1
+        cdef np.int64_t k = 0
+        for i in range(num_particles):
+            if fof_tags[i] == 0:
+                continue
+            if fof_tags[i] != last_fof_tag:
+                last_fof_tag = fof_tags[i]
+                if k > 16:
+                    print "Finding subs", k, i
+                    fof_obj.num_p = k
+                    find_subs(&fof_obj)
+                k = 0
+            particles[k].id = pid[i]
 
-		# Allocate space for correct number of particles
-		cdef particle* particles = <particle*> malloc(num_particles * sizeof(particle))
+            # fill in locations & velocities
+            for j in range(3):
+                particles[k].pos[j] = pos[i,j]
+                particles[k].pos[j+3] = vel[i,j]
+            k += 1
+        free(particles)
 
-		# Fill in array of particles with particle that fof identified
-		# This is possibly the slowest way to code this, but for now
-		# I just want it to work
-		for i,id in enumerate(fof_ids):
-			particles[i].id = id
 
-			# fill in locations & velocities
-			for j in range(3):
-				particles[i].pos[j] = pos[id][j]
-				particles[i].pos[j+3] = vel[id][j]
 
-
-		# Assign pointer to particles into FOF object 
-		fof_obj.particles = particles
-
-		# Assign number of particles into FOF object
-		fof_obj.num_p = num_particles
-
-		# Make pointer to fof object
-		cdef fof* fof_pointer = & fof_obj
-
-		# Find the sub halos using rockstar by passing a pointer to the fof object
-		find_subs( fof_pointer)
-
-		# Output the halos, rockstar style
-		output_halos(0, 0, 0, NULL) 
-
-		free(particles)
-
-
-

diff -r 689fca64a1840a993c017e2578eb3c5412cd4c38 -r bf628d9eec62eb47e086acc690d045f89b31ce4e yt/analysis_modules/halo_finding/rockstar/setup.py
--- a/yt/analysis_modules/halo_finding/rockstar/setup.py
+++ b/yt/analysis_modules/halo_finding/rockstar/setup.py
@@ -24,5 +24,12 @@
                          include_dirs=[rd,
                                        os.path.join(rd, "io"),
                                        os.path.join(rd, "util")])
+    config.add_extension("rockstar_groupies",
+                         "yt/analysis_modules/halo_finding/rockstar/rockstar_groupies.pyx",
+                         library_dirs=[rd],
+                         libraries=["rockstar"],
+                         include_dirs=[rd,
+                                       os.path.join(rd, "io"),
+                                       os.path.join(rd, "util")])
     return config

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list