Adding dynamic y-tick placement and bundling the ChangeLog in the tarball. Release 1.2.2 pyslha-1.2.2

Sun, 13 Mar 2011 12:34:46 +0000

author
Andy Buckley <andy@insectnation.org>
date
Sun, 13 Mar 2011 12:34:46 +0000
changeset 137
0aecd3e7f444
parent 136
1218f20d4cf5
child 138
1dde19f15a09

Adding dynamic y-tick placement and bundling the ChangeLog in the tarball. Release 1.2.2

ChangeLog file | annotate | diff | comparison | revisions
MANIFEST.in file | annotate | diff | comparison | revisions
pyslha.py file | annotate | diff | comparison | revisions
slhaplot file | annotate | diff | comparison | revisions
     1.1 --- a/ChangeLog	Sun Mar 13 11:39:49 2011 +0000
     1.2 +++ b/ChangeLog	Sun Mar 13 12:34:46 2011 +0000
     1.3 @@ -1,3 +1,15 @@
     1.4 +2011-03-13  Andy Buckley  <andy@insectnation.org>
     1.5 +
     1.6 +	* Version 1.2.2: use a more dynamic system for choosing y-tick
     1.7 +	values, to avoid overlaps and too-close tick labels in high-mass
     1.8 +	SUSY models.
     1.9 +
    1.10 +2011-03-10  Andy Buckley  <andy@insectnation.org>
    1.11 +
    1.12 +	* Version 1.2.1: add more semantic and case-insensitive handling
    1.13 +	of format codes, and simultaneously avoid using the any() function
    1.14 +	which requires Python >= 2.5.
    1.15 +
    1.16  2011-02-27  Andy Buckley  <andy@insectnation.org>
    1.17  
    1.18  	* Version 1.2.0 (major version change due to interface changes and
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/MANIFEST.in	Sun Mar 13 12:34:46 2011 +0000
     2.3 @@ -0,0 +1,3 @@
     2.4 +include ChangeLog
     2.5 +include spcfiles/sps1a.spc
     2.6 +include spcfiles/tgm.spc
     3.1 --- a/pyslha.py	Sun Mar 13 11:39:49 2011 +0000
     3.2 +++ b/pyslha.py	Sun Mar 13 12:34:46 2011 +0000
     3.3 @@ -23,7 +23,7 @@
     3.4  """
     3.5  
     3.6  __author__ = "Andy Buckley <andy.buckley@cern.ch"
     3.7 -__version__ = "1.2.1"
     3.8 +__version__ = "1.2.2"
     3.9  
    3.10  
    3.11  def _autotype(var):
     4.1 --- a/slhaplot	Sun Mar 13 11:39:49 2011 +0000
     4.2 +++ b/slhaplot	Sun Mar 13 12:34:46 2011 +0000
     4.3 @@ -14,8 +14,6 @@
     4.4  to the output file format.
     4.5  
     4.6  TODOs:
     4.7 -  * Avoid overlap/too-tight clustering of y-axis ticks. Looks fine for *most*
     4.8 -    spectra I've seen with 100 GeV intervals, but it should be handled properly.
     4.9    * Merge labels if shifting fails (cf. "poi" test spectrum file).
    4.10    * Allow user to provide a file which defines the particle line x-positions, labels, etc.
    4.11    * Allow use of --outname to specify a list of output base names for multiple inputs.
    4.12 @@ -542,7 +540,8 @@
    4.13          ydiff = ASPECTRATIO * XWIDTH
    4.14          ymin = 0.0
    4.15          ymax = ymin + ydiff
    4.16 -        ## Get range of masses needed
    4.17 +
    4.18 +        ## Get range of masses needed (quite application-specific at the moment)
    4.19          maxmass = max(pd.mass for pid, pd in PDETAILS.iteritems())
    4.20          maxdisplaymass = maxmass * 1.1
    4.21          if maxdisplaymass % 100 != 0:
    4.22 @@ -559,13 +558,33 @@
    4.23          out += "  %% Frame\n"
    4.24          out += "  \\draw (%f,%f) rectangle (%f,%f);\n" % (scalex(xmin), ymin, scalex(xmax), ymax)
    4.25          out += "  %% y-ticks\n"
    4.26 -        for mtick in xrange(0, int(maxdisplaymass) + 100, 100):
    4.27 +
    4.28 +        def calc_tick_vals(vmax, vdiff_nominal=100, max_num_ticks=12):
    4.29 +            """Calculate a display-optimised list of values at which tick marks will be drawn.
    4.30 +
    4.31 +            TODO: Generalize:
    4.32 +             1. Scale by powers of 10 to bring smallest tick val into 1-10 range. (Handling 0?)
    4.33 +             2. Calculate ticks vector by incrementing in units of {1, 2, 5}
    4.34 +             3. If #ticks > max (determined by available space on plot, i.e. vdiff_plot),
    4.35 +                multiply increment factor by 10 and goto 2.
    4.36 +            """
    4.37 +            ok = False
    4.38 +            vticks = None
    4.39 +            vdiff_scalefactor = 1
    4.40 +            while not ok:
    4.41 +                vticks = xrange(0, int(vmax)+1, vdiff_nominal*vdiff_scalefactor) # the +1 ensures that vmax is included
    4.42 +                if len(vticks) <= max_num_ticks:
    4.43 +                    ok = True
    4.44 +                vdiff_scalefactor *= 2
    4.45 +            return vticks
    4.46 +
    4.47 +        for mtick in calc_tick_vals(maxdisplaymass):
    4.48              ytick = mtick * yscale
    4.49              out += "  \\draw (%f,%f) node[left] {%d};\n" % (scalex(xmin), ytick, mtick)
    4.50              if mtick > 0 and mtick < maxdisplaymass:
    4.51 -                ## The 0.3 needs to be in the plot coords
    4.52 +                ## The 0.3 needs to be in the (arbitrary) plot coords
    4.53                  out += "  \\draw (%f,%f) -- (%f,%f);\n" % (scalex(xmin+0.3), ytick, scalex(xmin), ytick)
    4.54 -        out += "  \\draw (%f,%f) node[left,rotate=90] {Mass / GeV};\n" % (scalex(xmin-2.0), ymax)
    4.55 +        out += "  \\draw (%f,%f) node[left,rotate=90] {Mass / GeV};\n" % (scalex(xmin-2.2), ymax)
    4.56  
    4.57          ## Decay arrows
    4.58          if DDETAILS:

mercurial