Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F118852625
gadget2ascii
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
Sun, Jun 22, 14:12
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Jun 24, 14:12 (2 d)
Engine
blob
Format
Raw Data
Handle
26922080
Attached To
rPNBODY pNbody
gadget2ascii
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")
(options, args) = parser.parse_args()
if len(args) < 2:
print "you must specify two filenames !"
sys.exit(0)
file = None
else:
file = args
return file,options
################################################################################
#
# MAIN
#
################################################################################
files,opt = parse_options()
infile = files[0]
outfile = files[1]
nb = Nbody(infile,ftype=opt.ftype)
f = open(outfile,'w')
for i in xrange(nb.nbody):
line = nb.pos[i,0],nb.pos[i,1],nb.pos[i,2],nb.vel[i,0],nb.vel[i,1],nb.vel[i,2],nb.mass[i]
f.write("%20g %20g %20g %20g %20g %20g %20g \n"%line)
f.close()
Event Timeline
Log In to Comment