Page MenuHomec4science

gsoftening
No OneTemporary

File Metadata

Created
Fri, Nov 8, 17:33

gsoftening

#!/usr/bin/env python
from Nbody import *
import sys
import copy
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 = None,
help="type of the file",
metavar=" TYPE")
parser.add_option("--center",
action="store_true",
dest="center",
default = 0,
help="center model")
parser.add_option("-r",
action="store",
dest="r",
type="float",
default=1,
help="radius")
(options, args) = parser.parse_args()
if len(args) == 0:
print "you must specify a filename"
sys.exit(0)
files = args
return files,options
######################################################################
# M A I N
######################################################################
# get options
files,options = parse_options()
ftype = options.ftype
center = options.center
r = options.r
file = files[0]
nb = Nbody(file,ftype=ftype)
if center:
nb.histocenter(rbox=2*r)
rs = nb.rxyz()
c = (rs<r)
n = sum(c.astype(Int))
print "%i particles in the sphere of radius %8.3f"%(n,r)

Event Timeline