Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121841892
gsteps
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, Jul 14, 08:29
Size
3 KB
Mime Type
text/x-python
Expires
Wed, Jul 16, 08:29 (2 d)
Engine
blob
Format
Raw Data
Handle
27389122
Attached To
rGTOOLS Gtools
gsteps
View Options
#!/usr/bin/env python
'''
Extract and plot info contained in cpu.txt files
Yves Revaz
jeu avr 6 15:58:19 CEST 2006
'''
import
Ptools
as
pt
import
os
,
sys
,
string
from
optparse
import
OptionParser
from
Gtools
import
*
from
Gtools
import
io
from
optparse
import
OptionParser
from
pNbody
import
cosmo
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
=
pt
.
add_postscript_options
(
parser
)
parser
=
pt
.
add_limits_options
(
parser
)
parser
=
pt
.
add_log_options
(
parser
)
parser
=
pt
.
add_cmd_options
(
parser
)
parser
.
add_option
(
"-t"
,
action
=
"store"
,
dest
=
"time"
,
type
=
"string"
,
default
=
'hour'
,
help
=
"time : day, hour, minute, second"
,
metavar
=
" TYPE"
)
parser
.
add_option
(
"--rf"
,
action
=
"store"
,
dest
=
"rf"
,
type
=
"int"
,
default
=
1
,
help
=
"reduction factor"
,
metavar
=
" INT"
)
parser
=
pt
.
add_units_options
(
parser
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
==
0
:
print
"you must specify a filename"
sys
.
exit
(
0
)
files
=
args
return
files
,
options
#######################################
# MakePlot
#######################################
def
MakePlot
(
dirs
,
opt
):
# some inits
palette
=
pt
.
GetPalette
()
#colors = pt.SetColorsForFiles(files,palette)
colors
=
pt
.
Colors
(
n
=
len
(
files
))
labels
=
[]
# define local units
try
:
unit_params
=
pt
.
do_units_options
(
opt
)
system_of_units
=
units
.
Set_SystemUnits_From_Params
(
unit_params
)
# convert a to Myrs
out_units
=
units
.
UnitSystem
(
'local'
,[
units
.
Unit_cm
,
units
.
Unit_Msol
,
units
.
Unit_Myr
,
units
.
Unit_K
])
hubbleparam
=
unit_params
[
"HubbleParam"
]
omegalambda
=
unit_params
[
"OmegaLambda"
]
omega0
=
unit_params
[
"Omega0"
]
Hubble
=
ctes
.
HUBBLE
.
into
(
system_of_units
)
pars
=
{
"Hubble"
:
Hubble
,
"HubbleParam"
:
hubbleparam
,
"OmegaLambda"
:
omegalambda
,
"Omega0"
:
omega0
}
funit
=
system_of_units
.
convertionFactorTo
(
out_units
.
UnitTime
)
ToTime
=
True
xlabel
=
"Time [Gyr]"
ylabel
=
"d Time [Myr]"
except
:
ToTime
=
False
xlabel
=
"Time"
ylabel
=
"Step"
# read files
datas
=
[]
for
file
in
files
:
Step
,
a
,
da
=
io
.
read_info
(
file
)
n
=
len
(
a
)
print
n
if
opt
.
rf
>
1
:
# compress
c
=
mod
(
arange
(
n
),
opt
.
rf
)
a
=
compress
(
c
==
0
,
a
)
da
=
compress
(
c
==
0
,
da
)
n
=
len
(
a
)
print
n
if
ToTime
:
t
=
ones
(
n
,
float
)
dt
=
ones
(
n
,
float
)
for
i
in
xrange
(
n
):
t
[
i
]
=
cosmo
.
CosmicTime_a
(
a
[
i
],
pars
)
/
hubbleparam
*
funit
/
1e3
dt
[
i
]
=
cosmo
.
dt_da
(
da
[
i
],
a
[
i
],
pars
)
/
hubbleparam
*
funit
x
=
t
y
=
dt
else
:
x
=
a
y
=
da
data
=
pt
.
DataPoints
(
x
,
y
,
color
=
colors
.
get
(),
label
=
None
,
tpe
=
'points'
)
data
datas
.
append
(
data
)
# plot
for
d
in
datas
:
pt
.
plot
(
d
.
x
,
d
.
y
,
color
=
d
.
color
)
xmin
,
xmax
,
ymin
,
ymax
=
pt
.
SetLimitsFromDataPoints
(
opt
.
xmin
,
opt
.
xmax
,
opt
.
ymin
,
opt
.
ymax
,
datas
,
opt
.
log
)
# plot axis
pt
.
SetAxis
(
xmin
,
xmax
,
ymin
,
ymax
,
log
=
opt
.
log
)
pt
.
xlabel
(
xlabel
,
fontsize
=
pt
.
labelfont
)
pt
.
ylabel
(
ylabel
,
fontsize
=
pt
.
labelfont
)
pt
.
grid
(
False
)
if
__name__
==
'__main__'
:
files
,
opt
=
parse_options
()
pt
.
InitPlot
(
files
,
opt
)
#pt.figure(figsize=(8*2,6*2))
#pt.figure(dpi=10)
pt
.
pcolors
#fig = pt.gcf()
#fig.subplots_adjust(left=0.1)
#fig.subplots_adjust(right=1)
#fig.subplots_adjust(bottom=0.12)
#fig.subplots_adjust(top=0.95)
#fig.subplots_adjust(wspace=0.25)
#fig.subplots_adjust(hspace=0.02)
MakePlot
(
files
,
opt
)
pt
.
EndPlot
(
files
,
opt
)
Event Timeline
Log In to Comment