Esempio n. 1
0
 def measure(self, phantom, noise=False):
     """Return the probe measurement given phantom. When noise is > 0,
     poisson noise is added to the returned measurement."""
     newdata = 0
     for m in range(phantom.population):
         newdata += (beamcirc(self, phantom.feature[m]) *
                     phantom.feature[m].mass_atten)
     if noise > 0:
         newdata += newdata * noise * np.random.poisson(1)
     self.record()
     return newdata
Esempio n. 2
0
def test_beamcirc_intersecting_partially_from_bottom_inside_center():
    circ = Circle(Point(0, -0.5), 1)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 2.52740780429, rtol=1e-6)
Esempio n. 3
0
def test_beamcirc_intersecting_partially_from_bottom_outside_center():
    circ = Circle(Point(0, -1.5), 1)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 0.614184849304, rtol=1e-6)
Esempio n. 4
0
def test_beamcirc_nonintersecting_bottom():
    circ = Circle(Point(0, -3), 1)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 0., rtol=1e-6)
Esempio n. 5
0
def test_beamcirc_vertical_intersection():
    circ = Circle(Point(0, 0), 1)
    beam = Beam(Point(-1, -1), Point(1, 1), 1)
    assert_allclose(beamcirc(beam, circ), 1.91322295498, rtol=1e-6)
Esempio n. 6
0
def test_beamcirc_intersecting_fully():
    circ = Circle(Point(0, 0), 1)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 3.14159265359, rtol=1e-6)
Esempio n. 7
0
def test_beamcirc_intersecting_fully_from_bottom_inside_center():
    circ = Circle(Point(0, -0.5), 3)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 11.5955559562, rtol=1e-6)
Esempio n. 8
0
def test_beamcirc_intersecting_fully_from_bottom_outside_center():
    circ = Circle(Point(0, -1.5), 3)
    beam = Beam(Point(-2, 0), Point(2, 0), 2)
    assert_allclose(beamcirc(beam, circ), 10.0257253792, rtol=1e-6)
Esempio n. 9
0
def test_beamcirc_intersecting_fully_from_top_inside_center():
    circ = Circle(Point([0, 0.5]), 3)
    beam = Beam(Point([-2, 0]), Point([2, 0]), 2)
    assert_allclose(beamcirc(beam, circ), 11.5955559562, rtol=1e-6)
Esempio n. 10
0
def test_beamcirc_intersecting_fully_from_top_outside_center():
    circ = Circle(Point([0, 1.5]), 3)
    beam = Beam(Point([-2, 0]), Point([2, 0]), 2)
    assert_allclose(beamcirc(beam, circ), 10.0257253792, rtol=1e-6)
Esempio n. 11
0
def test_beamcirc_intersecting_partially_from_top_inside_center():
    circ = Circle(Point([0, 0.5]), 1)
    beam = Beam(Point([-2, 0]), Point([2, 0]), 2)
    assert_allclose(beamcirc(beam, circ), 2.52740780429, rtol=1e-6)
Esempio n. 12
0
def test_beamcirc_intersecting_partially_from_top_outside_center():
    circ = Circle(Point([0, 1.5]), 1)
    beam = Beam(Point([-2, 0]), Point([2, 0]), 2)
    assert_allclose(beamcirc(beam, circ), 0.614184849304, rtol=1e-6)
Esempio n. 13
0
def test_beamcirc_nonintersecting_top():
    circ = Circle(Point([0, 3]), 1)
    beam = Beam(Point([-2, 0]), Point([2, 0]), 2)
    assert_allclose(beamcirc(beam, circ), 0., rtol=1e-6)