Skip to content

Commit

Permalink
Deprecated the phrasing SubParser in favour for parser, aligning name…
Browse files Browse the repository at this point in the history
…s of src code directories
  • Loading branch information
atomprobe-tc committed Aug 1, 2024
1 parent 8df79ed commit 8afec16
Show file tree
Hide file tree
Showing 38 changed files with 88 additions and 102 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Configuration of the image_png_protochips subparser."""
"""Configuration of the image_png_protochips parser."""

import re
from typing import Dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Configuration of the image_tiff_tfs subparser."""
"""Configuration of the image_tiff_tfs parser."""

from numpy import pi

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
"""Map content from Velox EMD file format onto NeXus concepts.
# TODO move to pynxtools-em Velox subparser documentation
# TODO move to pynxtools-em Velox parser documentation
"Core/MetadataDefinitionVersion": ["7.9"]
"Core/MetadataSchemaVersion": ["v1/2013/07"]
all *.emd files from https://ac.archive.fhi.mpg.de/D62142 parsed with
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,25 @@

import flatdict as fd
import yaml

from pynxtools_em.concepts.mapping_functors import (
add_specific_metadata,
variadic_path_to_specific_path,
)
from pynxtools_em.config.conventions_cfg import (
from pynxtools_em.configurations.conventions_cfg import (
DETECTOR_CSYS_TO_NEXUS,
GNOMONIC_CSYS_TO_NEXUS,
PATTERN_CSYS_TO_NEXUS,
PROCESSING_CSYS_TO_NEXUS,
ROTATIONS_TO_NEXUS,
SAMPLE_CSYS_TO_NEXUS,
)
from pynxtools_em.geometry.euler_angle_convention import euler_convention
from pynxtools_em.geometry.handed_cartesian import (
from pynxtools_em.geometries.euler_angle_convention import euler_convention
from pynxtools_em.geometries.handed_cartesian import (
AXIS_DIRECTIONS,
REFERENCE_FRAMES,
is_cartesian_cs_well_defined,
)
from pynxtools_em.geometry.msmse_convention import is_consistent_with_msmse_convention
from pynxtools_em.geometries.msmse_convention import is_consistent_with_msmse_convention


class NxEmConventionParser:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import numpy as np
from diffpy.structure import Lattice, Structure
from orix.quaternion import Orientation

from pynxtools_em.concepts.nxs_em_eds_indexing import NxEmEdsIndexing
from pynxtools_em.concepts.nxs_image_r_set import NxImageRealSpaceSet
from pynxtools_em.concepts.nxs_object import NxObject
Expand All @@ -35,7 +34,7 @@
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.utils.get_scan_points import get_scan_point_coords
from pynxtools_em.utils.get_xrayline_iupac_names import get_xrayline_candidates
from pynxtools_em.utils.hfive_utils import read_strings_from_dataset
Expand Down Expand Up @@ -376,7 +375,7 @@ def parse_and_normalize_group_ebsd_data(self, fp, ckey: str):
# distances for hexagonal or square tiling of R^2
# self.tmp[ckey]["grid_type"] in ["HexGrid", "SqrGrid"]:
# if just SQUARE_GRID there is no point to explicitly compute the scan_point
# coordinates here (for every subparser) especially not when the respective
# coordinates here (for every parser) especially not when the respective
# quantity from the tech partner is just a pixel index i.e. zeroth, first px ...
# however, ideally the tech partners would use the scan_point fields to report
# calibrated absolute scan point positions in the local reference frame of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
#
"""Parent class for all tech partner-specific HDF5 parsers for mapping on NXem."""

import numpy as np
import h5py
from typing import Dict, List

from pynxtools_em.subparsers.hfive_concept import (
IS_GROUP,
IS_REGULAR_DATASET,
IS_COMPOUND_DATASET,
import h5py
import numpy as np
from pynxtools_em.parsers.hfive_concept import (
IS_ATTRIBUTE,
IS_COMPOUND_DATASET,
IS_FIELD_IN_COMPOUND_DATASET,
IS_GROUP,
IS_REGULAR_DATASET,
Concept,
)

Expand Down Expand Up @@ -437,7 +437,7 @@ def get_value(self, h5path):
# with which the content in the HDF5 file is formatted
# Therefore, at least some of the content and how that content is
# formatted is inspected to make an informed decision which specific hfive
# subparser can be expected to deal at all with the content of the HDF5 file
# parser can be expected to deal at all with the content of the HDF5 file

# For the example of EBSD there was once a suggestion made by the academic community
# to report EBSD results via HDF5, specifically via H5EBSD (Jackson et al.).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import h5py
import numpy as np
from diffpy.structure import Lattice, Structure

from pynxtools_em.examples.ebsd_database import (
ASSUME_PHASE_NAME_TO_SPACE_GROUP,
FLIGHT_PLAN,
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser

# HEXAGONAL_GRID
from pynxtools_em.utils.get_scan_points import get_scan_point_coords
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.utils.hfive_utils import (
read_strings_from_dataset,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import h5py
import numpy as np
from diffpy.structure import Lattice, Structure

from pynxtools_em.examples.ebsd_database import (
ASSUME_PHASE_NAME_TO_SPACE_GROUP,
FLIGHT_PLAN,
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser

# HEXAGONAL_GRID
from pynxtools_em.utils.get_scan_points import get_scan_point_coords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import h5py
import numpy as np
from diffpy.structure import Lattice, Structure

from pynxtools_em.examples.ebsd_database import (
ASSUME_PHASE_NAME_TO_SPACE_GROUP,
FLIGHT_PLAN,
HEXAGONAL_FLAT_TOP_TILING,
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.utils.hfive_utils import (
EULER_SPACE_SYMMETRY,
format_euler_parameterization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#
"""(Sub-)parser mapping concepts and content from Marc deGraeff's EMsoft *.h5 files on NXem."""

