Skip to content

Commit

Permalink
Fix ExamplePeakFunction & test. Refs #970
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Apr 19, 2013
1 parent ef94fe0 commit d28ca82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def setFwhm(self, new_fwhm):
"""
Called by an external entity, probably a GUI, in response to a user guessing
the height.
"""
sigma = new_fwhm/(2.0*math.sqrt(2.0*math.log(2.0)))
self.setParameter("Sigma",sigma)
"""

# Required to have Mantid recognise the new function
FunctionFactory.subscribe(ExamplePeakFunction)
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ def PyExec(self):
import math
import random
nbins=1000
wspace = WorkspaceFactory.create("Workspace2D",NVectors=1,XLength=nbins+1,YLength=nbins)
wspace = WorkspaceFactory.create("Workspace2D",NVectors=1,XLength=nbins,YLength=nbins)
height = self.getProperty("Height").value
centre = self.getProperty("Centre").value
sigma_sq = math.pow(self.getProperty("Sigma").value,2)
# Noise parameter
amplitude = 0.1*height

prog_reporter = Progress(self,start=0.0,end=1.0,nreports=nbins)
for i in range(1,nbins + 1):
for i in range(1,nbins):
x_value = 5.0 + 5.5*i;
nominal_y = height * math.exp(-0.5*math.pow(x_value - centre, 2.)/sigma_sq)
# add some noise
nominal_y += random.random()*amplitude

wspace.dataX(0)[i-1] = x_value
wspace.dataY(0)[i-1] = nominal_y
wspace.dataE(0)[i-1] = 1
wspace.dataX(0)[i] = x_value
wspace.dataY(0)[i] = nominal_y
wspace.dataE(0)[i] = 1
prog_reporter.report("Setting %dth bin in workspace" % (i-1))

self.setProperty("OutputWorkspace", wspace) # Stores the workspace as the given name
Expand Down

0 comments on commit d28ca82

Please sign in to comment.