pynbody.analysis.profile.VerticalProfile#

class pynbody.analysis.profile.VerticalProfile(sim, rmin, rmax, zmax, load_from_file=False, ndim=3, type='lin', **kwargs)[source]#

Bases: Profile

A profile class that uses the absolute value of the z coordinate for binning instead of a radial coordinate.

Methods

create_particle_array(profile_name[, ...])

Interpolate the profile back onto the particles

derivable_keys()

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, rmin, rmax, zmax, load_from_file=False, ndim=3, type='lin', **kwargs)[source]#

Creates a profile object that uses the absolute value of the z-coordinate for binning.

Parameters:
  • sim (pynbody.snapshot.simsnap.SimSnap) – The snapshot to make a profile from.

  • rmin (str, float or pynbody.units.Unit) – Minimum radius for particle selection.

  • rmax (str, float or pynbody.units.Unit) – Maximum radius for particle selection.

  • zmax (str, float or pynbody.units.Unit) – Maximum height to consider (the upper edge of the binning range)

  • ndim (int, optional) – If ndim=2, an edge-on projected profile is produced, i.e. density is in units of mass/length^2. If ndim=3 (default) a volume profile is made, i.e. density is in units of mass/length^3.

  • type (str, optional) – The type of binning to use. Can be ‘lin’ (default), ‘log’, or ‘equaln’.

create_particle_array(profile_name, particle_name=None, log_x_interpolation=None, log_y_interpolation=None, target_simulation=None)#

Interpolate the profile back onto the particles

For example, calling create_particle_array('density') will create a new array in the simulation called ‘density’ which is the density of each particle according to the profile.

Parameters:
  • profile_name (str) – The name of the profile to interpolate

  • particle_name (str, optional) – The name of the new array to create. If not specified, it will be the same as the profile_name.

  • log_x_interpolation (bool, optional) – If True, interpolate in log space for the x-axis; if False, don’t. If None, perform log interpolation if all bin centres are positive.

  • log_y_interpolation (bool, optional) – If True, interpolate in log space for the y-axis; if False, don’t. If None, perform log interpolation if all profile values are positive.

  • target_simulation (pynbody.SimSnap, optional) – The simulation to create the new array in. If not specified, the array will be created in the current simulation. Specifying another simulation is helpful e.g. if you want to interpolate the profile onto a different set of particles.

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 object pro.

write()#

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.