Example #1
0
def v_circ(p, grav_sim=None) :
    """Circular velocity, i.e. rotation curve. Calculated by computing the gravity 
    in the midplane - can be expensive"""

    import pynbody.gravity.calc as gravity
    from .. import config

    global config

    grav_sim = grav_sim or p.sim

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

    
    # If this is a cosmological run, go up to the halo level
    #if hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #    while hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #        grav_sim = grav_sim.base
    
    #elif hasattr(grav_sim,'base') : 
    #    grav_sim = grav_sim.base
    
    if config['tracktime']:
        import time
        start = time.time()
        rc = gravity.midplane_rot_curve(grav_sim, p['rbins']).in_units(p.sim['vel'].units)
        end = time.time()
        if config['verbose']: print 'Rotation curve calculated in %5.3g s'%(end-start)
        return rc
    else:
        return gravity.midplane_rot_curve(grav_sim, p['rbins']).in_units(p.sim['vel'].units)
Example #2
0
def v_circ(p, grav_sim=None):
    """Circular velocity, i.e. rotation curve. Calculated by computing the gravity 
    in the midplane - can be expensive"""

    import pynbody.gravity.calc as gravity
    from .. import config

    global config

    grav_sim = grav_sim or p.sim

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

    # If this is a cosmological run, go up to the halo level
    # if hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #    while hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #        grav_sim = grav_sim.base

    # elif hasattr(grav_sim,'base') :
    #    grav_sim = grav_sim.base

    start = time.time()
    rc = gravity.midplane_rot_curve(
        grav_sim, p['rbins']).in_units(p.sim['vel'].units)
    end = time.time()
    logger.info("Rotation curve calculated in %5.3g s" % (end - start))
    return rc
Example #3
0
def v_circ(p, grav_sim=None):
    """Circular velocity, i.e. rotation curve. Calculated by computing the gravity 
    in the midplane - can be expensive"""

    import pynbody.gravity.calc as gravity
    from .. import config

    global config

    grav_sim = grav_sim or p.sim

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

    # If this is a cosmological run, go up to the halo level
    # if hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #    while hasattr(grav_sim,'base') and grav_sim.base.properties.has_key("halo_id") :
    #        grav_sim = grav_sim.base

    # elif hasattr(grav_sim,'base') :
    #    grav_sim = grav_sim.base

    start = time.time()
    rc = gravity.midplane_rot_curve(grav_sim,
                                    p['rbins']).in_units(p.sim['vel'].units)
    end = time.time()
    logger.info("Rotation curve calculated in %5.3g s" % (end - start))
    return rc