How to use the pynbody.analysis.profile.Profile.profile_property function in pynbody

To help you get started, we’ve selected a few pynbody examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def magnitudes(self, band='v'):
    """
    Calculate magnitudes in each bin
    """
    from . import luminosity

    magnitudes = np.zeros(self.nbins)
    for i in range(self.nbins):
        magnitudes[i] = luminosity.halo_mag(
            self.sim[self.binind[i]], band=band)
    magnitudes = array.SimArray(magnitudes, units.Unit('1'))
    magnitudes.sim = self.sim
    return magnitudes
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def pot(p) :
    """Calculates the potential in the midplane - can be expensive"""
    #from . import gravity
    import pynbody.gravity.calc as gravity

    if pynbody.config['verbose'] : 
        print 'Profile: pot() -- warning, disk must be in the x-y plane'

    grav_sim = p.sim
    # Go up to the halo level
    while hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
        grav_sim = grav_sim.base
        
    if pynbody.config['tracktime']:
        import time
        start = time.clock()
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def mass_enc(self):
    """
    Generate the enclosed mass profile
    """
    if pynbody.config['verbose'] : print 'Profile: mass_enc()'
    m_enc = array.SimArray(np.zeros(self.nbins), self.sim['mass'].units)
    m_enc.sim = self.sim
    for i in range(self.nbins):
        m_enc[i] = self['mass'].in_units(self.sim['mass'].units)[:i].sum()
    return m_enc
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def density_enc(self):
    """
    Generate the mean enclosed density profile
    """
    return self['mass_enc'] / ((4. * math.pi / 3) * self['rbins'] ** 3)
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def dyntime(self):
    """The dynamical time of the bin, sqrt(R^3/2GM)."""
    dyntime = (self['rbins'] ** 3 / (2 * units.G * self['mass_enc'])) ** (1, 2)
    return dyntime
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def omega(p) :
    """Circular frequency Omega = v_circ/radius (see Binney & Tremaine Sect. 3.2)"""
    if pynbody.config['verbose'] : print 'Profile: omega()'
    prof = p['v_circ']/p['rbins']
    prof.set_units_like('km s**-1 kpc**-1')
    return prof
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def Q(self):
    """Toomre Q parameter"""
    return (self['vr_disp'] * self['kappa'] / (3.36 * self['density'] * units.G)).in_units("")
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def mass(self):
    """
    Calculate mass in each bin
    """
    
    if pynbody.config['verbose'] : print 'Profile: mass()'
    mass = array.SimArray(np.zeros(self.nbins), self.sim['mass'].units)

    with self.sim.immediate_mode : 
        pmass = self.sim['mass'].view(np.ndarray)

    for i in range(self.nbins):
        mass[i] = (pmass[self.binind[i]]).sum()

    mass.sim = self.sim
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def X(self):
    """X parameter defined as kappa^2*R/(2*pi*G*sigma*m) 
    See Binney & Tremaine 2008, eq. 6.77"""

    lambda_crit = 4. * np.pi ** 2 * units.G * \
        self['density'] / (self['kappa'] ** 2)
    kcrit = 2. * np.pi / lambda_crit
    return (kcrit * self['rbins'] / 2).in_units("")
github pynbody / pynbody / pynbody / analysis / profile.py View on Github external
@Profile.profile_property
def kappa(p) :
    """Radial frequency kappa = sqrt(R dOmega^2/dR + 4 Omega^2) (see Binney & Tremaine Sect. 3.2)"""
    if pynbody.config['verbose'] : print 'Profile: kappa()'
    dOmegadR = np.gradient(p['omega']**2, p['dr'][0])
    dOmegadR.set_units_like('km**2 s**-2 kpc**-3')
    return np.sqrt(p['rbins']*dOmegadR + 4*p['omega']**2)