From b27aa7115c1045db5551a239d9d0feb139e10ed7 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 10 Feb 2015 14:52:11 -0800 Subject: [PATCH 1/2] enhanced 'Mean' attribute on vcs plots fix #1024 use %.4g rather %.f for both prettyness and 'last-digits-may-change-on-some-machnies' reasons use cdutil where possible to produce a better average --- Packages/vcs/Lib/template.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Packages/vcs/Lib/template.py b/Packages/vcs/Lib/template.py index ef46d8dd0e..f9536feaea 100644 --- a/Packages/vcs/Lib/template.py +++ b/Packages/vcs/Lib/template.py @@ -34,6 +34,7 @@ from Pdata import * from types import * import inspect +import cdutil ## Following for class properties def _getgen(self,name): @@ -1239,9 +1240,16 @@ def plot(self,x,slab,gm,bg=0,min=None,max=None,X=None,Y=None,**kargs): tt.string='Max %g' % smx elif s=='mean': if not inspect.ismethod(getattr(slab,'mean')): - tt.string='Mean '+str(getattr(slab,s)) + meanstring='Mean '+str(getattr(slab,s)) else: - tt.string='Mean %f'%slab.mean() + try: + #slices = [slice(0,1),] * (slab.ndim -2 ) + meanstring='Mean %.4g'% float(cdutil.averager(slab, + axis = " ".join(["(%s)" % S for S in slab.getAxisIds()]))) + except Exception,err: + meanstring='Mean %.4g'%slab.mean() + tt.string=meanstring + print tt.list() else : tt.string=str(getattr(slab,s)) tt.x=[sub.x] From 3ed2771637154fc2e8ab3600fd3fd4d28aa06fbf Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 10 Feb 2015 15:55:43 -0800 Subject: [PATCH 2/2] removed debug print spotted by @painter1 --- Packages/vcs/Lib/template.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Packages/vcs/Lib/template.py b/Packages/vcs/Lib/template.py index f9536feaea..fa3553a478 100644 --- a/Packages/vcs/Lib/template.py +++ b/Packages/vcs/Lib/template.py @@ -1249,7 +1249,6 @@ def plot(self,x,slab,gm,bg=0,min=None,max=None,X=None,Y=None,**kargs): except Exception,err: meanstring='Mean %.4g'%slab.mean() tt.string=meanstring - print tt.list() else : tt.string=str(getattr(slab,s)) tt.x=[sub.x]