Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110224896
gplot_crv_005
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, Apr 25, 06:28
Size
5 KB
Mime Type
text/x-python
Expires
Sun, Apr 27, 06:28 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25796360
Attached To
rGTOOLS Gtools
gplot_crv_005
View Options
#!/usr/bin/env python
'''
Plot velocity dispertion in z as a function of the radius
Yves Revaz
Mon Jun 4 16:05:18 CEST 2007
'''
from numpy import *
from pNbody import *
from pNbody import cosmo
from pNbody.libutil import *
from pNbody import libdisk
import Ptools as pt
import string
import sys
import os
from optparse import OptionParser
from Gtools import *
from Gtools import vanderwaals as vw
from Gtools import io
unit_velocity = 0.8797
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_cmd_options(parser)
parser = add_display_options(parser)
parser = add_labels_options(parser)
parser.add_option("--write",
action="store_true",
dest="write",
default = False,
help="write output")
parser.add_option("--add_legend",
action="store_true",
dest="add_legend",
default = False,
help="add legend")
(options, args) = parser.parse_args()
if options.colors!=None:
exec("options.colors = array([%s])"%(options.colors))
files = args
return files,options
#######################################
# MakePlot
#######################################
def MakePlot(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
write = options.write
labels = options.labels
labx = options.labx
laby = options.laby
labdx = options.labdx
labdy = options.labdy
labex = options.labex
labbox = options.labbox
localsystem = Set_SystemUnits_From_Options(options)
#######################################
# define output system of unit
#######################################
outputunits = units.UnitSystem('mks',[units.Unit_km, units.Unit_Ms, units.Unit_s , units.Unit_K, units.Unit_mol, units.Unit_C])
#######################################
# init graph
#######################################
labelfont = 16
ax = pt.gca()
pt.setp(ax.get_xticklabels(),fontsize=labelfont)
pt.setp(ax.get_yticklabels(),fontsize=labelfont)
palette = pt.GetPalette()
colors = pt.SetColorsForFiles(files,palette)
fig = pt.gcf()
fig.subplots_adjust(left=0.1)
fig.subplots_adjust(top=1)
fig.subplots_adjust(bottom=0.1)
fig.subplots_adjust(right=1)
fig.subplots_adjust(wspace=0.15)
fig.subplots_adjust(hspace=0.1)
#######################################
# LOOP
#######################################
factor = 100* unit_velocity
lweight_fact = 1
directories = ['ref','003']
crv_lst = []
for directory in directories:
if directory=='ref':
ls = '-'
else:
ls = '--'
# total
R,Vc2 = io.read_crv2('%s/None.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_tot = pt.plot(x,y,c='k',ls=ls,lw=1.5,label=r'$\rm{total}$')
if directory=='ref':
xmin,xmax,ymin,ymax = pt.SetLimits(options.xmin,options.xmax,options.ymin,options.ymax,x,y,options.log)
# halo
R,Vc2 = io.read_crv2('%s/halo.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_halo = pt.plot(x,y,c='c',ls=ls,lw=1.0,label=r'$\rm{halo}$')
# bulge
R,Vc2 = io.read_crv2('%s/bulge.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_bulge = pt.plot(x,y,c='g',ls=ls,lw=1.0,label=r'$\rm{bulge}$')
# disk
R,Vc2 = io.read_crv2('%s/disk.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_disk = pt.plot(x,y,c='y',ls=ls,lw=1.0,label=r'$\rm{disk}$')
# gas
R,Vc2 = io.read_crv2('%s/wg.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_wg = pt.plot(x,y,c='r',ls=ls,lw=1.0,label=r'$\rm{visble gas}$')
if directory!='ref':
# cold gas
R,Vc2 = io.read_crv2('%s/cg.crv2'%(directory))
x = R.astype(float32)
y2 = Vc2.astype(float32)
y = sqrt(fabs(y2)) * factor
line_cg = pt.plot(x,y,c='b',ls=':',lw=1.0,label=r'$\rm{cold gas}$')
crv_lst.append(line_cg)
else:
crv_lst = [line_tot,line_halo,line_bulge,line_disk,line_wg]
pt.SetAxis(xmin,xmax,ymin,ymax,options.log)
pt.xlabel(r'$\rm{Radius}\,\left[ kpc \right]$',fontsize=labelfont)
pt.ylabel(r'$\rm{Circular\,\,Velocity}\,\left[ km/s \right]$',fontsize=labelfont)
# add legend
if options.add_legend:
labels = [r'$\rm{total}$',r'$\rm{halo}$',r'$\rm{bulge}$',r'$\rm{disk}$',r'$\rm{visible\,\,gas}$',r'$\rm{dark\,\,gas}$']
pt.legend(crv_lst,labels,loc='upper right',shadow=True,labelsep=0.005)
####################################
if __name__ == '__main__':
files,opt = parse_options()
pt.InitPlot(files,opt)
#pt.figure(figsize=(8*2,6*2))
#pt.figure(dpi=10)
pt.pcolors
MakePlot(files,opt)
pt.EndPlot(files,opt)
Event Timeline
Log In to Comment