Example #1
0
    def __iter__(self):
        reference = descriptor.Reference("lee1966")
        reference2 = descriptor.Reference("doe2016")
        element = descriptor.Element(118)
        atomic_shell = descriptor.AtomicShell(1)
        transition = descriptor.XrayTransition(L3, K)
        transition2 = descriptor.XrayTransition(L2, K)
        transitionset = descriptor.XrayTransition(2, 1, None, K)
        notation = descriptor.Notation("mock")
        notation_iupac = descriptor.Notation("iupac")
        language = descriptor.Language("en")

        yield property.ElementName(reference, element, language, "Vibranium")
        yield property.ElementSymbol(reference, element, "Vi")
        yield property.ElementAtomicWeight(reference, element, 999.1)
        yield property.ElementAtomicWeight(reference2, element, 111.1)
        yield property.ElementMassDensity(reference, element, 999.2)

        yield property.AtomicShellNotation(reference, atomic_shell, notation,
                                           "a", "b", "c", "d")

        yield property.AtomicSubshellNotation(reference, K, notation, "a", "b",
                                              "c", "d")
        yield property.AtomicSubshellBindingEnergy(reference, element, K, 0.1)
        yield property.AtomicSubshellRadiativeWidth(reference, element, K,
                                                    0.01)
        yield property.AtomicSubshellNonRadiativeWidth(reference, element, K,
                                                       0.001)
        yield property.AtomicSubshellOccupancy(reference, element, K, 1)

        yield property.XrayTransitionNotation(reference, transition, notation,
                                              "a", "b", "c", "d")
        yield property.XrayTransitionNotation(reference, transition,
                                              notation_iupac, "aa", "bb", "cc",
                                              "dd")
        yield property.XrayTransitionEnergy(reference, element, transition,
                                            0.2)
        yield property.XrayTransitionProbability(reference, element,
                                                 transition, 0.02)
        yield property.XrayTransitionRelativeWeight(reference, element,
                                                    transition, 0.002)

        yield property.XrayTransitionNotation(reference, transition2, notation,
                                              "e", "f", "g", "h")
        yield property.XrayTransitionEnergy(reference, element, transition2,
                                            0.4)
        yield property.XrayTransitionProbability(reference, element,
                                                 transition2, 0.04)
        yield property.XrayTransitionRelativeWeight(reference, element,
                                                    transition2, 0.004)

        yield property.XrayTransitionNotation(reference, transitionset,
                                              notation, "i", "j", "k", "l")
        yield property.XrayTransitionEnergy(reference, element, transitionset,
                                            0.6)
        yield property.XrayTransitionProbability(reference, element,
                                                 transitionset, 0.06)
        yield property.XrayTransitionRelativeWeight(reference, element,
                                                    transitionset, 0.006)
Example #2
0
def test_element_xray_transitions(database, element, reference):
    transitions = database.element_xray_transitions(element,
                                                    reference=reference)
    assert len(transitions) == 3

    assert descriptor.XrayTransition(L3, K) in transitions
    assert descriptor.XrayTransition(L2, K) in transitions
    assert descriptor.XrayTransition(2, 1, None, K) in transitions
Example #3
0
    def xray_transition(self, xray_transition):
        table = self.require_table(descriptor.XrayTransition)

        builder = StatementBuilder()
        builder.add_column(table.c["source_principal_quantum_number"])
        builder.add_column(table.c["source_azimuthal_quantum_number"])
        builder.add_column(table.c["source_total_angular_momentum_nominator"])
        builder.add_column(table.c["destination_principal_quantum_number"])
        builder.add_column(table.c["destination_azimuthal_quantum_number"])
        builder.add_column(table.c["destination_total_angular_momentum_nominator"])
        self._update_xray_transition(builder, table, xray_transition, "id")

        src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n = self._execute(builder)
        return descriptor.XrayTransition(src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n)
Example #4
0
def test_epq_xraytransition_notation(database, testdatadir):
    filepath = os.path.join(testdatadir, "epq_xraytransition.csv")
    with open(filepath, "r") as fp:
        reader = csv.DictReader(fp)

        for row in reader:
            source = database.atomic_subshell(row["source"])
            destination = database.atomic_subshell(row["destination"])
            transition = descriptor.XrayTransition(source, destination)

            expected = ast.literal_eval('"' + row["notation"] + '"')
            expected = expected.replace("p", "\u2032")

            try:
                actual = database.xray_transition_notation(transition, "siegbahn")
            except NotFound:
                continue

            actual = actual.strip("I")

            assert actual == expected
