Example #1
0
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()
        pot = gravity.midplane_potential(grav_sim, p['rbins']).in_units(p.sim['vel'].units**2)
        end = time.clock()
        if pynbody.config['verbose']: print 'Potential calculated in %5.3g s'%(end-start)
        return pot
    else:
        return gravity.midplane_potential(grav_sim, p['rbins']).in_units(p.sim['vel'].units**2)
Example #2
0
def pot(p):
    """Calculates the potential in the midplane - can be expensive"""
    #from . import gravity
    import pynbody.gravity.calc as gravity

    logger.warn(
        "Profile pot -- this routine assumes the disk is 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

    start = time.clock()
    pot = gravity.midplane_potential(
        grav_sim, p['rbins']).in_units(p.sim['vel'].units ** 2)
    end = time.clock()
    logger.info("Potential calculated in %5.3g s" % (end - start))
    return pot
Example #3
0
def pot(p):
    """Calculates the potential in the midplane - can be expensive"""
    #from . import gravity
    import pynbody.gravity.calc as gravity

    logger.warn(
        "Profile pot -- this routine assumes the disk is in the x-y plane")

    grav_sim = p.sim
    # Go up to the halo level
    while hasattr(grav_sim, 'base') and "halo_id" in grav_sim.base.properties:
        grav_sim = grav_sim.base

    start = backcompat.clock()
    pot = gravity.midplane_potential(grav_sim, p['rbins']).in_units(
        p.sim['vel'].units**2)
    end = backcompat.clock()
    logger.info("Potential calculated in %5.3g s" % (end - start))
    return pot