Page MenuHomec4science

gbubble_stat
No OneTemporary

File Metadata

Created
Thu, Jul 18, 17:50

gbubble_stat

#!/usr/bin/env python
'''
Extract and plot info contained in the
output Gadget file called by default "bubble.txt".
Yves Revaz
mer sep 6 10:18:58 CEST 2006
'''
from numarray import *
from Nbody import *
import string
import sys
import os
from Nbody.libutil import histogram
from optparse import OptionParser
from Gtools import *
from Gtools import io
def parse_options():
usage = "usage: %prog [options] file"
parser = OptionParser(usage=usage)
parser = add_postscript_options(parser)
parser = add_color_options(parser)
parser = add_limits_options(parser)
parser = add_log_options(parser)
parser.add_option("-o",
action="store",
dest="obs",
type="string",
default = 'OverPressure',
help="observable name",
metavar=" NAME")
(options, args) = parser.parse_args()
if options.colors!=None:
exec("options.colors = array([%s])"%(options.colors))
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()
obs = options.obs
#######################################
# LOOP
#######################################
# read files
for file in files:
try:
vals = io.read_bubble(file)
except:
print "problem reading %s"%(file)
sys.exit()
'''
Step Time OverPressure EgyJet EgyInt EgyPot
'''
t = vals['Time']
e = vals['EgyJet']
tmin = min(t)
tmax = max(t)
dt = tmax-tmin
print
print file
print "Mean Energy = %g"%(e.mean())
print "Tot Energy = %g"%(sum(e))
print "Num of bubbles = %d"%(len(e))
print "Mean Jet Time = %g"%(2*dt/len(e))

Event Timeline