#!/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()