Example #5
0
    def element_xray_transition(self, element, xray_transition, reference=None):
        table_xray = self.require_table(descriptor.XrayTransition)
        table_probability = self.require_table(property.XrayTransitionProbability)

        builder = StatementBuilder()
        builder.add_column(table_xray.c["source_principal_quantum_number"])
        builder.add_column(table_xray.c["source_azimuthal_quantum_number"])
        builder.add_column(table_xray.c["source_total_angular_momentum_nominator"])
        builder.add_column(table_xray.c["destination_principal_quantum_number"])
        builder.add_column(table_xray.c["destination_azimuthal_quantum_number"])
        builder.add_column(table_xray.c["destination_total_angular_momentum_nominator"])
        builder.add_join(
            table_probability,
            table_xray,
            table_probability.c["xray_transition_id"] == table_xray.c["id"],
        )
        builder.add_clause(table_probability.c["value"] > 0.0)
        self._update_xray_transition(builder, table_xray, xray_transition, "id")
        self._update_element(builder, table_probability, element)
        self._update_reference(builder, table_probability, reference)

        src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n = self._execute(builder)
        return descriptor.XrayTransition(src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n)
Example #6
0
    def element_xray_transitions(self, element, xray_transition=None, reference=None):
        table_xray = self.require_table(descriptor.XrayTransition)
        table_probability = self.require_table(property.XrayTransitionProbability)

        builder = StatementBuilder()
        builder.add_column(table_xray.c["source_principal_quantum_number"])
        builder.add_column(table_xray.c["source_azimuthal_quantum_number"])
        builder.add_column(table_xray.c["source_total_angular_momentum_nominator"])
        builder.add_column(table_xray.c["destination_principal_quantum_number"])
        builder.add_column(table_xray.c["destination_azimuthal_quantum_number"])
        builder.add_column(table_xray.c["destination_total_angular_momentum_nominator"])
        builder.add_join(
            table_probability,
            table_xray,
            table_probability.c["xray_transition_id"] == table_xray.c["id"],
        )
        builder.add_clause(table_probability.c["value"] > 0.0)
        self._update_element(builder, table_probability, element)
        self._update_reference(builder, table_probability, reference)
        if xray_transition is not None:
            self._update_xray_transition(
                builder, table_probability, xray_transition, search=True
            )

        transitions = []
        try:
            for src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n in self._execute_many(
                builder
            ):
                transition = descriptor.XrayTransition(
                    src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n
                )
                transitions.append(transition)
        except NotFound:
            logger.info("No transition found for {}".format(element))

        if len(transitions) == 0:
            table_relative_weight = self.require_table(
                property.XrayTransitionRelativeWeight
            )
            builder = StatementBuilder()
            builder.add_column(table_xray.c["source_principal_quantum_number"])
            builder.add_column(table_xray.c["source_azimuthal_quantum_number"])
            builder.add_column(table_xray.c["source_total_angular_momentum_nominator"])
            builder.add_column(table_xray.c["destination_principal_quantum_number"])
            builder.add_column(table_xray.c["destination_azimuthal_quantum_number"])
            builder.add_column(
                table_xray.c["destination_total_angular_momentum_nominator"]
            )
            builder.add_join(
                table_relative_weight,
                table_xray,
                table_relative_weight.c["xray_transition_id"] == table_xray.c["id"],
            )
            builder.add_clause(table_relative_weight.c["value"] > 0.0)
            self._update_element(builder, table_relative_weight, element)
            self._update_reference(builder, table_relative_weight, reference)
            if xray_transition is not None:
                self._update_xray_transition(
                    builder, table_relative_weight, xray_transition, search=True
                )

            transitions = []
            try:
                for src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n in self._execute_many(
                    builder
                ):
                    transition = descriptor.XrayTransition(
                        src_n, src_l, src_j_n, dst_n, dst_l, dst_j_n
                    )
                    transitions.append(transition)
            except NotFound:
                logger.info("No transition found for {}".format(element))

        if len(transitions) == 0:
            raise NotFound

        return tuple(transitions)
Example #7
0
def test_xray_transition_notation(database, encoding, expected):
    xray_transition = descriptor.XrayTransition(L3, K)
    assert (database.xray_transition_notation(xray_transition, "mock",
                                              encoding) == expected)
Example #8
0
def test_xray_transition(database, xray_transition):
    assert database.xray_transition(
        xray_transition) == descriptor.XrayTransition(L3, K)
Example #9
0
def test_element_xray_transition(database):
    transition = database.element_xray_transition(118, "a")
    assert transition == descriptor.XrayTransition(L3, K)
Example #10
0
@pytest.mark.parametrize("element,reference", [(118, None), (118, "lee1966")])
def test_element_xray_transitions(database, element, reference):
    transitions = database.element_xray_transitions(element,
                                                    reference=reference)
    assert len(transitions) == 3

    assert descriptor.XrayTransition(L3, K) in transitions
    assert descriptor.XrayTransition(L2, K) in transitions
    assert descriptor.XrayTransition(2, 1, None, K) in transitions


@pytest.mark.parametrize(
    "xray_transition,expected",
    [
        (descriptor.XrayTransition(L3, K), 1),
        (descriptor.XrayTransition(2, 1, None, K), 2),
    ],
)
def test_element_xray_transitions_with_xray_transition(database,
                                                       xray_transition,
                                                       expected):
    transitions = database.element_xray_transitions(118, xray_transition)
    assert len(transitions) == expected


@pytest.mark.parametrize("element, expected", [
    (13, 14),
    (6, 2),
    (5, 3),
    (4, 3),