Ignore:
Timestamp:
Jul 19, 2013, 10:35:53 AM (11 years ago)
Author:
aslmd
Message:

UTIL PYTHON. various updates on example + mcd + plot scripts. nothing major.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/ppcompute.py

    r1002 r1007  
    9595           else:
    9696              return np.array(field).sum(axis=axis)
     97
     98## compute mean over bins
     99## author AS
     100def meanbin(y,x,bins):
     101    bins.sort() # sorting is needed for binning
     102    meanvalues = []
     103    for iii in range(len(bins)):
     104        ## GET VALUES OVER RELEVANT INTERVALS
     105        if iii == 0:
     106          ind = x<bins[iii+1] ; ys = y[ind]
     107        elif iii == len(bins)-1:
     108          ind = x>=bins[iii-1] ; ys = y[ind]
     109        else:
     110          ind = x>=bins[iii-1] ; interm = x[ind] ; intermf = y[ind]
     111          ind = interm<bins[iii+1] ; xs = interm[ind] ; ys = intermf[ind]
     112        ## COMPUTE MEAN and TREAT NAN CASE
     113        meanvalues.append(mean(ys))
     114    ## RETURN A NUMPY ARRAY
     115    meanvalues = np.array(meanvalues)
     116    return meanvalues
    97117
    98118################
Note: See TracChangeset for help on using the changeset viewer.