Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91190226
gplot_r-vcirc
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
Fri, Nov 8, 19:43
Size
4 KB
Mime Type
text/x-python
Expires
Sun, Nov 10, 19:43 (2 d)
Engine
blob
Format
Raw Data
Handle
22216116
Attached To
rGTOOLS Gtools
gplot_r-vcirc
View Options
#!/home/revaz/local/bin/python
'''
Plot circular velocity curve of the model as a function of radius
Rotation curve is derived from the mass inside a certain radius,
assuming a sperical density distribution.
Yves Revaz
ven avr 14 16:17:32 CEST 2006
'''
from numarray import *
from pNbody import *
from pNbody import cosmo
import SM
import string
import sys
import os
from libjeans import *
from pNbody.libutil import histogram
from optparse import OptionParser
from Gtools import *
from Gtools import vanderwaals as vw
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_units_options(parser)
parser = add_log_options(parser)
parser = add_reduc_options(parser)
parser = add_center_options(parser)
parser = add_select_options(parser)
parser.add_option("-t",
action="store",
dest="ftype",
type="string",
default = None,
help="type of the file",
metavar=" TYPE")
parser.add_option("--rmax",
action="store",
dest="rmax",
type="float",
default = 50,
help="max radius",
metavar=" FLOAT")
parser.add_option("--nbins",
action="store",
dest="nbins",
type="int",
default=25,
help="number of bins")
parser.add_option("--cgs",
action="store_true",
dest="cgs",
default = 0,
help="invert into cgs units")
(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
reduc = options.reduc
center = options.center
select = options.select
cgs = options.cgs
ftype = options.ftype
rmax = options.rmax
nbins = options.nbins
localsystem = Set_SystemUnits_From_Options(options)
localsystem.get_UnitDensity_in_cgs()
#######################################
# define output system of unit
#######################################
outputunits = units.UnitSystem('mks',[units.Unit_kpc, units.Unit_Ms, units.Unit_yr , units.Unit_K, units.Unit_mol, units.Unit_C])
#######################################
# open sm
#######################################
g = Graph_Init(ps)
Graph_SetDefaultsGraphSettings(g)
colors = Graph_SetColorsForFiles(files,col)
#######################################
# LOOP
#######################################
# read files
for file in files:
nb = Nbody(file,ftype=ftype)
# set unit parameter
nb.localsystem_of_units = localsystem
# center the model
if center=='hdcenter':
print "centering %s"%(center)
nb.hdcenter()
elif center=='histocenter':
print "centering %s"%(center)
nb.histocenter()
# select
if select!=None:
print "select %s"%(select)
nb = nb.select(select)
if reduc!= None:
print "reducing %s"%(reduc)
nb = nb.reduc(reduc)
# get values
x,y = nb.mr(nb=nbins,rm=rmax)
# remove problematic values
c = (x!=0)
x = compress(c,x)
y = compress(c,y)
# compute vc
G = ctes.GRAVITY.into(nb.localsystem_of_units)
y = sqrt(G*y/x)
'''
if cgs:
z = Length2cgs(x,units)
y = Mass2cgs(y,units)
G = 6.672e-8 # in cgs
x = x[1:]
y = sqrt(G*y[1:]/z[1:])
else:
G = 43007.1 # in local units
x = x[1:]
y = sqrt(G*y[1:]/x)
'''
# use log
if log != None:
x,y = Graph_UseLog(x,y,log)
if file == files[0]:
Graph_SetLimits(g,xmin,xmax,ymin,ymax,x,y)
g.box()
# plot points
g.ctype(colors[file])
g.connect(x,y)
g.ctype(0)
if log == 'xy' or log == 'yx':
g.xlabel('log R')
g.ylabel('log Velocity')
elif log == 'x':
g.xlabel('log R')
g.ylabel('Velocity')
elif log == 'y':
g.xlabel('R')
g.ylabel('log Velocity')
else:
g.xlabel('R')
g.ylabel('Velocity')
# -- end ---
Graph_End(g,ps)
Event Timeline
Log In to Comment