Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100639761
gplotres
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
Sat, Feb 1, 09:59
Size
3 KB
Mime Type
text/x-python
Expires
Mon, Feb 3, 09:59 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
24005141
Attached To
rGTOOLS Gtools
gplotres
View Options
#!/usr/bin/env python
'''
Extract and plot data from output from jeans fortran program
Yves Revaz
Tue Aug 16 14:05:26 CEST 2005
'''
from numarray import *
import SM
import string
import sys
from libjeans import *
from scipy.interpolate import splrep,splev
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("--minx",
action="store",
dest="mnx",
default=0,
help="min value in x")
parser.add_option("--maxx",
action="store",
dest="mxx",
default=30,
help="max value in x")
parser.add_option("--miny",
action="store",
dest="mny",
default=0,
help="min value in y")
parser.add_option("--maxy",
action="store",
dest="mxy",
default=0.5,
help="max value in y")
parser.add_option("--omega",
action="store",
dest="omega",
type="float",
default=None,
help="omega value")
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")
(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
rmin = options.mnx
rmax = options.mxx
ymin = options.mny
ymax = options.mxy
omega = options.omega
col = options.colors
# 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')
#######################################
# colors
if len(files)>1:
x0 = 0.05
y0 = 0.95
x = x0
y = y0
dx = 0.5/len(files)
g.location(3500,31000,3500,31000)
g.limits(0,1,0,1)
g.ptype(10,3)
g.expand(1.5)
for i in range (len(colors)):
xp=array([x],Float)
yp=array([y],Float)
g.ctype(colors[files[i]])
g.points(xp,yp)
x = x + dx
g.ctype(0)
g.expand(0.999)
#######################################
# first
g.location(3500, 31000, 3500, 31000)
g.limits(rmin,rmax,ymin,ymax)
g.box()
g.ylabel('Omega')
g.xlabel('R [kpc]')
#######################################
# LOOP
#######################################
for file in files:
R,Sdens,Omega,Kappa,OmK2,Nu,Vr,Vt,Vz,Vc,Sr,St,Sz,H,Q=read_jeans(file)
r = R
om = Omega
omk2 = Omega-Kappa/2
opk2 = Omega+Kappa/2
# color
g.ctype(colors[file])
g.connect(r,om)
g.connect(r,omk2)
g.connect(r,opk2)
g.ctype(0)
if omega != None:
g.relocate(0,omega)
g.draw(100,omega)
# -- end ---
if ps==None:
g.show()
else:
g.write()
g.clean()
Event Timeline
Log In to Comment