[yoda-svn] yoda: compressed yodamerge code for Scatter{1, 2, 3}D into one blo...

YODA Mercurial yoda at projects.hepforge.org
Sat Aug 19 01:45:01 BST 2017


details:   https://yoda.hepforge.org/hg/yoda/rev/f399ddd322aa
branches:  release-1-6
changeset: 1367:f399ddd322aa
user:      Louie Corpe <lcorpe at cern.ch>
date:      Fri Aug 18 11:01:25 2017 +0200
description:
compressed yodamerge code for Scatter{1,2,3}D into one block by accessing the relevant axis by number. Also fixed small bug where the errors in the add-mode where the square root of the error was never taken, and so the errors were being saved as squared

diffs (truncated from 189 to 50 lines):

--- a/bin/yodamerge	Wed Aug 16 17:46:53 2017 +0100
+++ b/bin/yodamerge	Fri Aug 18 11:01:25 2017 +0200
@@ -226,158 +226,58 @@
         ## Make a copy of the first object as the basis for merging (suitable for all Scatter types)
         ao_out = aos[0].clone()
         ao_out.rmAnnotation("yodamerge_scale")
-
-
         ## If there's only one object, there's no need to do any combining
         if len(aos) == 1:
             pass
-
-        # TODO: compress code below by using numerical axis access to axis_index = ao_out.dim
-
-        elif aotype is yoda.Scatter1D:
-
+  
+        elif aotype in (yoda.Scatter1D,yoda.Scatter2D,yoda.Scatter3D):
+            
+            ## Retrieve dimensionality of the Scatter*D object
+            dim=ao_out.dim
+            SND_MODE=getattr(opts,"S%dD_MODE" % dim)
+            axis=['','x','y','z']
+            
             ## Use asymptotic mean+stderr convergence statistics
-            if opts.S1D_MODE in ["assume_mean", "add"]:
-
-                msg = "WARNING: Scatter1D %s merge assumes asymptotic statistics and equal run sizes" % p
+            if SND_MODE in ("assume_mean", "add"):
+  
+                msg = "WARNING: Scatter%dD %s merge assumes asymptotic statistics and equal run sizes" % (dim, p)
                 if any(float(ao.annotation("yodamerge_scale")) != 1.0 for ao in aos):
                     msg += " (+ user scaling)"
                 sys.stderr.write(msg + "\n")
-
-                npoints = len(ao_out.points)
-                for i in xrange(npoints):
-                    val_i = ep_i = em_i = scalesum = 0.0
-                    for ao in aos:
-                        scale = float(ao.annotation("yodamerge_scale"))
-                        # print aos[0].path, scale
-                        scalesum += scale
-                        val_i += scale * ao.points[i].x
-                        ep_i += (scale * ao.points[i].xErrs[0])**2
-                        em_i += (scale * ao.points[i].xErrs[1])**2
-                    if opts.S1D_MODE == "assume_mean":
-                        val_i /= scalesum
-                        ep_i = math.sqrt(ep_i) / scalesum
-                        em_i = math.sqrt(em_i) / scalesum
-                    ao_out.points[i].x = val_i


More information about the yoda-svn mailing list