Beispiel #1
0
 def __iter__(self):
     length = len(self.SYMBOLS)
     for z, symbol in enumerate(self.SYMBOLS, 1):
         prop = ElementSymbol(base.UNATTRIBUTED, Element(z), symbol)
         logger.debug("Parsed: {0}".format(prop))
         self.update(int((z - 1) / length * 100.0))
         yield prop
Beispiel #2
0
    def __iter__(self):
        relative_path = os.path.join("..", "data", "dtsa_subshell.csv")
        content = pkgutil.get_data(__name__, relative_path).decode("utf8")
        reader = csv.reader(content.splitlines())

        # skip first line
        next(reader)

        subshell_data = []
        for row in reader:
            atomic_number = int(row[0])
            # noinspection PyPep8Naming
            energy_eV = float(row[1])
            subshell = str(row[2])

            subshell_data.append([atomic_number, energy_eV, subshell])

        length = len(subshell_data)
        for atomic_number, energy_eV, subshell_dtsa in subshell_data:

            subshell = _SUBSHELL_LOOKUP[subshell_dtsa]
            element = Element(atomic_number)
            prop = AtomicSubshellBindingEnergy(DTSA1992, element, subshell,
                                               energy_eV)
            logger.debug("Parsed: {0}".format(prop))
            self.update(int((atomic_number - 1) / length * 100.0))
            yield prop
Beispiel #3
0
    def __iter__(self):
        relpath = os.path.join("..", "data", "campbell.asc")
        content = pkgutil.get_data(__name__, relpath).decode("utf8")

        shell_width = []
        for line in content.splitlines():
            line = line.strip()
            if not line:
                continue

            z = int(line[0:2])

            for s in range(1, 17):
                s_w = line[6 * s : 6 * s + 6].strip()
                if s_w == "":
                    continue
                shell_width.append([z, subshell_order[s - 1], float(s_w)])

        length = len(shell_width)
        for z, subshell, width in shell_width:
            if width is None:
                continue
            subshell = _SUBSHELL_LOOKUP[subshell]
            element = Element(z)
            prop = AtomicSubshellRadiativeWidth(CAMPBELL2001, element, subshell, width)
            logger.debug("Parsed: {0}".format(prop))
            self.update(int((z - 1) / length * 100.0))
            yield prop
Beispiel #4
0
 def __iter__(self):
     length = len(self.ATOMIC_WEIGHTS)
     for z, aw in enumerate(self.ATOMIC_WEIGHTS, 1):
         if aw is None:
             continue
         element = Element(z)
         prop = ElementAtomicWeight(SARGENT_WELCH, element, aw)
         logger.debug("Parsed: {0}".format(prop))
         self.update(int((z - 1) / length * 100.0))
         yield prop
Beispiel #5
0
 def __iter__(self):
     length = len(self.DENSITIES)
     for z, rho in enumerate(self.DENSITIES, 1):
         if rho is None:
             continue
         element = Element(z)
         prop = ElementMassDensity(SARGENT_WELCH, element, rho * 1000.0)
         logger.debug("Parsed: {0}".format(prop))
         self.update(int((z - 1) / length * 100.0))
         yield prop
Beispiel #6
0
    def __iter__(self):
        relative_path = os.path.join("..", "data", "dtsa_line.csv")
        content = pkgutil.get_data(__name__, relative_path).decode("utf8")
        reader = csv.reader(content.splitlines())

        # skip first line
        next(reader)

        line_data = []
        for row in reader:
            try:
                atomic_number = int(row[0])
                # noinspection PyPep8Naming
                energy_eV = float(row[1])
                fraction = float(row[2])
                line_label = str(row[3])

                line_data.append(
                    [atomic_number, energy_eV, fraction, line_label])
            except ValueError:
                pass

        unparse_lines = set()
        length = 2 * len(line_data)
        for atomic_number, energy_eV, fraction, line_label in line_data:
            try:
                transition = _TRANSITION_LOOKUP[line_label]
            except KeyError:
                #                logger.debug('Line not found: {} for {}'.format(line_label, atomic_number))
                unparse_lines.add(line_label)
                continue

            element = Element(atomic_number)

            prop = XrayTransitionEnergy(DTSA1992, element, transition,
                                        energy_eV)
            #                logger.debug('Parsed: {0}'.format(prop))
            self.update(int((atomic_number - 1) / length * 100.0))
            yield prop

            prop = XrayTransitionRelativeWeight(DTSA1992, element, transition,
                                                fraction)
            #                logger.debug('Parsed: {0}'.format(prop))
            self.update(int((atomic_number - 1) / length * 100.0))
            yield prop

        logger.debug("Lines not found: {}".format(sorted(unparse_lines)))
