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

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

mercurial