pynbody.analysis.profile.Profile#
- class pynbody.analysis.profile.Profile(sim, load_from_file=False, ndim=2, type='lin', calc_x=None, weight_by='mass', **kwargs)[source]#
Bases:
object
A basic profile class for arbitrary profiles. Stores information about bins etc.
Made to work with the pynbody SimSnap instances. The constructor only generates the bins and figures out which particles belong in which bin. Profiles are generated lazy-loaded when a given property is requested.
Input:
sim : a simulation snapshot - this can be any subclass of SimSnap
Optional Keywords:
- ndim (default = 2): specifies whether it’s a 2D or 3D profile - in the
2D case, the bins are generated in the xy plane
- type (default = ‘lin’): specifies whether bins should be spaced linearly (‘lin’),
logarithmically (‘log’) or contain equal numbers of particles (‘equaln’)
rmin (default = min(x)): minimum radial value to consider
rmax (default = max(x)): maximum radial value to consider
nbins (default = 100): number of bins
- binsarray like - predefined bin edges in units of binning quantity. If this
keyword is set, the values of the keywords type, nbins, rmin and rmax will be ignored
- calc_x (default = None): function to use to calculate the value
for binning. If None it defaults to the radial distance from origin (in either 2 or 3 dimensions), ut you can specify this function to return any value you want for making profiles along arbitrary axes. Depening on your function, the units of certain profiles (such as density) might not make sense.
- weight_by (default = ‘mass’): name of the array to use for weighting
averages across particles in each bin
Output:
a Profile object. To find out which profiles are available, use keys().
Implemented profile functions:
density : density
mass : mass in each bin
mass_enc : enclosed mass
- fourierprovides fourier coefficients, amplitude and phase for
m=0 to m=6. To access the amplitude profile of m=2 mode, do
p['fourier']['amp'][2,:]
dyntime : dynamical time
g_spherical: GM_enc/r^2
- rotation_curve_spherical: rotation curve from vc = sqrt(GM/R) -
can be very wrong!
j_circ : angular momentum of particles on circular orbits
- v_circcircular velocity, aka rotation curve - calculated from
the midplane gravity, so this can be expensive
E_circ : energy of particles on circular orbits in the midplane
omega : circular orbital frequency
kappa : radial orbital frequency
beta : 3-D velocity anisotropy parameter
magnitudes : magnitudes in each bin - default band = ‘v’
sb : surface brightness - default band = ‘v’
Additional functions should use the profile_property to yield the desired profile.
Lazy-loading arrays:
The Profile class will automatically compute a mass-weighted profile for any lazy-loadable array of its parent SimSnap object.
Dispersions:
To obtain a dispersion profile, attach a
_disp
after the desired quantity name.RMS:
The root-mean-square of a quantity can be obtained by using a
_rms
suffixDerivatives:
To compute a derivative of a profile, prepend a
d_
to the profile string, as inp['d_temp']
to get a temperature gradient.Saving and loading previously generated profiles:
Use the
write()
function to write the current profiles with all the necessary information to a file. Initialize a profile with the load_from_file=True keyword to automatically load a previously saved profile. The filename is chosen automatically and corresponds to a hash generated from the positions of the particles used in the profile. This is to ensure that you are always looking at the same set of particles, centered in the same way. It also means you must use the same centering method if you want to reuse a saved profile.Methods
create_particle_array
(profile_name[, ...])Create a particle array with the results of the profile calculation.
Returns a list of possible profiles
families
()Returns the family of particles used
keys
()Returns a listing of available profile types
write
()Writes all the vital information of the profile to a file.
profile_property
- __init__(sim, load_from_file=False, ndim=2, type='lin', calc_x=None, weight_by='mass', **kwargs)[source]#
- create_particle_array(profile_name, particle_name=None, out_sim=None)[source]#
Create a particle array with the results of the profile calculation.
After calling this function, sim[particle_name][i] == profile[profile_name][bin_in_which_particle_i_sits]
If particle_name is not specified, it defaults to the same as profile_name.
- write()[source]#
Writes all the vital information of the profile to a file.
To recover the profile, initialize a profile with the load_from_file=True keyword to automatically load a previously saved profile. The filename is chosen automatically and corresponds to a hash generated from the positions of the particles used in the profile. This is to ensure that you are always looking at the same set of particles, centered in the same way. It also means you must use the same centering method if you want to reuse a saved profile.