Exemplo n.º 1
0
def dump(particles, output_filenames, op=None):
    global a, a_dump, drift_fac, i_dump, kick_fac
    # Do nothing if not at dump time
    if a != a_dump:
        return False
    # Synchronize positions and momenta before dumping
    if op == 'drift':
        particles.drift(drift_fac[0])
    elif op == 'kick':
        particles.kick(kick_fac[1])
    # Dump terminal render
    if a in terminal_render_times:
        terminal_render(particles)
    # Dump snapshot
    if a in snapshot_times:
        save(particles, a, output_filenames['snapshot'].format(a))
    # Dump powerspectrum
    if a in powerspec_times:
        powerspec(particles, output_filenames['powerspec'].format(a))
    # Dump render
    if a in render_times:
        render(particles, a, output_filenames['render'].format(a),
               cleanup=(a == render_times[len(render_times) - 1]))
    # Increment dump time
    i_dump += 1
    if i_dump < len(a_dumps):
        a_dump = a_dumps[i_dump]
    # Reset the second kick factor,
    # making the next operation a half kick.
    kick_fac[1] = 0
    return True
Exemplo n.º 2
0
def powerspec():
    # Extract the snapshot filename
    snapshot_filename = special_params['snapshot_filename']
    # Read in the snapshot
    snapshot = load_into_standard(snapshot_filename, compare_params=False)
    # Output file
    output_dir, basename = os.path.split(snapshot_filename)
    output_filename = '{}/{}{}{}'.format(output_dir,
                                         output_bases['powerspec'],
                                         '_' if output_bases['powerspec'] else '',
                                         basename)
    # Produce powerspectrum of the snapshot
    analysis.powerspec(snapshot.particles,
                       output_filename)