Skip to content

Commit

Permalink
Merge pull request #957 from ToFuProject/Issue956_NCAMWrongSide
Browse files Browse the repository at this point in the history
Optics order checking when creating a `diagnostic`: better warning msg + minor bugfix for `collimator` cameras
  • Loading branch information
dvezinet authored Sep 5, 2024
2 parents c5ff23b + bab1f89 commit 9a2febd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tofu/data/_class8_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,10 @@ def _check_optic(
f"The following points of {ocls} '{oo}' are on the wrong"
f"side of lastref {last_ref_cls} '{last_ref}':\n"
f"{iout.nonzero()[0]}\n\n"
f"'{oo}':\n{dgeom}\n\n"
f"'{last_ref}':\n{dgeom_lastref}\n\n"
f"last ref {last_ref_cls} '{last_ref}':\n{dgeom_lastref}\n\n"
f"optics {ocls} '{oo}':\n{dgeom}\n\n"
"Tip:\n"
"\tMake sure to provide optics ordered from camera to plasma"
)
raise Exception(msg)

Expand All @@ -497,14 +499,15 @@ def _check_optic(

cx, cy, cz = dgeom_cam['cents']
if ind_pix is None:
cx = coll.ddata[cx]['data'][ind_pix]
cy = coll.ddata[cy]['data'][ind_pix]
cz = coll.ddata[cz]['data'][ind_pix]
else:
cx = coll.ddata[cx]['data'][None, ...]
cy = coll.ddata[cy]['data'][None, ...]
cz = coll.ddata[cz]['data'][None, ...]

else:
cx = coll.ddata[cx]['data'][ind_pix]
cy = coll.ddata[cy]['data'][ind_pix]
cz = coll.ddata[cz]['data'][ind_pix]

# ------------------------
# get pixel unit vector(s)

Expand Down Expand Up @@ -535,9 +538,14 @@ def _check_optic(

if np.any(iout):
msg = (
f"diag '{key}':\n"
f"The following points of {ocls} '{oo}' are on the wrong"
f"side of camera '{cam}':\n"
f"{np.unique(iout.nonzero()[0])}"
f"side of lastref {last_ref_cls} '{last_ref}':\n"
f"{iout.nonzero()[0]}\n\n"
f"last ref {last_ref_cls} '{last_ref}':\n{dgeom_lastref}\n\n"
f"optics {ocls} '{oo}':\n{dgeom}\n\n"
"Tip:\n"
"\tMake sure to provide optics ordered from camera to plasma\n"
)
warnings.warn(msg)

Expand Down

0 comments on commit 9a2febd

Please sign in to comment.