Skip to content

Commit

Permalink
Added xraydb to get all X-ray emission lines
Browse files Browse the repository at this point in the history
  • Loading branch information
atomprobe-tc committed Jan 12, 2024
1 parent baa02a6 commit bd4edec
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 10 deletions.
11 changes: 11 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ gitdb==4.0.11
# via gitpython
gitpython==3.1.40
# via pynxtools (pyproject.toml)
greenlet==3.0.3
# via sqlalchemy
h5py==3.10.0
# via
# fabio
Expand Down Expand Up @@ -297,6 +299,7 @@ numpy==1.24.4
# tables
# tifffile
# xarray
# xraydb
# zarr
numpy-quaternion==2022.4.3
# via orix
Expand All @@ -319,6 +322,7 @@ packaging==23.2
# scikit-image
# tables
# xarray
# xraydb
pandas==2.0.3
# via
# ifes-apt-tc-data-modeling
Expand Down Expand Up @@ -352,6 +356,7 @@ platformdirs==4.0.0
# pooch
# pylint
# requests-cache
# xraydb
pluggy==1.3.0
# via pytest
ply==3.11
Expand Down Expand Up @@ -470,6 +475,7 @@ scipy==1.9.1
# scikit-image
# scikit-learn
# sparse
# xraydb
silx==1.1.2
# via pyfai
six==1.16.0
Expand All @@ -482,6 +488,8 @@ smmap==5.0.1
# via gitdb
sparse==0.14.0
# via hyperspy
sqlalchemy==2.0.25
# via xraydb
stack-data==0.6.3
# via ipython
structlog==23.2.0
Expand Down Expand Up @@ -555,6 +563,7 @@ typing-extensions==4.8.0
# astroid
# cattrs
# mypy
# sqlalchemy
tzdata==2023.3
# via
# pandas
Expand Down Expand Up @@ -582,6 +591,8 @@ xarray==2023.1.0
# via pynxtools (pyproject.toml)
xmltodict==0.13.0
# via pynxtools (pyproject.toml)
xraydb==4.5.4
# via pynxtools (pyproject.toml)
zarr==2.16.1
# via hyperspy
zipp==3.17.0
Expand Down
12 changes: 11 additions & 1 deletion pynxtools/dataconverter/readers/em/concepts/nxs_concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
"""Implement NeXus-specific groups and fields to document software and versions used."""

# pylint: disable=no-member
# pylint: disable=no-member,too-few-members

from typing import List
from pynxtools.dataconverter.readers.em.concepts.concept_mapper \
Expand Down Expand Up @@ -59,3 +59,13 @@ def parse(self, template: dict, entry_id: int = 1, cmd_line_args: List = []) ->
template["/cs_profiling/@NX_class"] = "NXcs_profiling"
template["/cs_profiling/command_line_call"] = cmd_line_args
return template


class NxConcept():
""""Define a NeXus concept object to handle paths.
"""
def __init__(self, hdf_paths: List = []):
# TODO::remove redundant code for instantiating specific NxConcepts like
# NxSpectrum, NxImageRealSpaceSet, NxEmEdsIndexing
pass
54 changes: 54 additions & 0 deletions pynxtools/dataconverter/readers/em/concepts/nxs_em_eds_indexing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# 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_eds indexing instance data."""

from typing import Dict, List

from pynxtools.dataconverter.readers.em.concepts.nxs_object import NxObject


NX_EM_EDS_INDEXING_HDF_PATH = ["indexing-group",
"indexing/element_names-field",
"indexing/IMAGE_R_SET-group",
"indexing/IMAGE_R_SET/PROCESS-group",
"indexing/IMAGE_R_SET/PROCESS/peaks-field",
"indexing/IMAGE_R_SET/PROCESS/weights-field",
"indexing/PEAK-group",
"indexing/PEAK/ION-group",
"indexing/PEAK/ION/energy-field",
"indexing/PEAK/ION/energy_range-field",
"indexing/PEAK/ION/iupac_line_names-field",
"indexing/PROGRAM-group",
"indexing/summary-group",
"indexing/summary/axis_energy-field",
"indexing/summary/axis_energy@long_name-attribute",
"indexing/summary/intensity-field",
"indexing/summary/intensity@long_name-attribute"]


class NxEmEdsIndexing():
def __init__(self):
self.tmp: Dict = {}
self.tmp["source"] = None
for entry in NX_EM_EDS_INDEXING_HDF_PATH:
if entry.endswith("-field") is True:
self.tmp[entry[0:len(entry) - len("-field")]] = NxObject(eqv_hdf="dataset")
elif entry.endswith("-attribute") is True:
self.tmp[entry[0:len(entry) - len("-attribute")]] = NxObject(eqv_hdf="attribute")
else:
self.tmp[entry[0:len(entry) - len("-group")]] = NxObject(eqv_hdf="group")
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#
"""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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#
"""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, List

from pynxtools.dataconverter.readers.em.concepts.nxs_object import NxObject
Expand Down
9 changes: 9 additions & 0 deletions pynxtools/dataconverter/readers/em/subparsers/hfive_apex.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def parse_and_normalize(self):
h5r, f"/{grp_nm}/{sub_grp_nm}/{sub_sub_grp_nm}/{area_grp_nm}", ckey)
cache_id += 1

ckey = self.init_named_cache(f"eds_map{cache_id}")
self.parse_and_normalize_eds_rois(
h5r, f"/{grp_nm}/{sub_grp_nm}/{sub_sub_grp_nm}/{area_grp_nm}", ckey)
cache_id += 1

def parse_and_normalize_group_ebsd_header(self, fp, ckey: str):
# no official documentation yet from EDAX/APEX, deeply nested, chunking, virtual ds
if f"{self.prfx}/EBSD/ANG/DATA/DATA" not in fp:
Expand Down Expand Up @@ -581,3 +586,7 @@ def parse_and_normalize_eds_lsd(self, fp, src: str, ckey: str):
for key, val in self.tmp[ckey].tmp.items():
if key.startswith("spectrum_oned"):
print(f"spectrum_oned, key: {key}, val: {val}")

def parse_and_normalize_eds_rois(self, fp, src: str, ckey: str):
"""Normalize and scale APEX-specific EDS element emission line maps to NeXus."""

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ dependencies = [
"pandas>=1.3.2",
"odfpy>=1.4.1",
"ase>=3.19.0",
"flatdict>=4.0.1",
"hyperspy>=1.7.6",
"rosettasciio>=0.2",
"flatdict",
"hyperspy",
"rosettasciio",
"xraydb",
"ifes_apt_tc_data_modeling>=0.1",
"gitpython>=3.1.24",
"pytz>=2021.1",
Expand Down

0 comments on commit bd4edec

Please sign in to comment.