Skip to content

Commit f78b713

Browse files
authored
Merge pull request #41 from tomography/noise
API: Update noise model in `Probe.measure`.
2 parents c8f7c27 + 109c5ee commit f78b713

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

xdesign/acquisition.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,21 @@ def translate(self, dx):
129129
self.p1 += vec
130130
self.p2 += vec
131131

132-
def measure(self, phantom, noise=False):
133-
"""Return the probe measurement given phantom. When noise is > 0,
134-
poisson noise is added to the returned measurement."""
132+
def measure(self, phantom, sigma=0):
133+
"""Return the probe measurement with optional Gaussian noise.
134+
135+
Parameters
136+
----------
137+
sigma : float >= 0
138+
The standard deviation of the normally distributed noise.
139+
"""
135140
newdata = 0
136141
for m in range(phantom.population):
137142
# print("%s Measure feature %i" % (str(self), m))
138143
newdata += (beamintersect(self, phantom.feature[m].geometry) *
139144
phantom.feature[m].mass_atten)
140-
if noise > 0:
141-
newdata += newdata * noise * np.random.poisson(1)
145+
if sigma > 0:
146+
newdata += newdata * np.random.normal(scale=sigma)
142147
self.record()
143148
return newdata
144149

0 commit comments

Comments
 (0)