Allow plotting from a string cated from stdin

Tue, 30 Nov 2010 14:55:00 +0000

author
Andy Buckley <andy@insectnation.org>
date
Tue, 30 Nov 2010 14:55:00 +0000
changeset 95
63ae1d5bbe4e
parent 94
77808406c2d0
child 96
6ad4a953db93

Allow plotting from a string cated from stdin

slhaplot file | annotate | diff | comparison | revisions
     1.1 --- a/slhaplot	Tue Nov 30 14:48:47 2010 +0000
     1.2 +++ b/slhaplot	Tue Nov 30 14:55:00 2010 +0000
     1.3 @@ -14,7 +14,6 @@
     1.4  images.
     1.5  
     1.6  TODOs:
     1.7 -  * Allow plotting from a text string to stdin
     1.8    * Allow to set decay arrow color/thickness by branching ratio
     1.9    * Allow user control over aspect ratio
    1.10    * Use proper distinction between physical, plot-logical, and plot output coords
    1.11 @@ -149,6 +148,8 @@
    1.12  if opts.OUTFILE is None:
    1.13      import os
    1.14      o = os.path.basename(opts.INFILE)
    1.15 +    if o == "-":
    1.16 +        o = "out"
    1.17      if "." in o:
    1.18          o = o[:o.rindex(".")]
    1.19      ## Add format-specific suffix
    1.20 @@ -162,11 +163,15 @@
    1.21  
    1.22  ## Read spectrum file
    1.23  BLOCKS, DECAYS = None, None
    1.24 -if opts.INFILE.endswith(".isa"):
    1.25 +if opts.INFILE == "-":
    1.26 +    intext = sys.stdin.read()
    1.27 +    BLOCKS, DECAYS = pyslha.readSLHA(intext)
    1.28 +elif opts.INFILE.endswith(".isa"):
    1.29      BLOCKS, DECAYS = pyslha.readISAWIGFile(opts.INFILE)
    1.30  else:
    1.31      BLOCKS, DECAYS = pyslha.readSLHAFile(opts.INFILE)
    1.32  
    1.33 +
    1.34  ## Set mass values in PDETAILS
    1.35  massblock = BLOCKS["MASS"]
    1.36  for pid in PDETAILS.keys():

mercurial