slha2isawig

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@9 1 #! /usr/bin/env python
andy@9 2
andy@14 3 """\
andy@14 4 Usage: %prog IN.slha [OUT.isa]
andy@14 5
andy@9 6 Convert an SLHA model/decay spectrum file to a HERWIG/ISAWIG SUSY spectrum input
andy@25 7 file, in the format written by ISAWIG. The intention of this script is to allow
andy@25 8 HERWIG to be used with spectra generated by codes other than ISAWIG,
andy@25 9 e.g. SoftSUSY, SPheno, etc. And fundamentally because the author was fed up with
andy@25 10 having to make ISASUSY compile with gfortran on platforms where CERNLIB wasn't
andy@25 11 available!
andy@14 12
andy@14 13 Conversion based on the HERWIG SUSY specification format, from
andy@14 14 http://www.hep.phy.cam.ac.uk/~richardn/HERWIG/ISAWIG/file.html
andy@9 15 """
andy@9 16
andy@9 17 __author__ = "Andy Buckley <andy.buckley@cern.ch"
andy@9 18
andy@73 19 import pyslha
andy@14 20 import sys, optparse
andy@73 21 parser = optparse.OptionParser(usage=__doc__, version=pyslha.__version__)
andy@14 22 opts, args = parser.parse_args()
andy@14 23 if len(args) < 1 or len(args) > 2:
andy@14 24 parser.print_help()
andy@14 25 sys.exit(1)
andy@14 26
andy@14 27 ## Choose output file
andy@14 28 import os
andy@14 29 o = os.path.basename(args[0])
andy@14 30 if "." in o:
andy@14 31 o = o[:o.rindex(".")]
andy@14 32 opts.OUTFILE = o + ".isa"
andy@14 33 if len(args) == 2:
andy@14 34 opts.OUTFILE = args[1]
andy@14 35
andy@14 36 ## Read spectrum file
andy@21 37 BLOCKS, DECAYS = pyslha.readSLHAFile(args[0])
andy@14 38
andy@48 39 ## And write it out again!
andy@48 40 if opts.OUTFILE == "-":
andy@48 41 sys.stdout.write(pyslha.writeISAWIG(opts.OUTFILE))
andy@48 42 else:
andy@48 43 pyslha.writeISAWIGFile(opts.OUTFILE, BLOCKS, DECAYS)

mercurial