In [16]:
%matplotlib inline
%pylab inline
import wx
import tables
import numpy as np
import pynbody
import os


Populating the interactive namespace from numpy and matplotlib

In [17]:
#os.system("ls")
# Load Data, Show Some Stuff
data = pynbody.load('./output_00008')

In [43]:
#Propiedades
#print data;
#print len(data)
#print len(data.dark)
#print data.properties
#print data.keys()
#print data.loadable_keys()
#print data.all_keys()
#print data.dark["mass"]
#print data.dark["pos"]
#print data.dark["vel"]

In [20]:
print 'ngas = %e, ndark = %e, nstar = %e\n'%(len(data.gas),len(data.dark),len(data.star));
x = data.dark["x"]
y = data.dark["y"]
z = data.dark["z"]
vx = data.dark["vx"]
vy = data.dark["vy"]
vz = data.dark["vz"]
rho = data.dark["rho"]
mass = data.dark["mass"]
#mass=pynbody.snapshot.ramses.mass(data)


ngas = 0.000000e+00, ndark = 2.097152e+06, nstar = 0.000000e+00

Plot RAMSES bulk file binary


In [22]:
data.physical_units()
#s['pos'].in_units('Mpc')
im = pynbody.plot.image(data.dark, width='100 Mpc', units="Msol Mpc^-2", cmap=mpl.cm.Oranges)
plt.xlim(0,50000)
plt.ylim(0,50000)
#plt.savefig('Ramses1Snap8.png')
#plt.show()


Out[22]:
(0, 50000)

Useful for Data Analysis


In [23]:
pynbody.analysis.cosmology.linear_growth_factor(data, z=3)
pynbody.analysis.cosmology.age(data, z=None, unit='Gyr')
pynbody.analysis.cosmology.rho_crit(data, z=None, unit=None)
pynbody.analysis.gravity.potential(data, pos_vec, eps=None, unit=None)


Out[23]:
208.80003369518317

Plot RAMSES slice


In [37]:
#plot(x,y,'.')#plt.scatter(x,y)
z_aux = np.where(z<500.0)
scatter(x[z_aux], y[z_aux],s=.05)
xlim(0.0,100000.)
ylim(0.0,100000.)
xlabel("x (kpc)")
ylabel("y (kpc)")


Out[37]:
<matplotlib.text.Text at 0x7f005f6dc4d0>

In [ ]: