Skip to content

Commit b27aa71

Browse files
committed
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
1 parent a3d8c80 commit b27aa71

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Packages/vcs/Lib/template.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from Pdata import *
3535
from types import *
3636
import inspect
37+
import cdutil
3738

3839
## Following for class properties
3940
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):
12391240
tt.string='Max %g' % smx
12401241
elif s=='mean':
12411242
if not inspect.ismethod(getattr(slab,'mean')):
1242-
tt.string='Mean '+str(getattr(slab,s))
1243+
meanstring='Mean '+str(getattr(slab,s))
12431244
else:
1244-
tt.string='Mean %f'%slab.mean()
1245+
try:
1246+
#slices = [slice(0,1),] * (slab.ndim -2 )
1247+
meanstring='Mean %.4g'% float(cdutil.averager(slab,
1248+
axis = " ".join(["(%s)" % S for S in slab.getAxisIds()])))
1249+
except Exception,err:
1250+
meanstring='Mean %.4g'%slab.mean()
1251+
tt.string=meanstring
1252+
print tt.list()
12451253
else :
12461254
tt.string=str(getattr(slab,s))
12471255
tt.x=[sub.x]

0 commit comments

Comments
 (0)