Beispiel #1
0
    def test__ne__(self):
        l = UncertaintyLimit(XrayLine(14, 'Ka1'), self.d, 0.02)
        self.assertNotEqual(l, self.l)

        l = UncertaintyLimit(XrayLine(13, 'La1'), self.d, 0.02)
        self.assertNotEqual(l, self.l)

        l = UncertaintyLimit(XrayLine(13, 'Ka1'), 'detector', 0.02)
        self.assertNotEqual(l, self.l)

        l = UncertaintyLimit(XrayLine(13, 'Ka1'), self.d, 0.03)
        self.assertNotEqual(l, self.l)
Beispiel #2
0
    def test__ne__(self):
        K = pyxray.AtomicSubshell(1, 0, 1)
        L3 = pyxray.AtomicSubshell(2, 1, 3)
        line = pyxray.XrayTransition(L3, K)
        x = XrayLine(pyxray.Element(14), line)
        self.assertNotEqual(x, self.x)

        K = pyxray.AtomicSubshell(1, 0, 1)
        L3 = pyxray.AtomicSubshell(3, 1, 3)
        line = pyxray.XrayTransition(L3, K)
        x = XrayLine(pyxray.Element(13), line)
        self.assertNotEqual(x, self.x)
Beispiel #3
0
 def testvalidate_limit_uncertainty(self):
     xrayline = XrayLine(13, 'Ka1')
     detector = PhotonDetector('det', 1.1, 2.2)
     limit = UncertaintyLimit(xrayline, detector, 0.02)
     limit2 = self.v.validate_limit(limit, self.options)
     self.assertEqual(limit2, limit)
     self.assertIsNot(limit2, limit)
Beispiel #4
0
    def testphoton_range(self):
        material = Material.pure(29)
        xrayline = XrayLine(29, 'Ka1')

        actual = photon_range(20e3,
                              material,
                              xrayline,
                              reference='perkins1991')
        self.assertAlmostEqual(8.42816e-7, actual, 10)
Beispiel #5
0
    def testvalidate_limit_uncertainty_exception(self):
        xrayline = XrayLine(13, 'Ka1')
        detector = PhotonDetector('', float('nan'), -1)
        limit = UncertaintyLimit(xrayline, detector, 0.0)
        self.assertRaises(ValidationError, self.v.validate_limit, limit,
                          self.options)

        errors = set()
        self.v._validate_limit(limit, self.options, errors)
        self.assertEqual(3, len(errors))
Beispiel #6
0
    def calculate(self, simulation, simulations):
        """
        Calculate additional photon intensities for common X-ray transition sets.
        """
        newresult = super().calculate(simulation, simulations)

        for result in simulation.find_result(PhotonIntensityResult):
            zs = set(xrayline.atomic_number for xrayline in result)

            for z in zs:
                possible_transitions = set(pyxray.element_xray_transitions(z))

                for transitionset in COMMON_XRAY_TRANSITION_SETS:
                    # Check if it already exists
                    xrayline = XrayLine(z, transitionset)
                    if xrayline in result:
                        continue

                    # Only add possible transitions for this element
                    transitions = possible_transitions & transitionset.transitions
                    if not transitions:
                        continue

                    subxraylines = []
                    total = 0.0
                    for transition in transitions:
                        subxrayline = XrayLine(z, transition)
                        q = result.get(subxrayline, None)
                        if q is None:
                            break

                        subxraylines.append(subxrayline)
                        total += q

                    if len(subxraylines) != len(transitions):
                        continue

                    result.data[xrayline] = total
                    newresult = True

        return newresult
    def _import_analysis_photonintensity(self, analysis, dirpath, errors,
                                         simdata):
        emitted_builder = EmittedPhotonIntensityResultBuilder(analysis)
        intensities = simdata.get_total_xray_intensities_1_esr()

        for z in intensities:
            for line in intensities[z]:
                if line not in LINE_LOOKUP:
                    continue

                transition = LINE_LOOKUP[line]
                xrayline = XrayLine(z, transition)
                value = intensities[z][line]
                error = 0.0
                emitted_builder.add_intensity(xrayline, value, error)

        return [emitted_builder.build()]
Beispiel #8
0
 def testskeleton(self):
     self.assertEqual(XrayLine(13, 'Ka1'), self.l.xrayline)
     self.assertEqual(self.d, self.l.detector)
     self.assertAlmostEqual(0.02, self.l.uncertainty, 4)
Beispiel #9
0
 def test__hash__(self):
     K = pyxray.AtomicSubshell(1, 0, 1)
     L3 = pyxray.AtomicSubshell(2, 1, 3)
     line = pyxray.XrayTransition(L3, K)
     x = XrayLine(pyxray.Element(13), line)
     self.assertEqual(hash(x), hash(self.x))
Beispiel #10
0
    def setUp(self):
        super().setUp()

        self.x = XrayLine(13, 'Ka1')
 def testconvert(self):
     handler = UncertaintyLimitSeriesHandler()
     detector = self.create_basic_photondetector()
     limit = UncertaintyLimit(XrayLine(13, 'Ka1'), detector, 0.02)
     s = handler.convert(limit)
     self.assertEqual(1, len(s))
Beispiel #12
0
 def _add(self, xrayline, datum):
     xrayline = XrayLine(*xrayline)
     self.data[xrayline] = datum
Beispiel #13
0
 def __getitem__(self, xrayline):
     xrayline = XrayLine(*xrayline)
     return self.data[xrayline]
Beispiel #14
0
 def testconvert(self):
     handler = UncertaintyLimitHtmlHandler()
     detector = self.create_basic_photondetector()
     limit = UncertaintyLimit(XrayLine(13, 'Ka1'), detector, 0.02)
     root = handler.convert(limit)
     self.assertEqual(1, len(root.children))
Beispiel #15
0
 def testconvert_parse_xraytransitionset(self):
     handler = XrayLineHDF5Handler()
     xrayline = XrayLine(29, 'Ka')
     xrayline2 = self.convert_parse_hdf5handler(handler, xrayline)
     self.assertEqual(xrayline2, xrayline)
Beispiel #16
0
    def setUp(self):
        super().setUp()

        self.d = self.create_basic_photondetector()
        self.l = UncertaintyLimit(XrayLine(13, 'Ka1'), self.d, 0.02)
 def testconvert_parse(self):
     handler = UncertaintyLimitHDF5Handler()
     detector = self.create_basic_photondetector()
     limit = UncertaintyLimit(XrayLine(13, 'Ka1'), detector, 0.02)
     limit2 = self.convert_parse_hdf5handler(handler, limit)
     self.assertEqual(limit2, limit)
Beispiel #18
0
 def _validate_limit_uncertainty_xrayline(self, xrayline, options, errors):
     # Notes: No validate is required. Arguments are internally validated.
     return XrayLine(xrayline.element, xrayline.line)
Beispiel #19
0
 def test__eq__(self):
     l = UncertaintyLimit(XrayLine(13, 'Ka1'), self.d, 0.02)
     self.assertEqual(l, self.l)