-
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.
Added rosettasciio, added skeleton for refactoring EDS, EELS, ADF usi…
…ng rosettasciio, collected feedback from the discussion with Robert Kernke (IKZ), next steps i) complete mapping of all detector modes for Robert, ii) complete EDS, EELS, ADF
- Loading branch information
1 parent
5aa9977
commit 49fb0a3
Showing
12 changed files
with
340 additions
and
8 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
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
41 changes: 41 additions & 0 deletions
41
pynxtools/dataconverter/readers/em/concepts/nxs_em_image_r_set.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,41 @@ | ||
# | ||
# 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. | ||
# | ||
"""NXem spectrum set (element of a labelled property graph) to store instance data.""" | ||
|
||
# pylint: disable=no-member,too-few-public-methods | ||
|
||
|
||
from typing import Dict | ||
|
||
from pynxtools.dataconverter.readers.em.concepts.nxs_object import NxObject | ||
|
||
|
||
NX_EM_IMAGE_REAL_SPACE_SET_HDF_PATH = [] | ||
# this one needs an update ! | ||
|
||
|
||
class NxEmImageRealSpaceSet(): | ||
def __init__(self): | ||
self.tmp: Dict = {} | ||
for entry in NX_EM_IMAGE_REAL_SPACE_SET_HDF_PATH: | ||
if entry.endswith("-field") is True: | ||
self.tmp[entry[0:len(entry)-len("-field")]] = NxObject(eqv_hdf="dset") | ||
elif entry.endswith("-attribute") is True: | ||
self.tmp[entry[0:len(entry)-len("-attribute")]] = NxObject(eqv_hdf="attr") | ||
else: | ||
self.tmp[entry[0:len(entry)-len("-group")]] = NxObject(eqv_hdf="grp") |
70 changes: 70 additions & 0 deletions
70
pynxtools/dataconverter/readers/em/concepts/nxs_em_spectrum_set.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,70 @@ | ||
# | ||
# 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. | ||
# | ||
"""NXem spectrum set (element of a labelled property graph) to store instance data.""" | ||
|
||
# pylint: disable=no-member,too-few-public-methods | ||
|
||
|
||
from typing import Dict | ||
|
||
from pynxtools.dataconverter.readers.em.concepts.nxs_object import NxObject | ||
|
||
|
||
NX_EM_SPECTRUM_SET_HDF_PATH = [ | ||
"PROCESS-group", | ||
"PROCESS/detector_identifier-field", | ||
"PROCESS/source-group", | ||
"PROCESS/source/algorithm-field", | ||
"PROCESS/source/checksum-field", | ||
"PROCESS/source/path-field", | ||
"PROCESS/source/type-field", | ||
"stack-group", | ||
"stack/axis_energy-field", | ||
"stack/axis_energy@long_name-attribute", | ||
"stack/axis_x-field", | ||
"stack/axis_x@long_name-attribute", | ||
"stack/axis_y-field", | ||
"stack/axis_y@long_name-attribute", | ||
"stack/intensity-field", | ||
"stack/intensity@long_name-attribute", | ||
"stack/title-field", | ||
"stack@axes-attribute", | ||
"stack@AXISNAME_indices-attribute", | ||
"stack@long_name-attribute", | ||
"stack@signal-attribute", | ||
"summary-group", | ||
"summary/axis_energy-field", | ||
"summary/axis_energy@long_name-attribute", | ||
"summary/title-field", | ||
"summary@axes-attribute", | ||
"summary@AXISNAME_indices-attribute", | ||
"summary@long_name-attribute", | ||
"summary@signal-attribute"] | ||
# this one needs an update ! | ||
|
||
|
||
class NxEmSpectrumSet(): | ||
def __init__(self): | ||
self.tmp: Dict = {} | ||
for entry in NX_EM_SPECTRUM_SET_HDF_PATH: | ||
if entry.endswith("-field") is True: | ||
self.tmp[entry[0:len(entry)-len("-field")]] = NxObject(eqv_hdf="dset") | ||
elif entry.endswith("-attribute") is True: | ||
self.tmp[entry[0:len(entry)-len("-attribute")]] = NxObject(eqv_hdf="attr") | ||
else: | ||
self.tmp[entry[0:len(entry)-len("-group")]] = NxObject(eqv_hdf="grp") |
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,61 @@ | ||
# | ||
# 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. | ||
# | ||
"""NXobject (element of a labelled property graph) to store instance data.""" | ||
|
||
# pylint: disable=no-member,too-few-public-methods | ||
|
||
from typing import Dict | ||
|
||
|
||
class NxObject: | ||
"""An object in a graph e.g. an attribute, dataset, or group in NeXus.""" | ||
|
||
def __init__(self, | ||
name: str = None, | ||
unit: str = None, | ||
dtype=str, | ||
value=None, | ||
**kwargs): | ||
if (name is not None) and (name == ""): | ||
raise ValueError(f"Value for argument name needs to be a non-empty string !") | ||
if (unit is not None) and (unit == ""): | ||
raise ValueError(f"Value for argument unit needs to be a non-empty string !") | ||
if (dtype is not None) and isinstance(dtype, type) is False: | ||
raise ValueError(f"Value of argument dtype must not be None " \ | ||
f" and a valid, ideally a numpy datatype !") | ||
# self.doc = None # docstring | ||
self.name = name # name of the field | ||
self.unit = unit # not unit category but actual unit | ||
# use special values "unitless" for NX_UNITLESS (e.g. 1) and | ||
# "dimensionless" for NX_DIMENSIONLESS (e.g. 1m / 1m) | ||
self.dtype = dtype # use np.dtype if possible | ||
if value is None or dtype is str: | ||
self.unit = "unitless" | ||
if value is not None: | ||
self.value = value | ||
# value should be a numpy scalar, tensor, or string if possible | ||
self.eqv_hdf = None | ||
if "eqv_hdf" in kwargs: | ||
if kwargs["eqv_hdf"] in ["group", "dataset", "attribute"]: | ||
self.eqv_hdf = kwargs["eqv_hdf"] | ||
else: | ||
raise ValueError(f"Value of keyword argument eqv_hdf needs to be one of grp, dset, attr !") | ||
|
||
def __repr__(self): | ||
"""Report values.""" | ||
return f"Name: {self.name}, unit: {self.unit}, dtype: {self.dtype}, eqv_hdf: {self.eqv_hdf}" |
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
47 changes: 47 additions & 0 deletions
47
pynxtools/dataconverter/readers/em/subparsers/rsciio_base.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,47 @@ | ||
# | ||
# 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. | ||
# | ||
"""Base class to inherit sub-parser from when interacting with rosettasciio.""" | ||
|
||
# this subparser is currently implemented such that it represents the first | ||
# and the second step of a parsing and mapping workflow whereby concepts and | ||
# instance data within the representation realm of a tech partner is mapped | ||
# onto the realm of NeXus e.g. to offer normalized content to e.g. NOMAD OASIS | ||
|
||
# the first step is the reading of information (all code relevant to enable | ||
# information extraction from a specific file of a tech partner | ||
# the second step is normalization of the information | ||
# the third step is (currently performed) with the nxs_hyperspy.py parser | ||
# which finally processes the already normalized information into the | ||
# template object that is thereafter consumed by the convert.py and writer.py | ||
# functionalities to create a serialized NeXus data artifact | ||
|
||
from typing import Dict | ||
|
||
|
||
class RsciioBaseParser: | ||
def __init__(self, file_path: str = ""): | ||
# self.supported_version = VERSION_MANAGEMENT | ||
# self.version = VERSION_MANAGEMENT | ||
# tech_partner the company which designed this format | ||
# schema_name the specific name of the family of schemas supported by this reader | ||
# schema_version the specific version(s) supported by this reader | ||
# writer_name the specific name of the tech_partner's (typically proprietary) software | ||
self.prfx = None | ||
self.tmp: Dict = {} | ||
if file_path is not None and file_path != "": | ||
self.file_path = file_path |
Oops, something went wrong.