slha2isawig

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

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@209 15
andy@209 16 Author:
andy@209 17 Andy Buckley <andy.buckley@cern.ch>
andy@209 18 http://insectnation.org/projects/pyslha
andy@9 19 """
andy@9 20
andy@9 21 __author__ = "Andy Buckley <andy.buckley@cern.ch"
andy@9 22
andy@73 23 import pyslha
andy@14 24 import sys, optparse
andy@73 25 parser = optparse.OptionParser(usage=__doc__, version=pyslha.__version__)
andy@14 26 opts, args = parser.parse_args()
andy@14 27 if len(args) < 1 or len(args) > 2:
andy@14 28 parser.print_help()
andy@14 29 sys.exit(1)
andy@14 30
andy@14 31 ## Choose output file
andy@14 32 import os
andy@14 33 o = os.path.basename(args[0])
andy@14 34 if "." in o:
andy@14 35 o = o[:o.rindex(".")]
andy@14 36 opts.OUTFILE = o + ".isa"
andy@14 37 if len(args) == 2:
andy@14 38 opts.OUTFILE = args[1]
andy@14 39
andy@14 40 ## Read spectrum file
andy@21 41 BLOCKS, DECAYS = pyslha.readSLHAFile(args[0])
andy@14 42
andy@48 43 ## And write it out again!
andy@48 44 if opts.OUTFILE == "-":
andy@48 45 sys.stdout.write(pyslha.writeISAWIG(opts.OUTFILE))
andy@48 46 else:
andy@48 47 pyslha.writeISAWIGFile(opts.OUTFILE, BLOCKS, DECAYS)

mercurial