@@ -263,17 +263,20 @@ def beam_tilt(self) -> Union[Vector, float]:
263263 depends on a calibration of the tilt angles. (read/write)
264264 """
265265 dfmode = RequestBody (attr = self .__id + ".DFMode" , validator = int )
266- dftilt = RequestBody (attr = self .__id + ".Tilt" )
266+ dftiltx = RequestBody (attr = self .__id + ".Tilt.X" , validator = float )
267+ dftilty = RequestBody (attr = self .__id + ".Tilt.Y" , validator = float )
267268
268269 mode = self .__client .call (method = "get" , body = dfmode )
269- tilt = self .__client .call (method = "get" , body = dftilt )
270+ tiltx = self .__client .call (method = "get" , body = dftiltx ) # rad
271+ tilty = self .__client .call (method = "get" , body = dftilty ) # rad
270272
271273 if mode == DarkFieldMode .CONICAL :
272- tilt *= 1e3
273- return Vector (tilt .x * math .cos (tilt .y ), tilt .x * math .sin (tilt .y ))
274+ tilt = tiltx
275+ rot = tilty
276+ return Vector (tilt * math .cos (rot ), tilt * math .sin (rot )) * 1e3
274277 elif mode == DarkFieldMode .CARTESIAN :
275- return tilt * 1e3
276- else :
278+ return Vector ( tiltx , tilty ) * 1e3
279+ else : # DF is off
277280 return Vector (0.0 , 0.0 ) # Microscope might return nonsense if DFMode is OFF
278281
279282 @beam_tilt .setter
@@ -284,7 +287,7 @@ def beam_tilt(self, tilt: Union[Vector, float]) -> None:
284287 if isinstance (tilt , float ):
285288 tilt = Vector (tilt , tilt )
286289
287- tilt *= 1e-3
290+ tilt *= 1e-3 # mrad to rad
288291
289292 if tilt == (0.0 , 0.0 ):
290293 body = RequestBody (attr = self .__id + ".Tilt" , value = tilt )
@@ -299,13 +302,9 @@ def beam_tilt(self, tilt: Union[Vector, float]) -> None:
299302 body = RequestBody (attr = self .__id + ".Tilt" , value = value )
300303 self .__client .call (method = "set" , body = body )
301304
302- elif mode == DarkFieldMode .OFF :
303- body = RequestBody (attr = self .__id + ".DFMode" , value = DarkFieldMode .CARTESIAN )
304- self .__client .call (method = "set" , body = body )
305-
306- body = RequestBody (attr = self .__id + ".Tilt" , value = tilt .x )
305+ elif mode == DarkFieldMode .CARTESIAN :
306+ body = RequestBody (attr = self .__id + ".Tilt" , value = tilt )
307307 self .__client .call (method = "set" , body = body )
308308
309309 else :
310- body = RequestBody (attr = self .__id + ".Tilt" , value = tilt .x )
311- self .__client .call (method = "set" , body = body )
310+ raise ValueError ("Dark field mode is OFF. You cannot set beam tilt." )
0 commit comments