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

Dev micha #142

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions HZB_Unold_Lab_plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[build-system]
requires = [ "setuptools>=61.0.0",]
build-backend = "setuptools.build_meta"

[project]
name = "hzb-unold-lab"
version = "0.0.2"
description = "A plugin for NOMAD"
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: Apache Software License",
]
dependencies = [
"nomad-lab>=1.2.1",
"nomad-material-processing>=0.0.7",
"nomad-hzb-baseclasses>=0.0.1",
]
[project.optional-dependencies]
dev = [
"pytest",
"structlog>=22.3.0",
]

[project.license]
file = "LICENSE"

[tool.setuptools.packages.find]
where = [ "src",]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .schema import *
from .parser import *
from .parser import *
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
description: This is a plugin schema generated from a yaml schema.
name: parsers/hzb_unold_lab
plugin_type: parser
mainfile_name_re: ^.*hzb-unold-lab_pvdp.*\.(t|c)sv$
mainfile_name_re: ^.*(spx.(xlsx|csv)|cond.csv|(reflection|transmission)_spec.csv|pvdp.*\.(t|c)sv)$
mainfile_mime_re: '(application|text)/.*'
parser_class_name: hzb_unold_lab.PVDPParser
code_name: HZB Unold Lab Parser

98 changes: 98 additions & 0 deletions HZB_Unold_Lab_plugin/src/hzb_unold_lab/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import datetime


from nomad.datamodel import EntryArchive
from nomad.metainfo import (
Quantity,
)
from nomad.parsing import MatchingParser
from nomad.datamodel.metainfo.annotations import (
ELNAnnotation,
)
from nomad.datamodel.data import (
EntryData,
)

from nomad.datamodel.metainfo.basesections import (
Activity,
)


from nomad_material_processing.utils import create_archive
from baseclasses.helper.utilities import set_sample_reference
from hzb_unold_lab.schema import (
UnoldThermalEvaporation,
Unold_XRF_Measurement_Library,
Unold_UVvis_Reflection_Measurement_Library,
Unold_UVvis_Transmission_Measurement_Library,
Unold_PL_Measurement_Library,
Unold_Conductivity_Measurement_Library,
)


class ParsedFile(EntryData):
activity = Quantity(
type=Activity,
a_eln=ELNAnnotation(
component="ReferenceEditQuantity",
),
)


class PVDPParser(MatchingParser):
def __init__(self):
super().__init__(
name="parsers/hzb_unold_lab",
code_name="HZB Unold Lab Parser",
code_homepage="https://github.com/FAIRmat-NFDI/AreaA-data_modeling_and_schemas",
supported_compressions=["gz", "bz2", "xz"],
)

def parse(self, mainfile: str, archive: EntryArchive, logger) -> None:
entry = None
file = mainfile.split("/")[-1]

if "pvdp" in file:
entry = UnoldThermalEvaporation(log_file=file)

if file.endswith("reflection_spec.csv"):
entry = Unold_UVvis_Reflection_Measurement_Library(data_file=file)

if file.endswith("transmission_spec.csv"):
entry = Unold_UVvis_Transmission_Measurement_Library(data_file=file)

if file.endswith("cond.csv"):
entry = Unold_Conductivity_Measurement_Library(data_file=file)

if file.endswith("spx.xlsx") or file.endswith("spx.csv"):
entry = Unold_XRF_Measurement_Library(composition_file=file)
if entry is None:
return

search_id = file.split("#")[0]
set_sample_reference(archive, entry, search_id)

entry.datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
entry.name = f"{search_id}"

file_name = f"{file}.archive.json"
archive.data = ParsedFile(activity=create_archive(entry, archive, file_name))
archive.metadata.entry_name = file
Loading