Beispiel #7
0
    def __iter__(self):
        length = len(self.NAMES_EN)
        for z, name_en in enumerate(self.NAMES_EN, 1):
            element = Element(z)
            language = Language("en")
            prop = ElementName(WIKIPEDIA, element, language, name_en)
            logger.debug("Parsed: {0}".format(prop))
            yield prop

            names = self._find_wikipedia_names(name_en)
            for code, name in names.items():
                if code not in self.LANGUAGES:
                    continue
                language = Language(code)
                prop = ElementName(WIKIPEDIA, element, language, name)
                logger.debug("Parsed: {0}".format(prop))
                yield prop

            self.update(int((z - 1) / length * 100.0))
Beispiel #8
0
    def __iter__(self):
        relpath = os.path.join("..", "data", "nist_element_atomic_weight.html")
        content = pkgutil.get_data(__name__, relpath).decode("utf8")

        current_z = "1"
        value = 0

        atomic_weights = []
        for line in content.splitlines():
            z = re.search(r"Atomic\sNumber\s=\s([0-9]*)", line)
            relative_mass = re.search(
                r"Relative\sAtomic\sMass\s=\s([0-9]*.{0,1}[0-9]*)", line)
            composition = re.search(
                r"Isotopic\sComposition\s=\s([0-9]*.{0,1}[0-9]*)", line)
            if z != None:
                if current_z != z.group(1):
                    current_z = z.group(1)
                    if value == 0:
                        value = None
                    atomic_weights.append(value)
                    value = 0
            elif relative_mass != None:
                if relative_mass.group(1) == "":
                    r_m = 0.0
                else:
                    r_m = float(relative_mass.group(1))
            elif composition != None:
                if composition.group(1) == "":
                    c = 0.0
                else:
                    c = float(composition.group(1))
                value = value + r_m * c

        length = len(atomic_weights)
        for z, aw in enumerate(atomic_weights, 1):
            if aw is None:
                continue
            element = Element(z)
            prop = ElementAtomicWeight(NIST, element, aw)
            logger.debug("Parsed: {0}".format(prop))
            self.update(int((z - 1) / length * 100.0))
            yield prop
Beispiel #9
0
def test_element_symbol(element_symbol, reference):
    assert element_symbol.reference == reference
    assert element_symbol.element == Element(6)
    assert element_symbol.value == "C"
Beispiel #10
0
def element_symbol(reference):
    return ElementSymbol(reference, Element(6), "C")
Beispiel #11
0
def test_element_validate():
    with pytest.raises(ValueError):
        Element(0)

    with pytest.raises(ValueError):
        Element(119)
Beispiel #12
0
def test_element_hash(element):
    assert hash(element) == hash(Element(6))
Beispiel #13
0
def test_element_eq(element):
    assert element == Element(6)
Beispiel #14
0
def element():
    return Element(6)
Beispiel #15
0
def test_element_symbol_validate(reference):
    with pytest.raises(ValueError):
        ElementSymbol(reference, Element(6), "")
        ElementSymbol(reference, Element(6), "CCC")
        ElementSymbol(reference, Element(6), "c")
Beispiel #16
0
 def _extract_element(self, rows):
     return Element(int(rows[0][0:3]))
Beispiel #17
0
def xrayline():
    return XrayLine(Element(118), XrayTransition(2, 0, 1, 1, 0, 1), "a", "b",
                    0.1, 0.2, 0.3)