Skip to content

Commit

Permalink
Refs #8391 Fix bin width counting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Nov 15, 2013
1 parent 7e6fd15 commit 5c5d04f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Code/Mantid/scripts/Inelastic/IndirectBayes.py
Expand Up @@ -19,12 +19,12 @@
import sys, platform, math, os.path, numpy as np
mp = import_mantidplot()

def CalcErange(inWS,ns,erange,nbin):
def CalcErange(inWS,ns,erange,binWidth):
# length of array in Fortran
array_len = 4096

nbin = int(nbin)
bnorm = 1.0/nbin
binWidth = int(binWidth)
bnorm = 1.0/binWidth

# get data from input workspace
N,X,Y,E = GetXYE(inWS,ns,array_len)
Expand All @@ -39,11 +39,11 @@ def CalcErange(inWS,ns,erange,nbin):
xInMax = Xin[-1]

#get indicies either side of energy range
minIndex = np.where(Xdata==xInMin)[0]+1
maxIndex = np.where(Xdata==xInMax)[0]+1
minIndex = np.where(Xdata==xInMin)[0][0]+1
maxIndex = np.where(Xdata==xInMax)[0][0]

#check we're using a valid range
if nbin == 0:
if binWidth == 0:
error = 'Erange - calculated points is Zero'
sys.exit(error)

Expand All @@ -56,15 +56,18 @@ def CalcErange(inWS,ns,erange,nbin):
sys.exit(error)

#reshape array into sublists of bins
Xin = Xin.reshape(len(Xin)/nbin, nbin)
Xin = Xin.reshape(len(Xin)/binWidth, binWidth)

#sum and normalise values in bins
Xout = [sum(bin)*bnorm for bin in Xin]

#pad array for use in Fortran code
Xout = PadArray(Xout,array_len)
#count number of bins
nbins = len(Xout)-1

nout = [nbins, minIndex, maxIndex]

nout = [nbin, minIndex, maxIndex]
#pad array for use in Fortran code
Xout = PadArray(Xout,array_len)

return nout,bnorm,Xout,X,Y,E

Expand Down

0 comments on commit 5c5d04f

Please sign in to comment.