Skip to content

Commit

Permalink
Various bug fixes, delete template schema and parser
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianschoeppach committed Dec 2, 2024
1 parent afa09e0 commit c988e1f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 133 deletions.
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ package-dir = { "" = "src" }
where = ["src"]

[project.entry-points.'nomad.plugin']
myparser = "nomad_uibk_plugin.parsers:myparser"
mypackage = "nomad_uibk_plugin.schema_packages:mypackage"
microcellschema = "nomad_uibk_plugin.schema_packages:microcellschema"
# schema
xrfschema = "nomad_uibk_plugin.schema_packages:xrfschema"
xrfparser = "nomad_uibk_plugin.parsers:xrfparser"
sputtering = "nomad_uibk_plugin.schema_packages:sputtering"
sample = "nomad_uibk_plugin.schema_packages:sample"
# parser
xrfparser = "nomad_uibk_plugin.parsers:xrfparser"
21 changes: 2 additions & 19 deletions src/nomad_uibk_plugin/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
from nomad.config.models.plugins import ParserEntryPoint
from pydantic import Field


class MyParserEntryPoint(ParserEntryPoint):
parameter: int = Field(0, description='Custom configuration parameter')

def load(self):
from nomad_uibk_plugin.parsers.myparser import MyParser

return MyParser(**self.dict())


myparser = MyParserEntryPoint(
name='MyParser',
description='Parser defined using the new plugin mechanism.',
mainfile_name_re='.*\.myparser',
)


class XRFParserEntryPoint(ParserEntryPoint):
Expand All @@ -33,6 +16,6 @@ def load(self):
xrfparser = XRFParserEntryPoint(
name='XRFParser',
description='XRF Parser for UIBK .txt files.',
mainfile_name_re='.*\.txt',
mainfile_content_re='PositionType\s+Application\s+Sample\s+name\s+Date\s+\n[A-Z0-9-]+\s+Quant\s+analysis',
mainfile_name_re=r'.*\.txt',
mainfile_content_re=r'PositionType\s+Application\s+Sample\s+name\s+Date\s+\n[A-Z0-9-]+\s+Quant\s+analysis',
)
31 changes: 0 additions & 31 deletions src/nomad_uibk_plugin/parsers/myparser.py

This file was deleted.

26 changes: 14 additions & 12 deletions src/nomad_uibk_plugin/schema_packages/XRFreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@


def group_composition_into_layers(
layers: dict = {},
names: list = [],
values: list = [],
units: list = [],
logger: 'BoundLogger' = None,
) -> dict:
layers: dict = {},
names: list = [],
values: list = [],
units: list = [],
logger: 'BoundLogger' = None,
) -> dict:
"""
Function for grouping the composition data into layers.
Expand Down Expand Up @@ -69,16 +69,15 @@ def group_composition_into_layers(
if unit == 'mass%':
layers[current_layer]['elements'][name] = dict(mass_fraction=value)
elif unit == 'at%':
layers[current_layer]['elements'][name] = dict(
atomic_fraction=value
)
layers[current_layer]['elements'][name] = dict(atomic_fraction=value)
elif logger is not None:
logger.warn(
'read_UIBK_txt found unknown unit "{unit}" '
'in file: "{file_path}"'
)
return layers


def sort_intensity_values_into_layers( # noqa: PLR0913
layers: dict = {},
int_peak_elements: list = [],
Expand Down Expand Up @@ -133,6 +132,7 @@ def sort_intensity_values_into_layers( # noqa: PLR0913

return layers


def read_xrf_txt(file_path: str, logger: 'BoundLogger' = None) -> dict[str, Any]: # noqa: PLR0915, PLR0912
"""
Function for reading the X-ray fluorescence data in a UIBK `.txt` file.
Expand All @@ -156,9 +156,11 @@ def read_xrf_txt(file_path: str, logger: 'BoundLogger' = None) -> dict[str, Any]
if len(measurement) > 100: # noqa: PLR2004
# Try to match meta information
meta_match = re.search(
(r'PositionType\s+Application\s+Sample name\s+Date\s+(\S+)\s+'
r'Quant analysis\s+(\S+(?:\s\S+)*)\s+(\S+)\s+'
r'(\d{4}-\s*\d{1,2}-\s*\d{1,2}\s+\d{1,2}:\d{2})'),
(
r'PositionType\s+Application\s+Sample name\s+Date\s+(\S+)\s+'
r'Quant analysis\s+(\S+(?:\s\S+)*)\s+(\S+)\s+'
r'(\d{4}-\s*\d{1,2}-\s*\d{1,2}\s+\d{1,2}:\d{2})'
),
measurement,
)

