Skip to content

Commit

Permalink
linting, styling, mypying
Browse files Browse the repository at this point in the history
  • Loading branch information
atomprobe-tc committed Dec 11, 2023
1 parent 99d55ba commit 5aa9977
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 188 deletions.
8 changes: 4 additions & 4 deletions pynxtools/dataconverter/readers/em/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
#
"""Parser for loading generic orientation microscopy data based on ."""

# pylint: disable=no-member
# pylint: disable=no-member,fixme

from typing import Tuple, Any

from pynxtools.dataconverter.readers.base.reader import BaseReader
from pynxtools.dataconverter.readers.em.concepts.nexus_concepts import NxEmAppDef
# from pynxtools.dataconverter.readers.em.subparsers.nxs_mtex import NxEmNxsMTexSubParser
from pynxtools.dataconverter.readers.em.subparsers.nxs_pyxem import NxEmNxsPyxemSubParser
# from pynxtools.dataconverter.readers.em.subparsers.nxs_pyxem import NxEmNxsPyxemSubParser
from pynxtools.dataconverter.readers.em.subparsers.nxs_imgs import NxEmImagesSubParser
from pynxtools.dataconverter.readers.em.utils.default_plots import NxEmDefaultPlotResolver
# from pynxtools.dataconverter.readers.em.geometry.convention_mapper import NxEmConventionMapper
Expand Down Expand Up @@ -126,7 +126,7 @@ def read(self,
# sub_parser = "image_tiff"
subparser = NxEmImagesSubParser(entry_id, file_paths[0])
subparser.parse(template)

# for dat_instance in case.dat_parser_type:
# print(f"Process pieces of information in {dat_instance} tech partner file...")
# continue
Expand All @@ -146,7 +146,7 @@ def read(self,
# we only need to decorate the template to point to the mandatory ROI overview
# print("Create NeXus default plottable data...")
# em_default_plot_generator(template, 1)

if True is False:
nxs_plt = NxEmDefaultPlotResolver()
# if nxs_mtex is the sub-parser
Expand Down
22 changes: 11 additions & 11 deletions pynxtools/dataconverter/readers/em/subparsers/image_tiff_tfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_metadata(self):
sequence = [] # decide I/O order in which metadata for childs of parent concepts will be read
for key, value in tfs_parent_concepts_byte_offset.items():
if value is not None:
sequence.append((key, value))
sequence.append((key, value))
# tuple of parent_concept name and byte offset
sequence = sort_ascendingly_by_second_argument(sequence)
print(sequence)
Expand Down Expand Up @@ -131,7 +131,7 @@ def get_metadata(self):
else:
self.tmp["meta"][f"{parent}/{term}"] = value
else:
raise ValueError(f"Detected an unexpected case {parent}/{term}, type: {type(value)} !")
raise ValueError(f"Detected an unexpected case {parent}/{term}, type: {type(value)} !")
else:
pass

Expand All @@ -149,7 +149,7 @@ def process_into_template(self, template: dict) -> dict:
self.process_event_data_em_metadata(template)
self.process_event_data_em_data(template)
return template

def process_event_data_em_data(self, template: dict) -> dict:
"""Add respective heavy data."""
# default display of the image(s) representing the data collected in this event
Expand All @@ -167,8 +167,8 @@ def process_event_data_em_data(self, template: dict) -> dict:
# explorative viewing using H5Web than what traditionally typical image viewers are meant for
image_identifier = 1
trg = f"/ENTRY[entry{self.entry_id}]/measurement/EVENT_DATA_EM_SET[event_data_em_set]/" \
f"EVENT_DATA_EM[event_data_em{self.event_id}]/" \
f"IMAGE_R_SET[image_r_set{image_identifier}]/DATA[image]"
f"EVENT_DATA_EM[event_data_em{self.event_id}]/" \
f"IMAGE_R_SET[image_r_set{image_identifier}]/DATA[image]"
# TODO::writer should decorate automatically!
template[f"{trg}/title"] = f"Image"
template[f"{trg}/@NX_class"] = f"NXdata" # TODO::writer should decorate automatically!
Expand All @@ -183,8 +183,8 @@ def process_event_data_em_data(self, template: dict) -> dict:
template[f"{trg}/@axes"].append(f"axis_{dim}")
template[f"{trg}/intensity"] = {"compress": np.array(fp), "strength": 1}
# 0 is y while 1 is x for 2d, 0 is z, 1 is y, while 2 is x for 3d
template[f"{trg}/intensity/@long_name"] = f"Signal"
template[f"{trg}/intensity/@long_name"] = f"Signal"

sxy = {"x": self.tmp["meta"]["EScan/PixelWidth"],
"y": self.tmp["meta"]["EScan/PixelHeight"]}
shp = np.shape(np.array(fp))
Expand All @@ -206,14 +206,14 @@ def process_event_data_em_data(self, template: dict) -> dict:
for dim in dims:
template[f"{trg}/AXISNAME[axis_{dim}]"] \
= {"compress": np.asarray(np.linspace(0,
nxy[dim] - 1,
num=nxy[dim],
endpoint=True) * sxy[dim], np.float64), "strength": 1}
nxy[dim] - 1,
num=nxy[dim],
endpoint=True) * sxy[dim], np.float64), "strength": 1}
template[f"{trg}/AXISNAME[axis_{dim}]/@long_name"] \
= f"Coordinate along {dim}-axis ({scan_unit[dim]})"
template[f"{trg}/AXISNAME[axis_{dim}]/@units"] = f"{scan_unit[dim]}"
return template

def process_event_data_em_metadata(self, template: dict) -> dict:
"""Add respective metadata."""
# contextualization to understand how the image relates to the EM session
Expand Down
Loading

0 comments on commit 5aa9977

Please sign in to comment.