-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
122 move the transmission code from areaa repo (#123)
* Add parser and schema * Add init file containing transmission entry points * Add deps and entry points to pyproject * Bugfix: name of the file reader * Add transmission raw files * Add parser test * Reference any composite system in the sample reference * Rename to path_length * Copy latest changes from AreaA repo * Integrate suggestions from AreaA TF: sample path lenght and orientation * Rename to detector_gain, detector_integration_time * Reordering settings sections * Fix * Rename attenuator settings class * Plural names * Use common utils * Use composite system for sample reference * Move transmission test file * Refactor test file * Add schema config * Test normalized data for one file * Regex for matching raw file content * Review: from sourcery * Review: from Hampus
- Loading branch information
1 parent
617fb72
commit 5d8cc94
Showing
11 changed files
with
5,729 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# 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 measurements. Currently | ||
supports `.asc` files generated by Perkin Elmer UV WinLab software. | ||
""", | ||
mainfile_mime_re=r'text/.*|application/zip', | ||
mainfile_name_re=r'^.*\.asc$', | ||
mainfile_contents_re=r'^PE UV', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Oops, something went wrong.