Expand Down
31 changes: 8 additions & 23 deletions src/nomad_uibk_plugin/schema_packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ class UIBKCategory(EntryDataCategory):
m_def = Category(label='UIBK', categories=[EntryDataCategory])


class MySchemaPackageEntryPoint(SchemaPackageEntryPoint):
parameter: int = Field(0, description='Custom configuration parameter')

def load(self):
from nomad_uibk_plugin.schema_packages.mypackage import m_package

return m_package


mypackage = MySchemaPackageEntryPoint(
name='MyPackage',
description='Schema package defined using the new plugin mechanism.',
)


class XRFSchemaPackageEntryPoint(SchemaPackageEntryPoint):
parameter: int = Field(0, description='Custom configuration parameter')

Expand Down Expand Up @@ -55,17 +40,17 @@ def load(self):
)


class MicroCellSchemaPackageEntryPoint(SchemaPackageEntryPoint):
def load(self):
from nomad_uibk_plugin.schema_packages.microcellschema import m_package
# class MicroCellSchemaPackageEntryPoint(SchemaPackageEntryPoint):
# def load(self):
# from nomad_uibk_plugin.schema_packages.microcellschema import m_package

return m_package
# return m_package


microcellschema = MicroCellSchemaPackageEntryPoint(
name='MicroCellSchema',
description='MicroCell Schema package defined using the new plugin mechanism.',
)
# microcellschema = MicroCellSchemaPackageEntryPoint(
# name='MicroCellSchema',
# description='MicroCell Schema package defined using the new plugin mechanism.',
# )


class SampleSchemaPackageEntryPoint(SchemaPackageEntryPoint):
Expand Down
38 changes: 0 additions & 38 deletions src/nomad_uibk_plugin/schema_packages/mypackage.py

This file was deleted.

8 changes: 6 additions & 2 deletions src/nomad_uibk_plugin/schema_packages/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
CompositeSystem, # CompositeSystemReference
)
from nomad.datamodel.metainfo.plot import PlotlyFigure, PlotSection
from nomad.metainfo import Quantity, Section, SubSection
from nomad.metainfo import Quantity, SchemaPackage, Section, SubSection

if TYPE_CHECKING:
from nomad.datamodel.datamodel import EntryArchive
from structlog.stdlib import BoundLogger

from itertools import product

m_package = SchemaPackage(name='nomad_uibk_sample')


class MicroCell(CompositeSystem):
Expand Down Expand Up @@ -130,3 +131,6 @@ def normalize(self, archive, logger):
super().normalize(archive, logger)
self.figures = []
self.plot(archive, logger)


m_package.__init_metainfo__()
16 changes: 12 additions & 4 deletions src/nomad_uibk_plugin/schema_packages/sputtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
# MEnum,
Datetime,
Quantity,
# SectionProxy,
SchemaPackage,
# Package,
Section,
# MSection,
SubSection,
# SectionProxy,
)
from nomad_material_processing.vapor_deposition.pvd.general import PVDSource
from nomad_material_processing.vapor_deposition.pvd.sputtering import SputterDeposition

from nomad_uibk_plugin.schema_packages import UIBKCategory
from nomad_uibk_plugin.schema_packages.sample import UIBKSample

m_package = SchemaPackage(name='nomad_uibk_sputtering')


class Target(PVDSource, EntryData):
"""
Expand Down Expand Up @@ -70,7 +73,9 @@ class Target(PVDSource, EntryData):
)
internal_name = Quantity(
type=str,
description='Common name of the target. Usually the (simplified) elements and ID',
description=(
'Common name of the target. ' 'Usually the (simplified) elements and ID'
),
a_eln=ELNAnnotation(
component=ELNComponentEnum.StringEditQuantity,
),
Expand Down Expand Up @@ -103,7 +108,7 @@ class Target(PVDSource, EntryData):
composition = Quantity(
type=ElementalComposition,
description='Composition of the target as stated by the manufacturer',
#a_eln=ELNAnnotation(component=ELNComponentEnum.element),
# a_eln=ELNAnnotation(component=ELNComponentEnum.element),
repeatable=True,
)
thickness_total = Quantity(
Expand Down Expand Up @@ -316,4 +321,7 @@ class UIBKSputterDeposition(SputterDeposition, EntryData):

target = SubSection(section_def=TargetReference, repeats=True)

parameter = SubSection()
# parameter = SubSection()


m_package.__init_metainfo__()

0 comments on commit c988e1f

Please sign in to comment.