Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93067302
gplot_histoUth
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
Mon, Nov 25, 23:08
Size
4 KB
Mime Type
text/x-python
Expires
Wed, Nov 27, 23:08 (2 d)
Engine
blob
Format
Raw Data
Handle
22568938
Attached To
rGTOOLS Gtools
gplot_histoUth
View Options
#!/usr/bin/env python
'''
Plot an histogram of angular momentum of particles
Yves Revaz
Wed Aug 31 14:31:49 CEST 2005
'''
from numarray import *
from Nbody import *
import SM
import string
import sys
import os
from libjeans import *
from Nbody.libutil import histogram
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("-t",
action="store",
dest="ftype",
type="string",
default = 'gadget',
help="type of the file",
metavar=" TYPE")
parser.add_option("--umin",
action="store",
dest="umin",
type="float",
default=None,
help="min value in u")
parser.add_option("--umax",
action="store",
dest="umax",
type="float",
default=None,
help="max value in u")
parser.add_option("--du",
action="store",
dest="du",
type="float",
default=None,
help="interval in u")
parser.add_option("--miny",
action="store",
dest="mny",
type="float",
default=None,
help="min value in y")
parser.add_option("--maxy",
action="store",
dest="mxy",
type="float",
default=None,
help="max value in y")
parser.add_option("--tpe",
action="store",
dest="tpe",
type="string",
default = None,
help="particule type",
metavar=" NAME")
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
tpe= options.tpe
umin = options.umin
umax = options.umax
hmin = options.mny
hmax = options.mxy
col = options.colors
ftype = options.ftype
du = options.du
# 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:
# open file
nb = Nbody(file,ftype=ftype)
print nb.tnow
if tpe == 'wg':
nb = nb.select('gas')
u = nb.uth
elif tpe == 'cg':
nb = nb.select('halo')
u = nb.uth
elif tpe == 'st':
nb = nb.select('disk')
u = nb.uth
elif tpe == 'gas':
nb1 = nb.select('gas')
nb2 = nb.select('halo')
u1 = nb1.uth
u2 = nb2.uth
u = concatenate((u1,u2))
if umin == None:
umin = min(u)
if umax == None:
umax = max(u)
if du == None:
du = (umax-umin)/50.
bins = arange(umin,umax,du)
h = histogram(u,bins)
if hmin == None:
hmin = min(h)
if hmax == None:
hmax = max(h)
if file == files[0]:
g.location(3500, 31000, 3500, 31000)
g.limits(umin,umax,hmin,hmax)
g.box()
# color
g.ctype(colors[file])
g.histogram(bins,h)
g.ctype(0)
g.xlabel('l')
g.ylabel('N')
# -- end ---
if ps==None:
g.show()
else:
g.write()
g.clean()
Event Timeline
Log In to Comment