Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110374260
gjeans
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Apr 26, 01:08
Size
4 KB
Mime Type
text/x-python
Expires
Mon, Apr 28, 01:08 (2 d)
Engine
blob
Format
Raw Data
Handle
25813545
Attached To
rGTOOLS Gtools
gjeans
View Options
#!/usr/bin/env python
'''
Run jeans on an Nbody model
Yves Revaz
Tue Aug 16 14:51:59 CEST 2005
'''
jeans = "/home/revaz/pgm/F77/jeans2.1/jeans"
import sys
from numarray import *
from Nbody import *
try:
from optparse import OptionParser
except ImportError:
from optik import OptionParser
def parse_options():
usage = "usage: %prog [options] file"
parser = OptionParser(usage=usage)
parser.add_option("-t",
action="store",
dest="ftype",
type="string",
default = "gadget",
help="type of the file",
metavar=" TYPE")
parser.add_option("--hafaire",
action="store_true",
dest="hafaire",
default=0,
help="compute corrections")
parser.add_option("--Rmax",
action="store",
dest="Rmax",
default=100,
help="Rmax")
parser.add_option("--Hz",
action="store",
dest="Hz",
default=0.05,
help="Hz")
parser.add_option("--Dt",
action="store",
dest="Dt",
default=0,
help="Dt")
parser.add_option("--ccorrect",
action="store_true",
dest="ccorrect",
default=0,
help="ccorrect")
parser.add_option("--histocenter",
action="store_true",
dest="histocenter",
default=0,
help="histocenter")
parser.add_option("--axisym",
action="store_false",
dest="axisym",
default=1,
help="axisym")
parser.add_option("--symz",
action="store_true",
dest="symz",
default=0,
help="symz")
parser.add_option("--symr",
action="store_true",
dest="symr",
default=0,
help="symr")
parser.add_option("--ic",
action="store_true",
dest="ic",
default=0,
help="ic")
parser.add_option("--betha",
action="store",
dest="betha",
default=1.,
help="betha")
parser.add_option("-n",
action="store",
dest="sname",
type="string",
default = None,
help="simulation name",
metavar=" STRING")
(options, args) = parser.parse_args()
if len(args) == 0:
print "you must specify a filename"
sys.exit(0)
files = args
return files,options
def tf(val):
if val:
return 'T'
else:
return 'F'
#############################
# main
#############################
# get options
files,options = parse_options()
ftype = options.ftype
sname = options.sname
hafaire = tf(options.hafaire)
Rmax = options.Rmax
Hz = options.Hz
Dt = options.Dt
ccorrect= tf(options.ccorrect)
histocenter= options.histocenter
axisym = tf(options.axisym)
symz = tf(options.symz)
symr = tf(options.symr)
ic = tf(options.ic)
betha = options.betha
for file in files:
print "%s"%file
# open file and transorm it into binary format
nb = Nbody(file,ftype=ftype)
if ftype != 'binary':
npart = nb.npart
massarr = nb.massarr
nb = nb.set_ftype('binary')
else:
npart = array([nb.nbody])
massarr = array([1./nb.nbody])
tnow = nb.tnow
file = 'treo.dat'
nb.rename(file)
# histocenter if needed
if histocenter :
nb.histocenter()
nb.write()
# create fort.1 file
f = open('fort.1','w')
f.write('%s %f %f %f\n'%(hafaire,Rmax,Hz,Dt))
f.write('%s %s %s %s %s\n'%(ccorrect,axisym,symz,symr,ic))
# families
nf = 0
for i in range(6):
if npart[i]!=0:
nf = nf+1
f.write('%d\n'%(nf))
for i in range(nf):
f.write('%d %e %f \n'%(npart[i],massarr[i],betha))
f.close()
# lunch jeans
os.system('%s %s'%(jeans,file))
# move files
if sname !=None:
name = '%s_%08.3f'%(sname,tnow)
else:
name = '%08.3f'%(tnow)
os.rename('fort.9','%s.vel'%(name))
for n in arange(nf):
os.rename('fort.%d'%(n+10),'%s_%1d.vel'%(name,n+1))
# remove file
os.remove(file)
os.remove('fort.1')
os.remove('treemass.dat')
Event Timeline
Log In to Comment