Skip to content

Commit

Permalink
Remove non standard NXpositioner groups (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed May 10, 2024
1 parent 7b4b327 commit edb2c45
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 333 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# CHANGELOG


## 0.#.#

### Changed
- Non-standard "sample_{phi,omega,...}" groups in NXsample made optional and NXclass now set to NXtransformations instead of NXpositioner.


## 0.9.2

Expand Down
26 changes: 17 additions & 9 deletions src/nexgen/nxs_copy/copy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,25 @@ def convert_scan_axis(
ax_range (ArrayLike): Scan points. If passed, axis_increment_set and axis_end will also be written.\
Defaults to None
"""
del nxsample["transformations/" + ax]
nxsample["transformations/" + ax] = nxdata[ax]
name = (
"sample_" + ax + "/" + ax if "sam" not in ax else "sample_" + ax[-1] + "/" + ax
)
del nxsample[name]
nxsample[name] = nxdata[ax]
del nxsample[f"transformations/{ax}"]
nxsample[f"transformations/{ax}"] = nxdata[ax]
grp_name = f"sample_{ax}" if "sam" not in ax else f"sample_{ax[-1]}"
old_exists = grp_name in list(nxsample.keys())
if old_exists:
del nxsample[grp_name]
nxsample[f"{grp_name}/{ax}"] = nxdata[ax]
if ax_range is not None and "sam" not in ax:
increment = round(ax_range[1] - ax_range[0], 3)
nxsample["sample_" + ax].create_dataset(ax + "_increment_set", data=increment)
nxsample["sample_" + ax].create_dataset(ax + "_end", data=ax_range + increment)
end = ax_range + increment
nxsample["transformations"].create_dataset(
f"{ax}_increment_set", data=increment
)
nxsample["transformations"].create_dataset(f"{ax}_end", data=end)
if old_exists:
nxsample[f"{grp_name}/{ax}_increment_set"] = nxsample[
f"transformations/{ax}_increment_set"
]
nxsample[f"{grp_name}/{ax}_end"] = nxsample[f"transformations/{ax}_end"]


def check_and_fix_det_axis(nxs_in: h5py.File):
Expand Down
Loading

0 comments on commit edb2c45

Please sign in to comment.