Skip to content

Commit

Permalink
enhanced 'Mean' attribute on vcs plots
Browse files Browse the repository at this point in the history
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
  • Loading branch information
doutriaux1 committed Feb 10, 2015
1 parent a3d8c80 commit b27aa71
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Packages/vcs/Lib/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from Pdata import *
from types import *
import inspect
import cdutil

## Following for class properties
def _getgen(self,name):
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit b27aa71

Please sign in to comment.