import numpy as np
import h5py
from typing import Dict

from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
import h5py
import numpy as np
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.utils.hfive_utils import read_strings_from_dataset


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
import h5py
import numpy as np
from diffpy.structure import Lattice, Structure

from pynxtools_em.examples.ebsd_database import (
FLIGHT_PLAN,
REGULAR_TILING,
SQUARE_TILING,
)
from pynxtools_em.subparsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.parsers.hfive_base import HdfFiveBaseParser
from pynxtools_em.utils.hfive_utils import (
format_euler_parameterization,
read_strings_from_dataset,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import numpy as np
import xmltodict
from PIL import Image

from pynxtools_em.concepts.mapping_functors import (
add_specific_metadata,
variadic_path_to_specific_path,
)
from pynxtools_em.config.image_png_protochips_cfg import (
from pynxtools_em.configurations.image_png_protochips_cfg import (
AXON_AUX_DYNAMIC_TO_NX_EM,
AXON_CHIP_DYNAMIC_TO_NX_EM,
AXON_DETECTOR_STATIC_TO_NX_EM,
Expand All @@ -41,7 +40,7 @@
AXON_VARIOUS_DYNAMIC_TO_NX_EM,
specific_to_variadic,
)
from pynxtools_em.subparsers.image_base import ImgsBaseParser
from pynxtools_em.parsers.image_base import ImgsBaseParser
from pynxtools_em.utils.get_file_checksum import (
DEFAULT_CHECKSUM_ALGORITHM,
get_sha256_of_file_content,
Expand All @@ -50,7 +49,7 @@
from pynxtools_em.utils.xml_utils import flatten_xml_to_dict


class ProtochipsPngSetSubParser(ImgsBaseParser):
class ProtochipsPngSetParser(ImgsBaseParser):
def __init__(self, file_path: str = "", entry_id: int = 1, verbose: bool = False):
super().__init__(file_path)
self.entry_id = entry_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Derived image class to derive every tech-partner-specific TIFF subparser from."""
"""Derived image class to derive every tech-partner-specific TIFF parser from."""

import mmap
from typing import Dict

from PIL import Image
from PIL.TiffTags import TAGS

from pynxtools_em.subparsers.image_base import ImgsBaseParser
from pynxtools_em.parsers.image_base import ImgsBaseParser


class TiffSubParser(ImgsBaseParser):
class TiffParser(ImgsBaseParser):
"""Read Tagged Image File Format TIF/TIFF."""

def __init__(self, file_path: str = ""):
Expand Down Expand Up @@ -93,7 +93,7 @@ def get_tags(self, verbose: bool = False):
def parse_and_normalize(self):
"""Perform actual parsing filling cache self.tmp."""
if self.supported is True:
print(f"Parsing via TiffSubParser...")
print(f"Parsing via TiffParser...")
self.get_tags()
else:
print(f"{self.file_path} is not a TIFF file this parser can process !")
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
import numpy as np
from PIL import Image
from PIL.TiffTags import TAGS

from pynxtools_em.concepts.mapping_functors import add_specific_metadata
from pynxtools_em.config.image_tiff_tfs_cfg import (
from pynxtools_em.configurations.image_tiff_tfs_cfg import (
TFS_APERTURE_STATIC_TO_NX_EM,
TFS_DETECTOR_STATIC_TO_NX_EM,
TFS_OPTICS_DYNAMIC_TO_NX_EM,
Expand All @@ -35,8 +34,8 @@
TFS_VARIOUS_DYNAMIC_TO_NX_EM,
TFS_VARIOUS_STATIC_TO_NX_EM,
)
from pynxtools_em.subparsers.image_tiff import TiffSubParser
from pynxtools_em.subparsers.image_tiff_tfs_concepts import (
from pynxtools_em.parsers.image_tiff import TiffParser
from pynxtools_em.parsers.image_tiff_tfs_concepts import (
get_fei_childs,
get_fei_parent_concepts,
)
Expand All @@ -46,7 +45,7 @@
)


class TfsTiffSubParser(TiffSubParser):
class TfsTiffParser(TiffParser):
def __init__(self, file_path: str = "", entry_id: int = 1):
super().__init__(file_path)
self.entry_id = entry_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Configuration of the image_tiff_tfs subparser."""
"""Configuration of the image_tiff_tfs parser."""

from typing import List


# this example exemplifies the situation for the TFS/FEI SEM Apreo from the IKZ of Prof. Martin Albrecht
# thanks to Robert Kernke it was clarified the microscope has several detectors and imaging modes
# these imaging modes control the specific TFS/FEI concept instances stored in the respective TIFF file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#
"""Parser mapping content of specific image files on NeXus."""

from pynxtools_em.subparsers.image_tiff_tfs import TfsTiffSubParser
from pynxtools_em.subparsers.image_png_protochips import ProtochipsPngSetSubParser
from pynxtools_em.parsers.image_png_protochips import ProtochipsPngSetParser
from pynxtools_em.parsers.image_tiff_tfs import TfsTiffParser


class NxEmImagesSubParser:
class NxEmImagesParser:
"""Map content from different type of image files on an instance of NXem."""

def __init__(self, entry_id: int = 1, file_path: str = "", verbose: bool = False):
Expand All @@ -35,12 +35,12 @@ def __init__(self, entry_id: int = 1, file_path: str = "", verbose: bool = False
self.verbose = verbose

def identify_image_type(self):
"""Identify if image matches known mime type and has content for which subparser exists."""
"""Identify if image matches known mime type and has content for which parser exists."""
# tech partner formats used for measurement
img = TfsTiffSubParser(self.file_path)
img = TfsTiffParser(self.file_path)
if img.supported:
return "single_tiff_tfs"
img = ProtochipsPngSetSubParser(self.file_path)
img = ProtochipsPngSetParser(self.file_path)
if img.supported:
return "set_of_zipped_png_protochips"
return None
Expand All @@ -54,13 +54,13 @@ def parse(self, template: dict) -> dict:
return template
print(f"{self.__class__.__name__} identified content as {image_parser_type}")
# see also comments for respective nxs_pyxem parser
# and its interaction with tech-partner-specific hfive_* subparsers
# and its interaction with tech-partner-specific hfive_* parsers
if image_parser_type == "single_tiff_tfs":
tiff = TfsTiffSubParser(self.file_path, self.entry_id)
tiff = TfsTiffParser(self.file_path, self.entry_id)
tiff.parse_and_normalize()
tiff.process_into_template(template)
elif image_parser_type == "set_of_zipped_png_protochips":
pngs = ProtochipsPngSetSubParser(self.file_path, self.entry_id)
pngs = ProtochipsPngSetParser(self.file_path, self.entry_id)
pngs.parse_and_normalize()
pngs.process_into_template(template)
# add here further specific content (sub-)parsers for formats from other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def hfive_to_template(payload):
return np.asarray(payload[...], dtype=payload.dtype)


class NxEmNxsMTexSubParser:
class NxEmNxsMTexParser:
"""Map content from *.nxs.mtex files on an instance of NXem."""

def __init__(self, entry_id: int = 1, file_path: str = "", verbose: bool = False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from pynxtools_em.utils.nion_utils import uuid_to_file_name


class NionProjectSubParser:
class NionProjectParser:
"""Parse (zip-compressed archive of a) nionswift project with its content."""

def __init__(
Expand Down
Loading

0 comments on commit 8afec16

Please sign in to comment.