diskpy.clumps.clumpfinding package¶
Module contents¶
Created on Sat Jul 18 15:33:32 2015
@author: ibackus
-
diskpy.clumps.clumpfinding.
clump_tracker
(fprefix, param=None, directory=None, nsmooth=32, verbose=True)[source]¶ Finds and tracks clumps over a simulation with multiple time steps and calculates various physical properties of the clumps.
Runs all the steps necessary to find/track clumps, these are:
get_fnames pFind_clumps pClump_properties pLink2 multilink build_clumps
If the iord property is not found, the linking will only work if the number of particles remains constant through the simulation
ARGUMENTS
- fprefix : str
- Prefix of the simulation outputs
- param : str (recommended)
- Filename of a .param file for the simulation
- directory : str (optional)
- Directory to search through. Default is current working directory
- nsmooth : int (optional)
- Number of nearest neighbors used for particle smoothing in the simulation. This is used in the definition of a density threshold for clump finding.
- verbose : bool (optional)
- Verbosity flag. Default is True
RETURNS
- clump_list : list
- A list containing dictionaries for all clumps foujohn obryan fiddlend in the simulation See clump_properties for a list of the properties calculated for clumps
-
diskpy.clumps.clumpfinding.
blank_clump
(clump_pars, nt=1)[source]¶ Generates a blank clump dictionary, using clump_pars
-
diskpy.clumps.clumpfinding.
build_clumps
(multilink_list, clump_pars_list, fnames=None, param=None)[source]¶ Builds a list of clump dictionaries. The clump dictionaries contain various properties as a function of time for the different clumps.
ARGUMENTS
- multilink_list : list
- A list of clump-link arrays (output of multilink)
- clump_pars_list : list
- List of dictionaries containing clump properties for all clumps on a given time step (see pClump_properties)
- fnames : list (recommended)
- A list of the simulation snapshot filenames. If provided, the time steps are included in the clumps
- param : str (recommended)
- Filename of a .param file for the simulation. Only used if fnames is provided
RETURNS
- clump_list : list
- A list of clump dictionaries. Each clump dictionary gives various physical properties for a clump as a function of time. A value of NaN means the clump was not present at that time step.
-
diskpy.clumps.clumpfinding.
multilink
(link_list)[source]¶ Links clumps on multiple time steps.
Given the output of link2 or pLink2 for multiple time-steps, this determines every clump’s ID as a function of time-step.
ARGUMENTS
- link_list : list
- A list of link arrays. link_list[i] contains the links between time step i and i+1. ie: link_list[i] = link2(clump_pars_list[i], clump_pars_list[i+1]) Same as the output from pLink2
RETURNS
- clumpid_list : list
- A list of 2D arrays. Each array gives pairs of (clumpID, time-step)
-
diskpy.clumps.clumpfinding.
pLink2
(clump_pars_list)[source]¶ A parallel (batch) implementation of links2 for linking clumps in consecutive time-steps.
ARGUMENTS
- clump_pars_list : list
- A list of dictionaries containing the properties of clumps. Each element of the list is a dictio:nary for a single time step. (see pClump_properties)
RETURNS
- link_list : list
- A list of link arrays. link_list[i] contains the links between time step i and i+1. ie: link_list[i] = link2(clump_pars_list[i], clump_pars_list[i+1])
-
diskpy.clumps.clumpfinding.
link2
(clump_pars1, clump_pars2, link_thresh=0.2)[source]¶ ‘Links’ the clumps in two consecutive timesteps. i.e., a clump numbered 10 in one time step might be numbered 15 in the next. Requires the particle iord (ie, particle ID)
ARGUMENTS
- clump_pars1 : dict
- Dict containing the properties of the clumps in time-step 1 (see clump_properties)
- clump_pars2 : dict
- Dict containing the properties of the clumps in time-step 2 (see clump_properties)
- link_thresh : int (optional)
- The minimum fraction of particles in clump i at time 1 which must end up in clump j at time 2 to consider the clumps ‘linked’
RETURNS
- clump_pairs : array
- 2D numpy array organized according to (parent index, clump number) where clump number is the number of a clump in time 2 and parent index is the number of it’s “parent” in time-step 1 (ie, that same clump’s ID in time-step 1) A parent index of -1 corresponds to no parent (a new clump)
-
diskpy.clumps.clumpfinding.
clump_im
(f, clump_array, width, qty=’rho’, resolution=1200, clim=None, clump_min=None)[source]¶ Plots an sph image from f with particles not in clumps colored red and particles in clumps colored green. Uses pynbody for a backend.
ARGUMENTS
- f : TipsySnapshot (see pynbody) or str
- The snapshot to plot OR the filename of a snapshot to plot
- clump_array : numpy array
- A array (same length as f) such that 0 entries correspond to particles not in clumps and entries > 0 correspond to particles in clumps
- width : str, simarray
- See pynbody.plot.sph.image. Width of the plot, ie ‘3 au’
- resolution : int
- Resolution in pixels of the plot. The plot will be res by res pixels
- clim : tuple,list,array
- Density limits arranged as [low, high]. Any pixels below low are mapped to 0, any pixels above high are mapped to 1.
- clump_min : float
- Used to set a cutoff for masking the clumps. Not needed
RETURNS
- image : numpy nd-array
- Returns an NxNx3 numpy array of the color image plotted.
-
diskpy.clumps.clumpfinding.
pClump_properties
(flist, clumpnum_list)[source]¶ A parallel (batch) implementation of clump_properties. Calculates the physical properties of clumps in a list of snapshots.
ARGUMENTS
- flist : list
- A list of tipsy snapshots or filenames pointing to snapshots.
- clumpnum_list : list
- A list of arrays (one per snapshot) which define the clump number each particle belongs to (see pFind_clumps)
RETURNS
- properties : list
- A list of dictionaries which contain the clump properties for every simulation (see clump_properties)
-
diskpy.clumps.clumpfinding.
clump_properties
(f, clump_nums)[source]¶ Calculates the physical properties of clumps in a snapshot.
ARGUMENTS
- f : str -OR- tipsy snapshot
- Either a tipsy snapshot or a filename pointing to a snapshot
- clump_nums : array like
- Clump number that each particle belongs to (see clumps.find_clumps). 0 corresponds to not being in a clump.
RETURNS
- properties : dict
A dictionary containing the physical properties of the clumps. Keys are:
‘m’ mass ‘N’ Number of particles ‘pos’ xyz position ‘r’ cylindrical radial position ‘v’ center of mass velocity ‘L’ Angular momentum relative to clump center of mass ‘T’ Average temperature ‘rho’ Average density ‘r_clump’ Clump radius. Sqrt of mass averaged particle distance squared
(from the center of mass). IE: r = sqrt( sum(mr^2)/sum(m))- ‘ids’ particle IDs in the clump (first particle in simulation is
- 0, second is 1, etc…)
‘iord’ Particle iord (a particle’s ID for the whole simulation)
-
diskpy.clumps.clumpfinding.
pFind_clumps
(f_list, n_smooth=32, param=None, arg_string=None, verbose=True)[source]¶ A parallel implementation of find_clumps. Since SKID is not parallelized this can be used to run find_clumps on a set of snapshots from one simulation.
ARGUMENTS
- f_list : list
- A list containing the filenames of snapshots OR the tipsy snapshots
- n_smooth : int (optional)
- Number of nearest neighbors used for particle smoothing in the simulation. This is used in the definition of a density threshold for clump finding.
- param : str (optional)
- filename for a tipsy .param file
- arg_string : str (optional)
- Additional arguments to be passed to SKID. Cannot use -tau, -d, -m, -s, -o
- verbose : bool
- Verbosity flag. Default is True
RETURNS
- clumpnum_list : list
- A list containing the particle clump assignment for every snapshot in f_list. clumps[i][j] gives the clump number for particle j in snapshot i.
-
diskpy.clumps.clumpfinding.
find_clumps
(f, n_smooth=32, param=None, arg_string=None, seed=None, verbose=True)[source]¶ Uses skid (https://github.com/N-BodyShop/skid) to find clumps in a gaseous protoplanetary disk. Also requires tipsy tools (https://github.com/N-BodyShop/tipsy_tools), specifically totipnat
The linking length used is equal to the gravitational softening length of the gas particles.
The density cut-off comes from the criterion that there are n_smooth particles within the Hill sphere of a particle. This is formulated mathematically as:
rho_min = 3*n_smooth*Mstar/R^3where R is the distance from the star. The trick used here is to multiply all particle masses by R^3 before running skid so the density cut-off is:
rho_min = 3*n_smooth*MstarARGUMENTS
- f : TipsySnap, or str
- A tipsy snapshot loaded/created by pynbody -OR- a filename pointing to a snapshot.
- n_smooth : int (optional)
- Number of particles used in SPH calculations. Should be the same as used in the simulation. Default = 32
- param : str (optional)
- filename for a .param file for the simulation
- arg_string : str (optional)
- Additional arguments to be passed to skid. Cannot use -tau, -d, -m, -s, -o
- seed : int
- An integer used to seed the random filename generation for temporary files. Necessary for multiprocessing and should be unique for each thread.
- verbose : bool
- Verbosity flag. Default is True
RETURNS
- clumps : array, int-like
- Array containing the group number each particle belongs to, with star particles coming after gas particles. A zero means the particle belongs to no groups