IRATE-format / scripts / rockstar2irate


import sys,os
from optparse import OptionParser
from irate.rockstar import read_rockstar_ascii,read_rockstar_binary,write_halodata
import h5py

usage = "usage: %prog <input file> <format (-a or -b)> [output file (defaults to input file + '-irate.hdf5')]"

parser = OptionParser(usage=usage)

parser.add_option("-b",action="store_true",dest="binary",help="Specifies that input file is a Rockstar binary file.  Defaut = %default because not currently supported",default=False)
parser.add_option("-a",action="store_false",dest="binary",help="Specifies that the input file is a Rockstar ascii file.  Default = True, because currently the only supported format.")
parser.add_option('-o',action='store_true',dest='overwrite',help='Overwrite existing IRATE file, if one exists.  Default = %default',default=False)
parser.add_option('-q',action='store_true',dest='quiet',help='Run with minimal output.  Default = %default',default=False)

(ops,args) = parser.parse_args()

if len(sys.argv) == 1:

if len(args) == 1:
	inname = args[0]
	outname = inname+'-irate.hdf5'
elif len(args) == 2:
	inname = args[0]
	outname = args[1]

if not outname.endswith('.hdf5'):  outname = outname + ".hdf5"

if os.path.isfile(outname):
    if ops.overwrite:
        print "Overwriting "+outname+" with new file."
        print "Output file already exists; please choose a different output file or run with -o."
verbose = not ops.quiet

if binary:
	print "Reading data from Rockstar binary file "+inname
	[halodata,haloheaders] = read_rockstar_binary(inname,verbose)
	print "Reading data from Rockstar ascii file "+inname
	[halodata,haloheaders] = read_rockstar_ascii(inname,verbose)
print "Writing data to "+outname
print "Successfully created IRATE file "+outname
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.