def setUp(self): TestCase.setUp(self) self.tmpdir = tempfile.mkdtemp() self.c = Converter() self.e = Exporter()
class TestPenelopeExporter(TestCase): def setUp(self): TestCase.setUp(self) self.tmpdir = tempfile.mkdtemp() self.c = Converter() self.e = Exporter() def tearDown(self): TestCase.tearDown(self) shutil.rmtree(self.tmpdir, ignore_errors=True) def testexport(self): # Create ops = Options(name='test1') ops.beam.energy_eV = 30e3 ops.geometry.body.material = PenelopeMaterial.pure(29) ops.detectors['x-ray'] = \ PhotonIntensityDetector((radians(35), radians(45)), (0, radians(360.0))) ops.detectors['spectrum'] = \ PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)), 500, (0, 1000)) ops.detectors['prz'] = \ PhotonDepthDetector((radians(0), radians(90)), (0, radians(360.0)), 500) ops.limits.add(TimeLimit(100)) ops.limits.add( UncertaintyLimit(Transition(29, siegbahn='Ka1'), 'x-ray', 0.05)) # Export opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def test_append_photon_detectors_maxlimit(self): ops = Options() ops.limits.add(TimeLimit(100)) for i in range(MAX_PHOTON_DETECTORS + 1): ops.detectors['det%i' % i] = \ PhotonSpectrumDetector((radians(i), radians(45)), (0, radians(360.0)), 500, (0, 1000)) opss = self.c.convert(ops) self.assertRaises(ExporterException, self.e.export, opss[0], self.tmpdir) def test_append_photon_detectors_maxchannels(self): ops = Options() ops.limits.add(TimeLimit(100)) ops.detectors['spectrum'] = \ PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)), 50000, (0, 1000)) opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def test_photon_depth_detector(self): # Create ops = Options(name='test1') ops.beam.energy_eV = 30e3 ops.geometry.body.material = PenelopeMaterial.pure(29) ops.detectors['prz'] = \ PhotonDepthDetector((radians(0), radians(90)), (0, radians(360.0)), 500, [Transition(29, siegbahn='Ka1')]) ops.limits.add(TimeLimit(100)) # Export opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def testinteraction_forcing(self): ops = Options() ops.beam.energy_eV = 30e3 intfor = InteractionForcing(ELECTRON, HARD_ELASTIC, -40) ops.geometry.material = PenelopeMaterial.pure( 29, interaction_forcings=[intfor]) ops.detectors['det1'] = TimeDetector() ops.limits.add(TimeLimit(100)) opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir)
class TestPenelopeExporter(TestCase): def setUp(self): TestCase.setUp(self) self.tmpdir = tempfile.mkdtemp() self.c = Converter() self.e = Exporter() def tearDown(self): TestCase.tearDown(self) shutil.rmtree(self.tmpdir, ignore_errors=True) def testexport(self): # Create ops = Options(name='test1') ops.beam.energy_eV = 30e3 ops.geometry.body.material = PenelopeMaterial.pure(29) ops.detectors['x-ray'] = \ PhotonIntensityDetector((radians(35), radians(45)), (0, radians(360.0))) ops.detectors['spectrum'] = \ PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)), 500, (0, 1000)) ops.detectors['prz'] = \ PhotonDepthDetector((radians(0), radians(90)), (0, radians(360.0)), 500) ops.limits.add(TimeLimit(100)) ops.limits.add(UncertaintyLimit(Transition(29, siegbahn='Ka1'), 'x-ray', 0.05)) # Export opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def test_append_photon_detectors_maxlimit(self): ops = Options() ops.limits.add(TimeLimit(100)) for i in range(MAX_PHOTON_DETECTORS + 1): ops.detectors['det%i' % i] = \ PhotonSpectrumDetector((radians(i), radians(45)), (0, radians(360.0)), 500, (0, 1000)) opss = self.c.convert(ops) self.assertRaises(ExporterException, self.e.export, opss[0], self.tmpdir) def test_append_photon_detectors_maxchannels(self): ops = Options() ops.limits.add(TimeLimit(100)) ops.detectors['spectrum'] = \ PhotonSpectrumDetector((radians(35), radians(45)), (0, radians(360.0)), 50000, (0, 1000)) opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def test_photon_depth_detector(self): # Create ops = Options(name='test1') ops.beam.energy_eV = 30e3 ops.geometry.body.material = PenelopeMaterial.pure(29) ops.detectors['prz'] = \ PhotonDepthDetector((radians(0), radians(90)), (0, radians(360.0)), 500, [Transition(29, siegbahn='Ka1')]) ops.limits.add(TimeLimit(100)) # Export opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir) def testinteraction_forcing(self): ops = Options() ops.beam.energy_eV = 30e3 intfor = InteractionForcing(ELECTRON, HARD_ELASTIC, -40) ops.geometry.material = PenelopeMaterial.pure(29, interaction_forcings=[intfor]) ops.detectors['det1'] = TimeDetector() ops.limits.add(TimeLimit(100)) opss = self.c.convert(ops) self.e.export(opss[0], self.tmpdir)