adding beam center to raster shots, correcting test logic
This commit is contained in:
@@ -92,7 +92,7 @@ class RasterService:
|
||||
return
|
||||
|
||||
try:
|
||||
diffraction_image = self.ctx.deps.jfjoch.get_diffraction_image(image_id)
|
||||
diffraction_image = self.ctx.deps.jfjoch.get_diffraction_image(image_id, show_spots=True, show_res_est=True, show_beam_center=True)
|
||||
except NotFoundException:
|
||||
self.logger.warning(
|
||||
"JFJoch diffraction preview image was not found after raster; continuing without upload",
|
||||
@@ -108,7 +108,24 @@ class RasterService:
|
||||
)
|
||||
return
|
||||
|
||||
self.ctx.deps.aare.upload_jpg(sample_id, filename, diffraction_image)
|
||||
# Stamp spots/resolution from the best cell into the comment so the
|
||||
# Results diffraction modal can show them as a legend (like screening).
|
||||
comment = "Raster diffraction"
|
||||
try:
|
||||
best = scan_result.images[image_id]
|
||||
bits = []
|
||||
spots = getattr(best, "spots", None)
|
||||
res = getattr(best, "res", None)
|
||||
if spots is not None:
|
||||
bits.append(f"{spots} spots")
|
||||
if res is not None:
|
||||
bits.append(f"{res:.2f} Å")
|
||||
if bits:
|
||||
comment = f"Raster diffraction ({', '.join(bits)})"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.ctx.deps.aare.upload_jpg(sample_id, filename, diffraction_image, message=comment)
|
||||
|
||||
def ml_bounding_box(
|
||||
self,
|
||||
|
||||
@@ -194,7 +194,9 @@ def test_upload_raster_diffraction_preview_ignores_not_found():
|
||||
request=request,
|
||||
)
|
||||
|
||||
service.ctx.deps.jfjoch.get_diffraction_image.assert_called_once_with(2)
|
||||
service.ctx.deps.jfjoch.get_diffraction_image.assert_called_once_with(
|
||||
2, show_spots=True, show_res_est=True, show_beam_center=True
|
||||
)
|
||||
service.ctx.deps.aare.upload_jpg.assert_not_called()
|
||||
|
||||
|
||||
@@ -204,6 +206,8 @@ def test_upload_raster_diffraction_preview_uploads_when_present():
|
||||
request = make_request(2, 2)
|
||||
scan_result = MagicMock()
|
||||
scan_result.images = [MagicMock(), MagicMock(), MagicMock(), MagicMock()]
|
||||
scan_result.images[2].spots = 479
|
||||
scan_result.images[2].res = 2.23
|
||||
service.ctx.deps.jfjoch.get_diffraction_image.return_value = b"jpeg-bytes"
|
||||
|
||||
service._upload_raster_diffraction_preview(
|
||||
@@ -214,5 +218,9 @@ def test_upload_raster_diffraction_preview_uploads_when_present():
|
||||
request=request,
|
||||
)
|
||||
|
||||
service.ctx.deps.jfjoch.get_diffraction_image.assert_called_once_with(2)
|
||||
service.ctx.deps.aare.upload_jpg.assert_called_once_with(123, "preview", b"jpeg-bytes")
|
||||
service.ctx.deps.jfjoch.get_diffraction_image.assert_called_once_with(
|
||||
2, show_spots=True, show_res_est=True, show_beam_center=True
|
||||
)
|
||||
service.ctx.deps.aare.upload_jpg.assert_called_once_with(
|
||||
123, "preview", b"jpeg-bytes", message="Raster diffraction (479 spots, 2.23 Å)"
|
||||
)
|
||||
Reference in New Issue
Block a user