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

Fixes for transmission #18

Merged
merged 17 commits into from
Nov 20, 2024
Merged
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
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ dependencies = [
'nomad-analysis', # develop branch
'lakeshore-nomad-plugin @ git+https://github.com/IKZ-Berlin/lakeshore-nomad-plugin.git@69a6deb3f0e99d7b0dc66714105dd62a56f157e9',
'laytec_epitt_plugin @ git+https://github.com/IKZ-Berlin/laytec_epitt_nomad_plugin.git@f4953ac4ecb55b7003dee323d7d7f473e49ab4e3',
# 'transmission @ git+https://github.com/FAIRmat-NFDI/AreaA-data_modeling_and_schemas.git@de012ac8820dbb514f5dd73aafdf46bf2a879481#subdirectory=transmission/transmission_plugin/uv_vis_nir_transmission_plugin',
'transmission @ git+https://github.com/FAIRmat-NFDI/AreaA-data_modeling_and_schemas.git@3b05b9e0f8fa842e928768506ed4ba64aab83a46#subdirectory=transmission/transmission_plugin/uv_vis_nir_transmission_plugin',
]

[project.optional-dependencies]
dev = ["ruff", "pytest", "structlog"]
dev = [
"ruff",
"pytest",
"structlog",
"python-logstash>=0.4.6",
]

[project.urls]
"Homepage" = "https://github.com/IKZ-Berlin/nomad-ikz-plugin"
Expand Down Expand Up @@ -139,6 +144,7 @@ where = ["src"]
[project.entry-points.'nomad.plugin']
general_schema = "nomad_ikz_plugin.general:schema"
characterization_schema = "nomad_ikz_plugin.characterization:schema"
characterization_transmission_parser = "nomad_ikz_plugin.characterization:transmission_parser"
pld_schema = "nomad_ikz_plugin.pld:schema"
movpe_schema = "nomad_ikz_plugin.movpe:schema"
movpe2_growth_excel_parser = "nomad_ikz_plugin.movpe.movpe2.growth_excel:parser"
Expand Down
21 changes: 19 additions & 2 deletions src/nomad_ikz_plugin/characterization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# limitations under the License.
#

from nomad.config.models.plugins import SchemaPackageEntryPoint
from pydantic import Field
from nomad.config.models.plugins import ParserEntryPoint, SchemaPackageEntryPoint


class CharacterizationEntryPoint(SchemaPackageEntryPoint):
Expand All @@ -26,7 +25,25 @@ def load(self):
return m_package


class TransmissionParserEntryPoint(ParserEntryPoint):
"""
Entry point for lazy loading of the TransmissionParser.
"""

def load(self):
from nomad_ikz_plugin.characterization.parser import TransmissionParser

return TransmissionParser(**self.dict())


schema = CharacterizationEntryPoint(
name='CharacterizationSchema',
description='Schema package for general characterization methods used at IKZ.',
)

transmission_parser = TransmissionParserEntryPoint(
name='Transmission Parser',
description='Parser for data from Transmission Spectrophotometry.',
mainfile_mime_re='text/.*|application/zip',
mainfile_name_re='^.*\.asc$',
)
50 changes: 50 additions & 0 deletions src/nomad_ikz_plugin/characterization/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# 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.
#
from typing import TYPE_CHECKING

from nomad.parsing import MatchingParser
from transmission.schema import RawFileTransmissionData
from transmission.utils import create_archive

from nomad_ikz_plugin.characterization.schema import IKZELNUVVisNirTransmission

if TYPE_CHECKING:
from nomad.datamodel.datamodel import (
EntryArchive,
)


class TransmissionParser(MatchingParser):
"""
Parser for matching files from Transmission Spectrophotometry and
creating instances of ELN.
"""

def parse(
self, mainfile: str, archive: 'EntryArchive', logger=None, child_archives=None
) -> None:
data_file = mainfile.split('/')[-1]
entry = IKZELNUVVisNirTransmission.m_from_dict(
IKZELNUVVisNirTransmission.m_def.a_template
)
entry.data_file = data_file
file_name = f'{".".join(data_file.split(".")[:-1])}.archive.json'
archive.data = RawFileTransmissionData(
measurement=create_archive(entry, archive, file_name)
)
archive.metadata.entry_name = f'{data_file} data file'
Loading