pynbody.analysis.profile.QuantileProfile#

class pynbody.analysis.profile.QuantileProfile(sim, q=(0.16, 0.5, 0.84), weights=None, load_from_file=False, ndim=3, type='lin', **kwargs)[source]#

Bases: Profile

A profile object that returns requested quantiles instead of means in each bin.

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, q=(0.16, 0.5, 0.84), weights=None, load_from_file=False, ndim=3, type='lin', **kwargs)[source]#

Creates a profile object that returns the requested quantiles for a given array in a given bin.

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

  • q (list of floats, optional) – The quantiles that will be returned. Default is median with 1-sigma on either side. q can be of arbitrary length allowing the user to select any quantiles they desire.

  • weights (pynbody.array.SimArray, optional) – What should be used to weight the quantile. A likely possibility is to use particle mass: sim['mass']. The default is to weight by particle number, weights=None.

  • **kwargs – Additional keyword arguments are passed onto the underlying Profile constructor.

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.