Page MenuHomec4science

gplottv
No OneTemporary

File Metadata

Created
Fri, Nov 29, 06:10
#!/usr/bin/env python
'''
Extract and plot data from output from jeans fortran program
Yves Revaz
Wed Aug 31 13:47:40 CEST 2005
'''
from numarray import *
import SM
import string
import sys
import os
from libjeans 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("--tmin",
action="store",
dest="tmin",
default=None,
help="min value in t")
parser.add_option("--tmax",
action="store",
dest="tmax",
default=None,
help="max value in t")
parser.add_option("--miny",
action="store",
dest="mny",
default=0,
help="min value in y")
parser.add_option("--maxy",
action="store",
dest="mxy",
default=220,
help="max value in y")
parser.add_option("--rmin",
action="store",
dest="rmin",
default=10,
help="min value in r")
parser.add_option("--rmax",
action="store",
dest="rmax",
default=20,
help="max value in r")
parser.add_option("-p",
action="store",
dest="ps",
type="string",
default = None,
help="postscript filename",
metavar=" FILE")
parser.add_option("-c",
action="store",
dest="colors",
type="string",
default = None,
help="colors",
metavar=" 0,64,192")
parser.add_option("-o",
action="store",
dest="observable",
type="string",
default = 'Vc',
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()
ps = options.ps
tmin = options.tmin
tmax = options.tmax
rmin = options.rmin
rmax = options.rmax
vmin = options.mny
vmax = options.mxy
col = options.colors
observable = options.observable
# set colors
colors = {}
i = 0
for file in files:
if col!=None:
colors[file]=col[i]
else:
colors[file] = i*255/len(files)
i = i + 1
#######################################
# open sm
#######################################
if ps==None:
g = SM.plot("x11 -bg white -fg black ")
else:
g = SM.plot("postencap %s"%ps)
# some init
g.palette('bgyrw')
g.expand(0.999)
g.setvariable('TeX_strings', '1')
#######################################
# first
g.location(3500, 31000, 3500, 31000)
#######################################
# LOOP
#######################################
vs = array([],Float)
ts= array([],Float)
for file in files:
# extract time
bfile = os.path.basename(file)
t = float(bfile[bfile.find('_')+1:bfile.find('_')+9])
R,Sdens,Omega,Kappa,OmK2,Nu,Vr,Vt,Vz,Vc,Sr,St,Sz,H,Q=read_jeans(file)
if observable == 'Sdens':
var = Sdens
elif observable == 'Omega':
var = Sdens
elif observable == 'Kappa':
var = Kappa
elif observable == 'OmK2':
var = OmK2
elif observable == 'Nu':
var = Nu
elif observable == 'Vr':
var = Vr*978
elif observable == 'Vt':
var = Vt*978
elif observable == 'Vz':
var = Vz*978
elif observable == 'Vc':
var = Vc*978
elif observable == 'Sr':
var = Sr*978
elif observable == 'St':
var = St*978
elif observable == 'Sz':
var = Sz*978
elif observable == 'H':
var = H
elif observable == 'Q':
var = Q
var = compress((R>rmin)*(R<rmax),var)
var = var.mean()
vs = concatenate((vs,var))
ts = concatenate((ts,t))
if tmin==None:
tmin = min(ts)
if tmax==None:
tmax = max(ts)
if vmin==None:
vmin = min(vs)
if vmax==None:
vmax = max(vs)
g.limits(tmin,tmax,vmin,vmax)
g.connect(ts,vs)
g.box()
g.xlabel('time [Myr]')
g.ylabel('V [km/s]')
# -- end ---
if ps==None:
g.show()
else:
g.write()
g.clean()

Event Timeline