Skip to content

Commit

Permalink
3D EBSD working
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuehbach committed Nov 9, 2023
1 parent 8e1af84 commit 33688c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def parse_and_normalize_ebsd_data(self, ckey: str):
h5r[f"{self.path_registry['group_data']}/Phases"], np.int32)
old_shp = np.shape(self.tmp[ckey]["phase_id"])
self.tmp[ckey]["phase_id"] = np.reshape(self.tmp[ckey]["phase_id"],
(int(np.prod(old_shp[0:3])), int(old_shp[3])),
(int(np.prod(old_shp[0:3])),),
order="C")
print(np.unique(self.tmp[ckey]["phase_id"]))
# Phases here stores C-style index which Phase of the possible ones
Expand Down
21 changes: 12 additions & 9 deletions pynxtools/dataconverter/readers/em/subparsers/nxs_hfive.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ def onthefly_process_roi_ipfs_phases_threed(self, inp: dict, roi_id: int, templa
template[f"{prfx}/indexing_rate"] = np.float64(100. * n_pts_indexed / n_pts)
template[f"{prfx}/indexing_rate/@units"] = f"%"
grp_name = f"{prfx}/EM_EBSD_CRYSTAL_STRUCTURE_MODEL[phase{phase_id}]"
template[f"{grp_name}/number_of_scan_points"] = np.uint32(0)
template[f"{grp_name}/number_of_scan_points"] \
= np.uint32(np.sum(inp["phase_id"] == 0))
template[f"{grp_name}/phase_identifier"] = np.uint32(phase_id)
template[f"{grp_name}/phase_name"] = f"notIndexed"

Expand Down Expand Up @@ -611,7 +612,7 @@ def process_roi_phase_ipfs_threed(self,
direction=PROJECTION_VECTORS[idx])
img = get_ipfdir_legend(ipf_key)

rotations = Rotation.from_euler(euler=inp["euler"][inp["phases"] == pyxem_phase_id],
rotations = Rotation.from_euler(euler=inp["euler"][inp["phase_id"] == pyxem_phase_id],
direction='lab2crystal',
degrees=False)
print(f"shape rotations -----> {np.shape(rotations)}")
Expand All @@ -625,7 +626,7 @@ def process_roi_phase_ipfs_threed(self,
# but IPF color maps have a whitepoint which encodes in fact an orientation
# and because of that we may have a single crystal with an orientation
# close to the whitepoint which become a fully white seemingly "empty" image
ipf_rgb_map[inp["phases"] == pyxem_phase_id, :] = rgb_px_with_phase_id
ipf_rgb_map[inp["phase_id"] == pyxem_phase_id, :] = rgb_px_with_phase_id
ipf_rgb_map = np.reshape(
ipf_rgb_map, (inp["n_z"], inp["n_y"], inp["n_x"], 3), order="C")
# 0 is z, 1 is y, while 2 is x !
Expand Down Expand Up @@ -653,16 +654,17 @@ def process_roi_phase_ipfs_threed(self,
template[f"{mpp}/DATA[data]"] = {"compress": ipf_rgb_map, "strength": 1}
hfive_web_decorate_nxdata(f"{mpp}/DATA[data]", template)

scan_unit = inp["s_unit"] # this is not correct necessarily as the
# simulation may be scale-invariant...
scan_unit = inp["s_unit"] # TODO::this is not necessarily correct
# could be a scale-invariant synthetic microstructure whose simulation
# would work on multiple length-scales as atoms are not resolved directly!
if scan_unit == "um":
scan_unit = "µm"
for dim in dims:
template[f"{mpp}/AXISNAME[axis_{dim}]"] \
= {"compress": self.get_named_axis(inp, f"{dim}"), "strength": 1}
template[f"{mpp}/AXISNAME[axis_{dim}]/@long_name"] \
= f"Coordinate along {dim}-axis ({scan_unit})"
template[f"{mpp}/AXISNAME[axis_{dim}]/@units"] = f"{scan_unit}"
= {"compress": self.get_named_axis(inp, f"{dim}"), "strength": 1}
template[f"{mpp}/AXISNAME[axis_{dim}]/@long_name"] \
= f"Coordinate along {dim}-axis ({scan_unit})"
template[f"{mpp}/AXISNAME[axis_{dim}]/@units"] = f"{scan_unit}"

# add the IPF color map legend/key
lgd = f"{trg}/DATA[legend]"
Expand All @@ -672,6 +674,7 @@ def process_roi_phase_ipfs_threed(self,
template[f"{lgd}/@NX_class"] = f"NXdata" # TODO::writer should decorate automatically!
template[f"{lgd}/@signal"] = "data"
template[f"{lgd}/@axes"] = []
dims = ["x", "y"]
for dim in dims[::-1]:
template[f"{lgd}/@axes"].append(f"axis_{dim}")
enum = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def hfive_web_decorate_nxdata(path: str, inp: dict) -> dict:
inp[f"{path}/@CLASS"] = f"IMAGE" # required by H5Web to plot RGB maps
inp[f"{path}/@IMAGE_VERSION"] = f"1.2"
inp[f"{path}/@SUBCLASS_VERSION"] = np.int64(15)
inp[f"{path}/@long_name"] = f"Signal"
return inp
2 changes: 1 addition & 1 deletion test.ebsd3d_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Examples="067_0003 SmallIN100_Final 244_0014"


# Examples="SmallIN100_Final"
Examples="244_0014"
# Examples="244_0014"
for example in $Examples; do
echo $example
dataconverter --reader em --nxdl NXroot --input-file $example.dream3d --output debug.$example.dream3d.nxs 1>stdout.$example.dream3d.nxs.txt 2>stderr.$example.dream3d.nxs.txt
Expand Down

0 comments on commit 33688c1

Please sign in to comment.