Skip to content

Commit

Permalink
Merge pull request #354 from vshekar/eiger-monitor-error-handling
Browse files Browse the repository at this point in the history
Return empty image if eiger monitor is empty
  • Loading branch information
vshekar authored Feb 21, 2024
2 parents 5d416ef + 41279bf commit 46aa260
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions gui/albula/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from epics import PV
from enum import Enum
import platform
from PIL import Image
from PIL import Image, UnidentifiedImageError
from io import BytesIO
import os

Expand Down Expand Up @@ -156,14 +156,18 @@ def set_current_monitor_image(self):
self.albulaSubFrame.loadImage(dimage)

def get_eiger_monitor_image(self): # for EIGER1
urlData = "http://{}/monitor/api/{}/images/monitor".format(
self.ip, self.api_version
)
replyData = requests.get(urlData)
img_bytes = BytesIO(replyData.content)
img = Image.open(img_bytes)
array = numpy.array(img)
array[array == 65535] = 0
try:
urlData = "http://{}/monitor/api/{}/images/monitor".format(
self.ip, self.api_version
)
replyData = requests.get(urlData)
img_bytes = BytesIO(replyData.content)
img = Image.open(img_bytes)
array = numpy.array(img)
array[array == 65535] = 0
except UnidentifiedImageError:
logger.error("Could not get image from EIGER")
array = numpy.zeros((3110, 3269))

return array

Expand Down

0 comments on commit 46aa260

Please sign in to comment.