Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110713484
gget_massin
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
Sun, Apr 27, 17:03
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Apr 29, 17:03 (2 d)
Engine
blob
Format
Raw Data
Handle
25843413
Attached To
rGTOOLS Gtools
gget_massin
View Options
#!/usr/bin/env python
'''
Get the mass contained in a specific radius
Yves Revaz
Thu Feb 23 14:06:51 CET 2006
'''
from numarray import *
from Nbody import *
import string
import sys
import os
from libjeans import *
from Nbody.libutil import histogram
from optparse import OptionParser
from Gtools import *
def parse_options():
usage = "usage: %prog [options] file"
parser = OptionParser(usage=usage)
parser = add_units_options(parser)
parser.add_option("-t",
action="store",
dest="ftype",
type="string",
default = None,
help="type of the file",
metavar=" TYPE")
parser.add_option("--cgs",
action="store_true",
dest="cgs",
default = 0,
help="invert into cgs units")
parser.add_option("--rmax",
action="store",
dest="rmax",
type="float",
default=0,
help="max radius")
(options, args) = parser.parse_args()
if len(args) == 0:
print "you must specify a filename"
sys.exit(0)
files = args
return files,options
#############################
# graph
#############################
# get options
files,options = parse_options()
rmax = options.rmax
cgs = options.cgs
ftype = options.ftype
if cgs:
units = get_units_options(options)
# read files
for file in files:
nbody = Nbody(file,ftype=ftype)
nbody.hdcenter()
r = nbody.rxyz()
mass = nbody.mass
if cgs:
mass = Mass2cgs(mass,units)
r = Length2cgs(r,units)
c = (r<rmax)
mass = compress(c,mass)
mtot = sum(mass)
print mtot
Event Timeline
Log In to Comment