Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102206350
old.addmetals.py
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
Tue, Feb 18, 06:32
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Feb 20, 06:32 (2 d)
Engine
blob
Format
Raw Data
Handle
24306300
Attached To
rPNBODY pNbody
old.addmetals.py
View Options
#!/usr/bin/env python
from
pNbody
import
*
from
optparse
import
OptionParser
########################################
#
# parser
#
########################################
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
(
"-o"
,
action
=
"store"
,
dest
=
"outputfile"
,
type
=
"string"
,
default
=
None
,
help
=
"outputfile name"
,
metavar
=
" STING"
)
parser
.
add_option
(
"--exec"
,
action
=
"store"
,
dest
=
"execline"
,
type
=
"string"
,
default
=
None
,
help
=
"give command to execute before"
,
metavar
=
" STRING"
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
==
0
:
print
"you must specify a filename"
sys
.
exit
(
0
)
file
=
None
else
:
file
=
args
return
file
,
options
################################################################################
#
# MAIN
#
################################################################################
file
,
opt
=
parse_options
()
nb
=
Nbody
(
file
,
ftype
=
opt
.
ftype
)
if
opt
.
execline
!=
None
:
exec
(
opt
.
execline
)
NELEMENTS
=
5
nb
.
flag_metals
=
NELEMENTS
nb
.
rho
=
ones
(
nb
.
nbody
)
.
astype
(
float32
)
nb
.
rsp
=
zeros
(
nb
.
nbody
)
.
astype
(
float32
)
nb
.
metals
=
zeros
((
nb
.
nbody
,
NELEMENTS
))
.
astype
(
float32
)
# Fe
Fe
=
-
1
*
ones
(
nb
.
nbody
)
.
astype
(
float32
)
nb
.
metals
[:,
0
]
=
nb
.
ChimieSolarMassAbundances
[
'Fe'
]
*
(
10
**
Fe
-
1.0e-20
)
if
opt
.
outputfile
!=
None
:
nb
.
rename
(
opt
.
outputfile
)
nb
.
write
()
Event Timeline
Log In to Comment