|
[Rivet-svn] r2494 - trunk/binblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Jun 21 18:16:30 BST 2010
Author: buckley Date: Mon Jun 21 18:16:34 2010 New Revision: 2494 Log: Various script functionality and cosmetic improvements... mostly relating to automatic discovery of ref and plot info paths Modified: trunk/bin/compare-histos trunk/bin/make-plots trunk/bin/rivet Modified: trunk/bin/compare-histos ============================================================================== --- trunk/bin/compare-histos Mon Jun 21 17:37:46 2010 (r2493) +++ trunk/bin/compare-histos Mon Jun 21 18:16:34 2010 (r2494) @@ -1,5 +1,16 @@ #! /usr/bin/env python +"""\ +%prog - generate comparison plots + +USAGE: + %prog [options] [REF:'Expt data'] aidafile1:'label 1' [path/to/aidafile2:label2 ...] + +TODO: + * regex selector + * ask/force overwrite modes +""" + ## Make "set" a builtin type on Python < 2.4 if 'set' not in dir(__builtins__): @@ -42,15 +53,13 @@ if __name__ == "__main__": import os, sys, re, logging - usage = """%prog - generate comparison plots - - USAGE: - %prog [options] [REF:'Expt data'] aidafile1:'label 1' [path/to/aidafile2:label2 ...] - - TODO: - * regex selector - * ask/force overwrite modes - """ + ## Try to rename the process on Linux + try: + import ctypes + libc = ctypes.cdll.LoadLibrary('libc.so.6') + libc.prctl(15, 'compare-histos', 0, 0, 0) + except Exception: + pass ## Try to use Psyco optimiser try: @@ -60,16 +69,21 @@ pass ## Get Rivet data dir - rivet_data_dir = "" + rivet_data_dirs = [] try: import rivet - rivet_data_dir = rivet.getRivetDataPath() + if os.environ.has_key("RIVET_REF_PATH"): + env = os.environ.get("RIVET_REF_PATH").strip() + if env != ":": + rivet_data_dirs = os.environ.get("RIVET_REF_PATH").split(":") + else: + rivet_data_dirs.append(rivet.getRivetDataPath()) except: pass ## Parse command line options from optparse import OptionParser - parser = OptionParser(usage=usage) + parser = OptionParser(usage=__doc__) parser.add_option("-o", "--outdir", dest="OUTDIR", default=".", help="write data files into this directory") parser.add_option("-R", "--rivet-refs", dest="RIVETREFS", action="store_true", @@ -95,7 +109,7 @@ parser.add_option("--refid", dest="REF_ID", default="REF", help="ID of reference data set (file path for non-REF data)") parser.add_option("--plot-info-dir", dest="PLOTINFODIR", action="append", - default=["./", rivet_data_dir], help="directory which may contain plot header information") + default=["./", rivet_data_dirs[0]], help="directory which may contain plot header information") parser.add_option("-q", "--quiet", help="Suppress normal messages", dest="LOGLEVEL", action="store_const", default=logging.INFO, const=logging.WARNING) parser.add_option("-v", "--verbose", help="Add extra debug messages", dest="LOGLEVEL", @@ -140,9 +154,11 @@ ## Get file names and labels FILES = [] FILELABELS = { } - if opts.RIVETREFS and rivet_data_dir: - import glob - reffiles = glob.glob(os.path.join(rivet_data_dir, "*.aida")) + if opts.RIVETREFS and rivet_data_dirs: + reffiles = [] + for d in rivet_data_dirs: + import glob + reffiles += glob.glob(os.path.join(d, "*.aida")) args = reffiles + args for a in args: path = a Modified: trunk/bin/make-plots ============================================================================== --- trunk/bin/make-plots Mon Jun 21 17:37:46 2010 (r2493) +++ trunk/bin/make-plots Mon Jun 21 18:16:34 2010 (r2494) @@ -1,5 +1,14 @@ #! /usr/bin/env python +"""\ +Usage: %prog [options] file.dat [file2.dat ...] + +TODO + * use std method (from compphys marking) to kill the subprocess + * Tidy LaTeX-writing code + * Handle boolean values flexibly (yes, no, true, false, etc. as well as 1, 0) +""" + ## ## This program is copyright by Hendrik Hoeth <hoeth at linta.de>. It may be used ## for scientific and private purposes. Patches are welcome, but please don't @@ -1729,14 +1738,14 @@ if __name__ == '__main__': - msg = """\ -Usage: %prog [options] file.dat [file2.dat ...] -TODO - * use std method (from compphys marking) to kill the subprocess - * Tidy LaTeX-writing code - * Handle boolean values flexibly (yes, no, true, false, etc. as well as 1, 0) -""" + ## Try to rename the process on Linux + try: + import ctypes + libc = ctypes.cdll.LoadLibrary('libc.so.6') + libc.prctl(15, 'make-plots', 0, 0, 0) + except Exception: + pass ## Try to use Psyco optimiser try: @@ -1745,7 +1754,6 @@ except ImportError: pass - ## Find number of (virtual) processing units numcores = os.sysconf('SC_NPROCESSORS_ONLN') if numcores is None: @@ -1753,7 +1761,7 @@ ## Parse command line options from optparse import OptionParser, OptionGroup - parser = OptionParser(usage=msg) + parser = OptionParser(usage=__doc__) parser.add_option("-n", "--num-threads", dest="NUM_THREADS", type="int", default=numcores, help="max number of threads to be used [%s]" % numcores) parser.add_option("--palatino", dest="OUTPUT_FONT", action="store_const", const="PALATINO", default="PALATINO", Modified: trunk/bin/rivet ============================================================================== --- trunk/bin/rivet Mon Jun 21 17:37:46 2010 (r2493) +++ trunk/bin/rivet Mon Jun 21 18:16:34 2010 (r2494) @@ -44,14 +44,6 @@ pass -## Get version from rivet-config -version = "HEAD" -try: - version = commands.getoutput("rivet-config --version") -except: - pass - - ## Description / usage message usage="""Run Rivet analyses on inputted events from file or Unix pipe @@ -85,8 +77,17 @@ pass +## Try importing rivet +try: + import rivet +except Exception, e: + sys.stderr.write(PROGNAME + " requires the 'rivet' Python module\n"); + logging.debug(str(e)) + sys.exit(1) + + ## Parse command line options -parser = OptionParser(usage=usage, version="rivet v%s" % version) +parser = OptionParser(usage=usage, version="rivet v%s" % rivet.version()) parser.add_option("-n", "--nevts", dest="MAXEVTNUM", type="int", default=None, metavar="NUM", help="max number of events to read.") @@ -140,15 +141,6 @@ logging.getLogger().addHandler(h) -## Try importing rivet -try: - import rivet -except Exception, e: - sys.stderr.write(PROGNAME + " requires the 'rivet' Python module\n"); - logging.debug(str(e)) - sys.exit(1) - - ## Control native Rivet library logger for l in opts.NATIVE_LOG_STRS: name, level = None, None @@ -244,13 +236,17 @@ ## Override/modify analysis search path if opts.ANALYSIS_PATH: os.environ["RIVET_ANALYSIS_PATH"] = opts.ANALYSIS_PATH + os.environ["RIVET_REF_PATH"] = opts.ANALYSIS_PATH if opts.ANALYSIS_PATH_APPEND: - anapath = os.environ.get("RIVET_ANALYSIS_PATH", "") - if anapath: - anapath += ":" - anapath += opts.ANALYSIS_PATH_APPEND - os.environ["RIVET_ANALYSIS_PATH"] = anapath + for var in ["RIVET_ANALYSIS_PATH", "RIVET_REF_PATH"]: + anapath = os.environ.get(var, "") + if anapath: + anapath += ":" + anapath += opts.ANALYSIS_PATH_APPEND + os.environ[var] = anapath logging.debug("RIVET_ANALYSIS_PATH = " + os.environ.get("RIVET_ANALYSIS_PATH", "")) +logging.debug("RIVET_REF_PATH = " + os.environ.get("RIVET_REF_PATH", "")) +logging.debug("RIVET_INFO_PATH = " + os.environ.get("RIVET_INFO_PATH", "")) ## List of analyses
More information about the Rivet-svn mailing list |