Page MenuHomec4science

gbubble
No OneTemporary

File Metadata

Created
Mon, Nov 25, 23:19
#!/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 SM
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")
parser.add_option("--relative",
action="store_true",
dest="relative",
default = 0,
help="plot relative value")
(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()
ps = options.ps
col = options.colors
xmin = options.xmin
xmax = options.xmax
ymin = options.ymin
ymax = options.ymax
log = options.log
obs = options.obs
rel = options.relative
#######################################
# open sm
#######################################
g = Graph_Init(ps)
Graph_SetDefaultsGraphSettings(g)
colors = Graph_SetColorsForFiles(files,col)
#######################################
# 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
'''
x = vals['Time']
if obs == 'OtherKeyWord':
pass
elif vals.has_key(obs):
y = vals[obs]
else:
print "unknown observable %s"%(obs)
sys.exit()
if rel:
y = 100*(fabs(y-y[0]))/y[0]
y = fabs(y)
# use log
if log != None:
x,y = Graph_UseLog(x,y,log)
if file == files[0]:
xmin,xmax,ymin,ymax = Graph_SetLimits(g,xmin,xmax,ymin,ymax,x,y)
g.box()
# plot points
g.ctype(colors[file])
g.ptype(10,3)
g.points(x,y)
g.ptype(0,0)
# labels
g.ctype(0)
g.xlabel('T')
g.ylabel('%s'%obs)
g.ctype(0)
if log == 'xy' or log == 'yx':
g.xlabel('log T')
g.ylabel('log %s'%obs)
elif log == 'x':
g.xlabel('log T')
g.ylabel('%s'%obs)
elif log == 'y':
g.xlabel('T')
g.ylabel('log %s'%obs)
else:
g.xlabel('T')
g.ylabel('%s'%obs)
# -- end ---
Graph_End(g,ps)

Event Timeline