Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xrf implement tests #5

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/data/QNT20220823_A1_2m.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Quantitative Analysis Result
PositionType Application Sample name Date
A-1 Quant analysis SS_SiO2_CIGS_st 20220823_A1_2m 2022- 9- 1 11:01

Component CIGS Cu In Ga Se MoLayer Mo
Analyzed value 2.506 28.413 17.179 5.899 48.509 295.6 100.000
Unit um at% at% at% at% nm mass%

Component TiLayer Ti Na Al Si P S
Analyzed value 155.1 100.000 0.083 0.026 32.000 0.009 0.004
Unit nm mass% mass% mass% mass% mass% mass%

Component Cl K Ca Ti V Cr Mn
Analyzed value 0.007 2.230 0.005 0.016 0.075 14.000 0.622
Unit mass% mass% mass% mass% mass% mass% mass%

Component Fe Co Ni Cu
Analyzed value 50.800 0.039 0.034 0.012
Unit mass% mass% mass% mass%

Component CIGS Cu Ga Se MoLayer TiLayer
Element line In-KA Cu-KA Ga-KA Se-KA Mo-KA Ti-KA
Peak intensity 75.60331 613.75255 153.39145 1416.68603 559.53932 6.48511
BG intensity 8.18314 1.78306 1.97573 3.16844 6.17783 0.15205
Net intensity 67.42017 611.96949 151.41572 1413.51759 553.36149 6.33306
Drift corrected 67.42017 611.96949 151.41572 1413.51759 553.36149 6.33306
Application result 2.506 28.413 5.899 48.509 295.6 155.1

Element line In-KA In-KA In-KA Cu-KA Cu-KA Cu-KA Ga-KA
Peak/BG Peak BG1 BG2 Peak BG1 BG2 Peak
Meas. intensity 75.60331 8.93593 7.32280 613.75255 1.93129 1.58626 153.39145

Element line Ga-KA Ga-KA Se-KA Se-KA Se-KA Mo-KA Mo-KA
Peak/BG BG1 BG2 Peak BG1 BG2 Peak BG1
Meas. intensity 1.94062 2.01084 1416.68603 3.17834 3.15821 559.53932 6.62328

Element line Mo-KA Ti-KA Ti-KA Ti-KA
Peak/BG BG2 Peak BG1 BG2
Meas. intensity 5.53638 6.48511 0.14283 0.15944
____________________________________________________________________________________________________
12 changes: 12 additions & 0 deletions tests/parsers/test_myparser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging

from nomad.datamodel import EntryArchive
from nomad_uibk_plugin.parsers.myparser import MyParser


def test_parse_file():
parser = MyParser()
archive = EntryArchive()
parser.parse('tests/data/example.out', archive, logging.getLogger())

assert archive.results.material.elements == ['H', 'O']
41 changes: 33 additions & 8 deletions tests/parsers/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import logging
import os

from nomad.datamodel import EntryArchive
from nomad_uibk_plugin.parsers.myparser import MyParser
import pytest
from nomad.client import normalize_all, parse


def test_parse_file():
parser = MyParser()
archive = EntryArchive()
parser.parse('tests/data/example.out', archive, logging.getLogger())
@pytest.fixture(params=['QNT20220823_A1_2m.txt'])
def parsed_archive(request):
"""
Sets up a parsed archive and cleans up afterwards.
"""
file_path = os.path.join('tests', 'data', request.param)
archive_from_file = parse(file_path)[0]
measurement = os.path.join(
'tests', 'data', '.'.join(request.param.split('.')[:-1]) + '.archive.json'
)
assert archive_from_file.data.measurement.m_proxy_value == os.path.abspath(
measurement
)
measurement_archive = parse(measurement)[0]

assert archive.results.material.elements == ['H', 'O']
yield measurement_archive

if os.path.exists(measurement):
os.remove(measurement)


def test_normalize_all(parsed_archive):
"""
Tests the normalization of data in the archive.
"""
normalize_all(parsed_archive)

# checks for different parsers
if parsed_archive.data.method == 'X-Ray Fluorescence (XRF)':
# TODO: Add tests specific for XRF method
pass