예제 #1
0
def test(ngrid=32):
    from numpy import *

    drt1 = "/store/stellcomp/group/pcreasey/runs/2Mpc_LG_3spheres/run_03_pmgrid_lowsoft/outputs"
    drt1 = "/store/stellcomp/cecilia/sims/LG/new_7Mpc_2048/outputs"
    snapnum = 0
    snap = load_snapshot(directory=drt1,
                         snapnum=snapnum,
                         label_table=cecilia_labels)
    modes, boxsize = snap_to_modes(snap, ngrid)

    print 'Making power spectrum bins'
    kmin, kmax, kbins, kvol = powerspec_bins(ngrid, boxsize)

    wts = square(modes.ravel().real) + square(modes.ravel().imag)

    print 'Summing power spectrum'
    v1 = bincount(kbins, weights=wts)
    powerspec = v1 / kvol

    # work out error on power spectrum
    v2 = bincount(kbins, weights=square(wts))
    v0 = bincount(kbins)
    p_err = sqrt((v2 * v0 - v1 * v1) / v0) / kvol

    print '#k_bin_min k_bin_max k_bin_vol Power power_error'
    for l, h, vol, p, er in zip(kmin, kmax, kvol, powerspec, p_err):
        print l, h, vol, p, er
예제 #2
0
def animate(i):

    snap = load_snapshot(file.format(i), label_table=cecilia_labels)
    gas_pos = snap['POS '][0]
    stars_pos = snap['POS '][4]

    add_to_plot(gas, gas_pos)
    add_to_plot(stars, stars_pos)

    print(i)

    return points,
예제 #3
0
def animate(i):

    snap = load_snapshot(file.format(i), label_table=cecilia_labels)
    gas_pos = snap['POS '][0]
    #stars_pos = snap['POS '][4]

    x, y, z = np.split(gas_pos, 3, axis=1)

    points[0].set_offsets(gas_pos[:, :2])
    #points[1].set_offsets([x,z])
    #points[2].set_offsets([y,z])

    return points,
예제 #4
0
def animate(i):

    snap = load_snapshot(file.format(i), label_table=cecilia_labels)
    gas_pos = snap['POS '][0]
    #stars_pos = snap['POS '][4]

    x, y, z = np.split(gas_pos, 3, axis=1)

    points.set_data(x, y)

    print(i)

    return points,
예제 #5
0
def dump(name):
    print '\nReading', name, '\n'
    snap = load_snapshot(name)
    print snap
    print '\n'
    header = snap.header

    for hname in header_names[:-1]:
        if hname in ['buffer', 'num_particles']:
            # these are stripped of the object
            continue
        dta = getattr(snap.header, hname)
        if len(dta) == 1:
            print '%25s' % (hname, ), dta[0]
        else:
            print '%25s' % (hname, ), dta
예제 #6
0
파일: ghdr.py 프로젝트: Lowingbn/iccpy
def dump(name):
    print '\nReading', name, '\n'
    snap = load_snapshot(name)
    print snap
    print '\n'
    header = snap.header
    
    for hname in header_names[:-1]:
        if hname in ['buffer', 'num_particles']:
            # these are stripped of the object
            continue
        dta = getattr(snap.header, hname)
        if len(dta)==1:
            print '%25s'%(hname,), dta[0]
        else:
            print '%25s'%(hname,), dta
예제 #7
0
from iccpy.gadget import load_snapshot
from iccpy.gadget.labels import cecilia_labels
from iccpy.gadget.subfind import SubfindCatalogue
from iccpy.utils import match

# paths to the parent directory of the folders containing snapshots and subfind
# outputs must be supplied
subfind_path = '../../2Mpc_LG'
snap_num = 135
snap_dir = '../../2Mpc_LG'

# we create the Subfind object for that particular snapshot
cat = SubfindCatalogue(subfind_path, snap_num)
# Directory and snapnum are passed instead of filename, to open snapshot in multiple parts
snap = load_snapshot(directory=snap_dir.format(snap_num),
                     snapnum=snap_num,
                     label_table=cecilia_labels)

gas_ids = snap['ID  '][0]
stars_ids = snap['ID  '][4]


def plotxy_subhalo(subhalo, num_species):
    """
	Given a subhalo object, and species number (0 for gas, 4 for stars, etc.),
	plots the XY projection of the particles onto the axis object.
	"""

    # we first find the indices of the IDs array in which the subhalo IDs are
    # located. We then filter out the -1s in the indexes array, since these are
    # the subhalo IDs unmatched to the snap IDs for the particular species.
예제 #8
0
Program to plot 
"""

import numpy as np
import matplotlib.pyplot as plt

from iccpy.gadget import load_snapshot
from iccpy.gadget.labels import cecilia_labels

plt.ion()

number_of_snapshots = 200  # actually includes snap_000

file = '/home/martin/Documents/Tesis/outputs/snap_{:03d}'

snap = load_snapshot(file.format(200), label_table=cecilia_labels)

gas_pos = snap['POS '][0]

gas_x = gas_pos[:, 0]
gas_y = gas_pos[:, 1]
gas_z = gas_pos[:, 2]

gas_r = np.sqrt(gas_x**2 + gas_y**2 + gas_z**2)

gas_U = snap['U   '][0]

gas_rho = snap['RHO '][0]

plt.figure()
ax = plt.gca()
예제 #9
0
import numpy as np
import pylab as pl

from iccpy.gadget import load_snapshot

from iccpy.gadget.labels import cecilia_labels

#f = load_snapshot('/Users/cecilia/data/Aquarius/halo_C09/snap_C09_200_converted_128', label_table=cecilia_labels)

#f = load_snapshot('/home/cscannapieco/data/isolated_random/single_explosion/outputs/snap_200', label_table=cecilia_labels)
f = load_snapshot('../outputs/snap_200', label_table=cecilia_labels)
list(f)

f.header

f.header.mass

gas_pos = f['POS '][0]

pl.plot(gas_pos[:, 0], gas_pos[:, 1], ',')
pl.plot(gas_pos[:, 0], gas_pos[:, 1],
        '.r')  # the r is for red, the . is for dot
#pl.xlim(45,55)
#pl.ylim(45,55)
pl.xlabel('x')
pl.ylabel('y')
pl.title('first plot, latex also e.g. $\sim$ 2')

pl.show()

gas_dens = f['RHO '][0]