In this section, we assume that pNbody in installed in /usr/lib/python2.4/site-packages/pNbody/. First move to the examples directory and start python :
[lunix@lunix ~]$ cd /usr/lib/python2.4/site-packages/pNbody/examples [lunix@lunix examples]$ python Python 2.4.2 (#2, Jul 13 2006, 15:26:48) [GCC 4.0.1 (4.0.1-5mdk for Mandriva Linux release 2006.0)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
>>> from pNbody import *
>>> nb = Nbody('gadget_z00.dat',ftype='gadget')
>>> nb.info() ----------------------------------- particle file : ['gadget_z00.dat'] ftype : 'Nbody_gadget' nbody : 20560 nbody_tot : 20560 npart : array([ 9160, 10280, 0, 0, 1120, 0]) npart_tot : array([ 9160, 10280, 0, 0, 1120, 0]) mtot : 79.717887878417969 byteorder : 'little' pio : 'no' len pos : 20560 pos[0] : array([-1294.48828125, -2217.09765625, -9655.49609375], type=Float32) pos[-1] : array([ -986.0625 , -2183.83203125, 4017.04296875], type=Float32) len vel : 20560 vel[0] : array([ -69.80491638, 60.56475067, -166.32981873], type=Float32) vel[-1] : array([-140.59715271, -66.44669342, -37.01613235], type=Float32) len mass : 20560 mass[0] : 0.0010856521548703313 mass[-1] : 0.0010856521548703313 len num : 20560 num[0] : 21488 num[-1] : 1005192 len rsp : 20560 rsp[0] : 909.027587890625 rsp[-1] : 0.0 nzero : 20560 npart : [ 9160 10280 0 0 1120 0] massarr : [ 0. 0. 0. 0. 0. 0.] atime : 1.0 redshift : 2.22044604925e-16 flag_sfr : 1 flag_feedback : 1 nall : [ 9160 10280 0 0 1120 0] flag_cooling : 1 num_files : 1 boxsize : 100000.0 omega0 : 0.3 omegalambda : 0.7 hubbleparam : 0.7 flag_age : 0 flag_metals : 0 nallhw : [0 0 0 0 0 0] flag_entr_ic : 0 critical_energy_spec: 0.0 len u : 20560 u[0] : 6606.63037109 u[-1] : 0.0 len rho : 20560 rho[0] : 7.05811936674e-11 rho[-1] : 0.0 len rsp : 20560 rsp[0] : 909.027587891 rsp[-1] : 0.0 len erd : 20560 erd[0] : 446292.5625 erd[-1] : 0.0
>>> nb.pos array([[-1294.48828125, -2217.09765625, -9655.49609375], [-4272.2734375 , -1574.39453125, -6895.22265625], [-4192.90234375, -2828.90625 , -7032.86328125], ..., [-1269.9921875 , -1017.7890625 , 300.4453125 ], [-1271.2890625 , -1018.8828125 , 300.6640625 ], [ -986.0625 , -2183.83203125, 4017.04296875]], type=Float32) >>> nb.nbody 20560
>>> nb.cm() array([-1649.92650646, 609.98258649, -1689.04021837]) >>> nb.Ltot() array([-1112071.75 , -755970.625, -1536666.25 ], type=Float32)
>>> nb.display(size=(10000,10000),shape=(256,256),palette='light')
>>> nb.translate([3125,-4690,1720]) >>> nb.display(size=(10000,10000),shape=(256,256),palette='light') >>> nb.display(size=(1000,1000),shape=(256,256),palette='light')
>>> nb.rotate(angle=pi) >>> nb.display(size=(1000,1000),shape=(256,256),palette='light')
>>> nb_gas = nb.select('gas') >>> nb_gas.display(size=(1000,1000),shape=(256,256),palette='light')
>>> nb_gas.display(size=(1000,1000),shape=(256,256),palette='rainbow4',mode='T',filter_name='convol')
>>> nb_sub = nb.selectc((nb.rxyz()<500)) >>> nb_sub.display(size=(1000,1000),shape=(256,256),palette='light')
>>> nb_sub.rename('gadget_z00_sub.dat') >>> nb_sub.write()
>>> log10(max(nb_gas.T())) 12.870792505729391 >>> nb_sub = nb_gas.selectc( (nb_gas.T()>1e11) ) >>> nb_sub.write_num('T11.num')
>>> nb = Nbody('gadget_z40.dat',ftype='gadget') >>> nb.display(size=(10000,10000),shape=(256,256),palette='light') >>> nb_sub = nb.selectp(file='T11.num') >>> nb_sub.display(size=(10000,10000),shape=(256,256),palette='light')
>>> nb = nb.set_ftype('binary') >>> nb.rename('binary.dat') >>> nb.write()
>>> nb1 = Nbody('disk.gad',ftype='gadget') >>> nb2 = Nbody('disk.gad',ftype='gadget') >>> nb1.rotate2(angle=pi/4,axis=[0,1,0]) >>> nb1.translate([-150,0,0]) >>> nb1.vel = nb1.vel + [50,0,0] >>> nb2.rotate2(angle=pi/4,axis=[1,0,0]) >>> nb2.translate([+150,0,50]) >>> nb2.vel = nb2.vel - [50,0,0] >>> nb3 = nb1 + nb2 >>> nb3.rename('merge.gad') >>> nb3.write()
See About this document... for information on suggesting changes.