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

122 move the transmission code from areaa repo #123

Merged
merged 24 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies = [
"nomad-lab>=1.3.6",
"xmltodict==0.13.0",
"fairmat-readers-xrd>=0.0.3",
"nomad-material-processing",
"fairmat-readers-transmission",
]
[project.urls]
"Homepage" = "https://github.com/FAIRmat-NFDI/nomad-measurements"
Expand Down Expand Up @@ -137,5 +139,7 @@ xrd_parser = "nomad_measurements.xrd:parser"
ppms_schema = "nomad_measurements.ppms:ppms_schema"
ppms_data_parser = "nomad_measurements.ppms:ppms_data_parser"
ppms_sequence_parser = "nomad_measurements.ppms:ppms_sequence_parser"
transmission_schema = "nomad_measurements.transmission:schema"
transmission_parser = "nomad_measurements.transmission:parser"

[tool.setuptools_scm]
56 changes: 56 additions & 0 deletions src/nomad_measurements/transmission/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# 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 nomad.config.models.plugins import ParserEntryPoint, SchemaPackageEntryPoint


class TransmissionSchemaEntryPoint(SchemaPackageEntryPoint):
"""
Entry point for lazy loading of the Transmission schemas.
"""

def load(self):
from nomad_measurements.transmission.schema import m_package

return m_package


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

def load(self):
from nomad_measurements.transmission.parser import TransmissionParser

return TransmissionParser(**self.dict())


schema = TransmissionSchemaEntryPoint(
name='Transmission Schema',
description='Schema for data from Transmission Spectrophotometry.',
)


parser = TransmissionParserEntryPoint(
name='Transmission Parser',
description='Parser for data from Transmission Spectrophotometry.',
mainfile_mime_re=r'text/.*|application/zip',
mainfile_name_re=r'^.*\.asc$',
mainfile_contents_re=r'^PE UV',
)
52 changes: 52 additions & 0 deletions src/nomad_measurements/transmission/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# 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 nomad_measurements.transmission.schema import (
ELNUVVisNirTransmission,
RawFileTransmissionData,
)
from nomad_measurements.utils import create_archive

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 = ELNUVVisNirTransmission.m_from_dict(
ELNUVVisNirTransmission.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
Loading