def setUp(self): super().setUp() det = PhotonDetector('det', math.radians(40.0)) self.a = PhotonIntensityAnalysis(det) self.options = self.create_basic_options()
def _create_standard_options(self, options): builder = OptionsBuilder() builder.add_program(options.program) beam = GaussianBeam(energy_eV=options.beam.energy_eV, diameter_m=0.0, particle=options.beam.particle) builder.add_beam(beam) for material in options.sample.materials: for z in material.composition: standard = self.get_standard_material(z) builder.add_sample(SubstrateSample(standard)) for limit in options.limits: builder.add_limit(options.program, limit) for model in options.models: builder.add_model(options.program, model) analysis = PhotonIntensityAnalysis(self.photon_detector) builder.add_analysis(analysis) return builder.build()
def testconvert(self): handler = GeneratedPhotonIntensityResultSeriesHandler() analysis = PhotonIntensityAnalysis(self.create_basic_photondetector()) b = GeneratedPhotonIntensityResultBuilder(analysis) b.add_intensity((29, 'Ka1'), 10.0, 0.1) b.add_intensity((29, 'Ka2'), 20.0, 0.2) b.add_intensity((29, 'Kb1'), 40.0, 0.5) result = b.build() s = handler.convert(result) self.assertEqual(6, len(s))
class TestPhotonIntensityAnalysis(TestCase): def setUp(self): super().setUp() det = PhotonDetector('det', math.radians(40.0)) self.a = PhotonIntensityAnalysis(det) self.options = self.create_basic_options() def testapply(self): list_options = self.a.apply(self.options) self.assertEqual(0, len(list_options)) def testcalculate(self): simulation = self.create_basic_simulation() result = simulation.find_result(EmittedPhotonIntensityResult)[0] self.assertEqual(7, len(result)) newresult = self.a.calculate(simulation, [simulation]) self.assertTrue(newresult) self.assertEqual(10, len(result)) q = result[(29, 'Ka')] self.assertAlmostEqual(3.0, q.n, 4) self.assertAlmostEqual(0.2236, q.s, 4) q = result[(29, 'Kb')] self.assertAlmostEqual(10.5, q.n, 4) self.assertAlmostEqual(0.8718, q.s, 4) q = result[(29, 'K')] self.assertAlmostEqual(13.5, q.n, 4) self.assertAlmostEqual(0.9, q.s, 4) newresult = self.a.calculate(simulation, [simulation]) self.assertFalse(newresult) # Just to make sure newresult = self.a.calculate(simulation, [simulation]) self.assertFalse(newresult)
def apply(self, options): analysis = PhotonIntensityAnalysis(self.photon_detector) # Add photon analysis to options if missing if analysis not in options.analyses: options.analyses.append(analysis) # Construct standard options standard_options = self._create_standard_options(options) return super().apply(options) + standard_options
def testconvert_parse(self): handler = GeneratedPhotonIntensityResultHDF5Handler() analysis = PhotonIntensityAnalysis(self.create_basic_photondetector()) b = GeneratedPhotonIntensityResultBuilder(analysis) b.add_intensity((29, 'Ka1'), 10.0, 0.1) b.add_intensity((29, 'Ka2'), 20.0, 0.2) b.add_intensity((29, 'Kb1'), 40.0, 0.5) result = b.build() result2 = self.convert_parse_hdf5handler(handler, result) self.assertEqual(len(result), len(result2)) self.assertSetEqual(set(result.keys()), set(result2.keys()))
def setUp(self): super().setUp() detector = PhotonDetector(1.1, 2.2) analysis = PhotonIntensityAnalysis(detector) b = EmittedPhotonIntensityResultBuilder(analysis) b.add_intensity((13, 'Ka1'), 1.0, 0.1) b.add_intensity((13, 'Ka2'), 2.0, 0.2) b.add_intensity((13, 'Kb1'), 4.0, 0.5) b.add_intensity((13, 'Kb3'), 5.0, 0.7) b.add_intensity((13, 'Ll'), 3.0, 0.1) self.r = b.build()
def _create_standard_options(self, options): builder = OptionsBuilder(tags=[TAG_STANDARD]) program = copy.copy(options.program) builder.add_program(program) beam = PencilBeam(energy_eV=options.beam.energy_eV, particle=options.beam.particle) builder.add_beam(beam) for material in options.sample.materials: for z in material.composition: standard = self.get_standard_material(z) builder.add_sample(SubstrateSample(standard)) analysis = PhotonIntensityAnalysis(self.photon_detector) builder.add_analysis(analysis) return builder.build()
def testconvert_parse(self): handler = PhotonIntensityAnalysisHDF5Handler() detector = self.create_basic_photondetector() analysis = PhotonIntensityAnalysis(detector) analysis2 = self.convert_parse_hdf5handler(handler, analysis) self.assertEqual(analysis2, analysis)
def analysis(detector): return PhotonIntensityAnalysis(detector)
def testconvert(self): handler = PhotonIntensityAnalysisSeriesHandler() detector = self.create_basic_photondetector() analysis = PhotonIntensityAnalysis(detector) s = handler.convert(analysis) self.assertEqual(0, len(s))
def create_analysis(): detector = PhotonDetector(name='detector_1', elevation_rad=math.radians(40)) photon_analysis = PhotonIntensityAnalysis(detector) return photon_analysis
def setUp(self): super().setUp() detector = PhotonDetector(1.1, 2.2) analysis = PhotonIntensityAnalysis(detector) self.b = EmittedPhotonIntensityResultBuilder(analysis)
def testconvert(self): handler = PhotonIntensityAnalysisHtmlHandler() detector = self.create_basic_photondetector() analysis = PhotonIntensityAnalysis(detector) root = handler.convert(analysis) self.assertEqual(1, len(root.children))