isawig2slha

Mon, 29 Apr 2013 15:04:31 +0200

author
Andy Buckley <andy@insectnation.org>
date
Mon, 29 Apr 2013 15:04:31 +0200
changeset 214
fa07ed634b18
parent 209
42fe24d30c22
permissions
-rwxr-xr-x

Better newline handling in final SLHA output formatting

     1 #! /usr/bin/env python
     3 """\
     4 Usage: %prog IN.isa [OUT.spc]
     6 Convert a HERWIG/ISAWIG model/decay spectrum file to an SLHA spectrum input
     7 file.
     9 Conversion based on the HERWIG SUSY specification format, from
    10 http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/file.html
    12 Author:
    13   Andy Buckley <andy.buckley@cern.ch>
    14   http://insectnation.org/projects/pyslha
    15 """
    17 __author__ = "Andy Buckley <andy.buckley@cern.ch"
    20 import pyslha
    21 import sys, optparse
    22 parser = optparse.OptionParser(usage=__doc__, version=pyslha.__version__)
    23 opts, args = parser.parse_args()
    24 if len(args) < 1 or len(args) > 2:
    25     parser.print_help()
    26     sys.exit(1)
    28 ## Choose output file
    29 import os
    30 o = os.path.basename(args[0])
    31 if "." in o:
    32     o = o[:o.rindex(".")]
    33 opts.OUTFILE = o + ".spc"
    34 if len(args) == 2:
    35     opts.OUTFILE = args[1]
    37 ## Read spectrum file
    38 BLOCKS, DECAYS = pyslha.readISAWIGFile(args[0])
    40 ## And write it out again!
    41 if opts.OUTFILE == "-":
    42     sys.stdout.write(pyslha.writeSLHA(opts.OUTFILE))
    43 else:
    44     pyslha.writeSLHAFile(opts.OUTFILE, BLOCKS, DECAYS)

mercurial