Skip to content

Commit

Permalink
Merge pull request #1028 from UV-CDAT/issue_1024_vcs_mean_use_cdutil_…
Browse files Browse the repository at this point in the history
…averager

enhanced 'Mean' attribute on vcs plots
  • Loading branch information
painter1 committed Feb 11, 2015
2 parents 7b363f4 + 3ed2771 commit e85c16f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 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,15 @@ 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
else :
tt.string=str(getattr(slab,s))
tt.x=[sub.x]
Expand Down

0 comments on commit e85c16f

Please sign in to comment.