Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65775737
tipsy2gadget.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
Thu, Jun 6, 03:39
Size
1004 B
Mime Type
text/x-python
Expires
Sat, Jun 8, 03:39 (2 d)
Engine
blob
Format
Raw Data
Handle
18125462
Attached To
rPNBODY pNbody
tipsy2gadget.py
View Options
#!/usr/bin/env python
from
pNbody
import
*
from
pNbody
import
libtipsy
import
argparse
description
=
None
epilog
=
None
parser
=
argparse
.
ArgumentParser
(
description
=
description
,
epilog
=
epilog
)
parser
.
add_argument
(
"-o"
,
"--outputfile"
,
action
=
"store"
,
dest
=
"outputfile"
,
help
=
"name of the output file"
,
metavar
=
"FILE"
)
parser
.
add_argument
(
'files'
,
metavar
=
'FILE'
,
type
=
str
,
nargs
=
1
,
help
=
'name of the file to convert'
)
#####################################
# main
#####################################
opt
=
parser
.
parse_args
()
file
=
opt
.
files
[
0
]
if
not
os
.
path
.
isfile
(
file
):
print
"file
%s
does not exists."
%
file
sys
.
exit
()
pos
,
vel
,
mass
=
libtipsy
.
read
(
file
)
pos
=
pos
.
astype
(
float32
)
vel
=
vel
.
astype
(
float32
)
mass
=
mass
.
astype
(
float32
)
if
opt
.
outputfile
!=
None
:
nb
=
Nbody
(
status
=
'new'
,
p_name
=
opt
.
outputfile
,
pos
=
pos
,
vel
=
vel
,
mass
=
mass
,
ftype
=
'gadget'
)
nb
.
set_tpe
(
2
)
nb
.
write
()
Event Timeline
Log In to Comment