-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made also now the mapping of TFS vocabulary to NeXus work, awaiting n…
…ow feedback from IKZ to implement mapping of further quantities, test NeXus file writes successfully, next step refactor em_spctrscpy parser
- Loading branch information
1 parent
345d8e1
commit 99d55ba
Showing
4 changed files
with
90 additions
and
20 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
49 changes: 49 additions & 0 deletions
49
pynxtools/dataconverter/readers/em/subparsers/image_tiff_tfs_modifier.py
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,49 @@ | ||
# | ||
# 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. | ||
# | ||
"""Utilities for working with TFS/FEI-specific concepts.""" | ||
|
||
# pylint: disable=no-member | ||
|
||
from pynxtools.dataconverter.readers.em.subparsers.image_tiff_tfs_cfg import \ | ||
TfsToNexusConceptMapping | ||
|
||
|
||
def get_nexus_value(modifier, metadata: dict): | ||
"""Interpret a functional mapping using data from dct via calling modifiers.""" | ||
if isinstance(modifier, dict): | ||
# different commands are available | ||
if set(["fun", "terms"]) == set(modifier.keys()): | ||
if modifier["fun"] == "load_from": | ||
if modifier["terms"] in metadata.keys(): | ||
return metadata[modifier['terms']] | ||
else: | ||
raise ValueError(f"Unable to interpret modififier load_from for argument {modifier['terms']}") | ||
if modifier["fun"] == "tfs_to_nexus": | ||
# print(metadata[modifier['terms']]) | ||
if f"{modifier['terms']}/{metadata[modifier['terms']]}" in TfsToNexusConceptMapping.keys(): | ||
return TfsToNexusConceptMapping[f"{modifier['terms']}/{metadata[modifier['terms']]}"] | ||
else: | ||
raise ValueError(f"Unable to interpret modifier tfs_to_nexus for argument {modifier['terms']}/{metadata[modifier['terms']]}") | ||
else: | ||
print(f"WARNING::Modifier {modifier} is currently not implemented !") | ||
# elif set(["link"]) == set(modifier.keys()), with the jsonmap reader Sherjeel conceptualized "link" | ||
return None | ||
elif isinstance(modifier, str): | ||
return modifier # metadata[modifier] | ||
else: | ||
return None |
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