pynbody.analysis.profile.InclinedProfile#
- class pynbody.analysis.profile.InclinedProfile(sim, angle, load_from_file=False, ndim=2, type='lin', **kwargs)[source]#
Bases:
ProfileA profile object to be used with a snapshot inclined by some known angle to the xy plane.
In addition to the SimSnap object, it also requires the angle to initialize.
Example:
>>> s = pynbody.load('sim') >>> pynbody.analysis.angmom.faceon(s) >>> s.rotate_x(60) >>> p = pynbody.profile.InclinedProfile(s, 60)
Methods
Returns a list of possible profiles
families()Returns the family of particles used
keys()Returns a listing of available profile types
profile_property(fn)Function decorator to define a new profile property.
write()Writes all the vital information of the profile to a file.
- __init__(sim, angle, load_from_file=False, ndim=2, type='lin', **kwargs)[source]#
Initialise a profile, determining the binning quantity and bin size.
The constructor generates the bins without actually calculating any profiles. The profiles are calculated lazily when requested.
- Parameters:
sim (pynbody.snapshot.SimSnap) – The simulation snapshot to generate a profile for
ndim (int, optional:) – Specifies whether it’s a 2D or 3D profile - in the 2D case, the bins are generated in the xy plane
type (str, optional:) – Specifies whether bins should be spaced linearly (‘lin’, default), logarithmically (‘log’) or contain equal numbers of particles (‘equaln’)
rmin (float, optional:) – Minimum value to consider (left-hand-edge of lowest bin). Default is the minimum value of the binning quantity.
rmax (float, optional:) – Maximum value to consider (right-hand-edge of highest bin). Default is the maximum value of the binning quantity.
nbins (int, optional:) – Number of bins to use. Default is 100.
bins (array-like, optional:) – Predefined bin edges in units of the binning quantity. If this keyword is set, the values of the keywords type, nbins, rmin and rmax will be ignored.
calc_x (function, optional:) – 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), but you can specify this function to return any value you want for making profiles along arbitrary axes. Depending on your function, the units of certain profiles (such as density) might not make sense.
weight_by (str, optional:) – Name of the array to use for weighting averages across particles in each bin. Default is ‘mass’.
- derivable_keys()#
Returns a list of possible profiles
- families()#
Returns the family of particles used
- keys()#
Returns a listing of available profile types
- static profile_property(fn)#
Function decorator to define a new profile property.
For example,
@Profile.profile_property def x_squared(pro): return pro['x']**2
would define a new profile property ‘x_squared’ which is the square of the ‘x’ profile. This can then be accessed as
pro['x_squared']for any profile objectpro.
- write()#
Writes all the vital information of the profile to a file.
To recover the profile, initialize a profile with the
load_from_file=Truekeyword 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.