isawig2slha

Sun, 10 Apr 2011 12:24:01 +0100

author
Andy Buckley <andy@insectnation.org>
date
Sun, 10 Apr 2011 12:24:01 +0100
changeset 141
869c16f9093b
parent 73
427216d07f43
child 209
42fe24d30c22
permissions
-rwxr-xr-x

Fix block parsing error and make 1.2.3 release

     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
    11 """
    13 __author__ = "Andy Buckley <andy.buckley@cern.ch"
    16 import pyslha
    17 import sys, optparse
    18 parser = optparse.OptionParser(usage=__doc__, version=pyslha.__version__)
    19 opts, args = parser.parse_args()
    20 if len(args) < 1 or len(args) > 2:
    21     parser.print_help()
    22     sys.exit(1)
    24 ## Choose output file
    25 import os
    26 o = os.path.basename(args[0])
    27 if "." in o:
    28     o = o[:o.rindex(".")]
    29 opts.OUTFILE = o + ".spc"
    30 if len(args) == 2:
    31     opts.OUTFILE = args[1]
    33 ## Read spectrum file
    34 BLOCKS, DECAYS = pyslha.readISAWIGFile(args[0])
    36 ## And write it out again!
    37 if opts.OUTFILE == "-":
    38     sys.stdout.write(pyslha.writeSLHA(opts.OUTFILE))
    39 else:
    40     pyslha.writeSLHAFile(opts.OUTFILE, BLOCKS, DECAYS)

mercurial