mxcube / HardwareObjects

**DEPRECATED**: MXCuBE Hardware Objects (now part of HardwareRepository)
1 stars 11 forks source link

Problem with identical crystal snapshots #193

Closed olofsvensson closed 7 years ago

olofsvensson commented 7 years ago

There's a problem with the crystal snapshots taken before a data collection, the two last images look identical. This is a problem on all ESRF MX beamlines, here is an example from MASSIF 1 (id30a1):

image

I had a look into the code and I think I found the problem, at least for the MiniDiff. This the code that takes the four snapshots and moves phi (https://github.com/mxcube/HardwareObjects/blob/07319c46d49d62254706f8aa8bf66d70b08489d8/MiniDiff.py#L75-L90):

  for i, angle in enumerate([0]+[-90]*(number_of_snapshots-1)):
     logging.getLogger("HWR").info("MiniDiff: taking snapshot #%d", i+1)
     centredImages.append((phi.getPosition(),str(myimage(drawing))))
     phi.syncMoveRelative(angle)

The sequence generated by the enumerate function looks like this for four snapshots:

>>> number_of_snapshots = 4
>>> for i, angle in enumerate([0] + [-90] * (number_of_snapshots - 1)):
...   print(i, angle)
... 
0 0
1 -90
2 -90
3 -90

The problem with this code is that the relative movement between the first and the second snapshot is zero, hence these snapshots are taken at the same phi location.

By making the move before taking the snapshot the code works (I tested this patch yesterday on MASSIF 1):

  for i, angle in enumerate([0] + [-90] * (number_of_snapshots - 1)):
     phi.syncMoveRelative(angle)
     logging.getLogger("HWR").info("MiniDiff: taking snapshot #%d", i + 1)
     centredImages.append((phi.getPosition(), str(myimage(drawing))))

I'll make a PR for this patch.

mguijarr commented 7 years ago

Thanks a lot.

PRs accepted.