Eiger fixes
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+57
-50
@@ -6,7 +6,9 @@ import java.awt.Rectangle as Rectangle
|
||||
import ch.psi.pshell.imaging.Data as Data
|
||||
import ch.psi.pshell.device.Camera.DataType as DataType
|
||||
import ch.psi.utils.Chrono as Chrono
|
||||
import subprocess
|
||||
|
||||
#GRAB_MIN_TIME = 1000
|
||||
CONTINOUS_MODE_MIN_TIME = 4000
|
||||
###############################################################################
|
||||
# ROI Integration
|
||||
@@ -14,18 +16,14 @@ CONTINOUS_MODE_MIN_TIME = 4000
|
||||
|
||||
|
||||
def start_eiger_ioc():
|
||||
cmd= "cd /sls/X11MA/data/X11MA/SW/Eiger/;launch"
|
||||
return run("sshutils", {"USR": "gac-x11ma", "PWD": "", "HOST": "x11ma-softioc","PORT": 22, "CMD": cmd})
|
||||
subprocess.call("/work/sls/bin/X_X11MA_EigerStart.sh")
|
||||
print "IOC started"
|
||||
|
||||
|
||||
|
||||
def stop_eiger_ioc():
|
||||
try:
|
||||
caputq("X11MA-ES1-SD1:SYSRESET", 1);
|
||||
print "IOC stopped"
|
||||
except:
|
||||
print "IOC not running"
|
||||
cmd= "proc=$(ps aux | grep 'Eiger Receiver' | awk -F ' ' '{print $2}' | xargs); kill $proc"
|
||||
return run("sshutils", {"USR": "gac-x11ma", "PWD": "", "HOST": "x11ma-softioc","PORT": 22, "CMD": cmd})
|
||||
subprocess.call("/work/sls/bin/X_X11MA_EigerStop.sh")
|
||||
print "IOC stopped"
|
||||
|
||||
|
||||
def integrate_roi(source, x,y, w, h):
|
||||
@@ -76,44 +74,37 @@ def create_roi_devices(roi_list, add = True):
|
||||
###############################################################################
|
||||
# Frame integration
|
||||
###############################################################################
|
||||
"""
|
||||
def get_image(source, roi=None, wait_next=False):
|
||||
if wait_next:
|
||||
source.waitNext(-1)
|
||||
elif wait_next:
|
||||
if str(source.camera)=="Single":
|
||||
eiger.start()
|
||||
eiger.waitCacheChange(20000)
|
||||
ret = load_image(Utils.grayscale(source.output, Rectangle(roi[0], roi[1], roi[2], roi[3]) if (roi is not None) else None))
|
||||
return ret
|
||||
|
||||
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
if sleep>0:
|
||||
time.sleep(sleep)
|
||||
aux = get_image(source, roi, wait_next)
|
||||
frames.append(aux)
|
||||
return frames
|
||||
|
||||
def average_frames(source, samples=1, roi=None, wait_next=False, sleep=0, as_float=True):
|
||||
return average_ips(grab_frames(source, samples, roi, wait_next, sleep), as_float)
|
||||
|
||||
def integrate_frames(source, samples=1, roi=None, wait_next=False, sleep=0, as_float=True):
|
||||
return integrate_ips(grab_frames(source, samples, roi, wait_next, sleep), as_float)
|
||||
"""
|
||||
def grab_frame(source, roi=None, wait_next=False, outliers_threshold=None, outliers_mask=None):
|
||||
#chrono_grab= Chrono()
|
||||
def grab_frame(source, roi=None, wait_next=False, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
|
||||
global eiger_averaging_number_of_samples #, chrono_grab
|
||||
#chrono_grab.waitTimeout(GRAB_MIN_TIME)
|
||||
if outliers_threshold is None:
|
||||
outliers_threshold = get_outliers_threshold()
|
||||
if outliers_mask is None:
|
||||
outliers_mask = get_outliers_mask()
|
||||
|
||||
if wait_next:
|
||||
if str(eiger.grabMode)=="Single":
|
||||
eiger.waitReady(5000)
|
||||
eiger.start()
|
||||
#eiger.getDataArray().waitCacheChange(2000)
|
||||
source.waitNext(20000 + int(eiger.exposure * 1000))
|
||||
if retries is None:
|
||||
retries = 3
|
||||
if timeout is None:
|
||||
timeout=10.0
|
||||
exposures = 1 if (eiger_averaging_number_of_samples is None) else eiger_averaging_number_of_samples
|
||||
retries=max(retries,1)
|
||||
timeout = int(((eiger.exposure * eiger_averaging_number_of_samples) + timeout) * 1000)
|
||||
for try_count in range(retries):
|
||||
if str(eiger.grabMode)=="Single":
|
||||
eiger.waitReady(5000)
|
||||
eiger.start()
|
||||
try:
|
||||
#eiger.getDataArray().waitCacheChange(timeout)
|
||||
source.waitNext(timeout)
|
||||
break
|
||||
except java.util.concurrent.TimeoutException:
|
||||
if try_count == (retries-1):
|
||||
raise
|
||||
msg = "Eiger timeout - retrying #" + str(try_count)
|
||||
print msg
|
||||
log(msg)
|
||||
|
||||
#ret = load_image(Utils.grayscale(source.output, Rectangle(roi[0], roi[1], roi[2], roi[3]) if (roi is not None) else None))
|
||||
time.sleep(0.01)
|
||||
data=source.data
|
||||
@@ -124,14 +115,15 @@ def grab_frame(source, roi=None, wait_next=False, outliers_threshold=None, outli
|
||||
data.mult(outliers_mask)
|
||||
if outliers_threshold>0:
|
||||
data.threshold(outliers_threshold, False, None)
|
||||
#chrono_grab = Chrono()
|
||||
return data
|
||||
|
||||
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None):
|
||||
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
|
||||
frames = []
|
||||
for i in range(samples):
|
||||
if (i>0) and (sleep>0):
|
||||
time.sleep(sleep)
|
||||
aux = grab_frame(source, roi, wait_next, outliers_threshold, outliers_mask)
|
||||
aux = grab_frame(source, roi, wait_next, outliers_threshold, outliers_mask, retries, timeout)
|
||||
frames.append(aux)
|
||||
return frames
|
||||
|
||||
@@ -311,23 +303,38 @@ def restore_eiger(check=True, retries=2):
|
||||
def is_averaging_detector():
|
||||
return str(get_setting("AVERAGING_DETECTOR")).lower()=="true"
|
||||
|
||||
eiger_averaging_number_of_samples=None
|
||||
|
||||
def apply_averaging_detector(value):
|
||||
global eiger_averaging_number_of_samples
|
||||
if value:
|
||||
caput("X11MA-ES1-SD1:Proc1:EnableCallbacks", True)
|
||||
caput("X11MA-ES1-SD1:Proc1:EnableFilter", True)
|
||||
caput("X11MA-ES1-SD1:Proc1:AutoResetFilter", 1)
|
||||
caput("X11MA-ES1-SD1:Proc1:FilterCallbacks", 1)
|
||||
else:
|
||||
caput("X11MA-ES1-SD1:Proc1:EnableFilter", False)
|
||||
caput("X11MA-ES1-SD1:Proc1:NumFilter", 1)
|
||||
caput("X11MA-ES1-SD1:cam1:NumCycles", 1)
|
||||
eiger_averaging_number_of_samples = None
|
||||
|
||||
|
||||
def average_eiger_frames(samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None):
|
||||
if is_averaging_detector():
|
||||
caput("X11MA-ES1-SD1:Proc1:NumFilter", samples)
|
||||
caput("X11MA-ES1-SD1:cam1:NumCycles", samples)
|
||||
return grab_frame(image, roi, wait_next, outliers_threshold, outliers_mask)
|
||||
def average_eiger_frames(samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
|
||||
global eiger_averaging_number_of_samples #, chrono_eiger
|
||||
sample = int(samples)
|
||||
if is_averaging_detector():
|
||||
#chrono_eiger.waitTimeout(1000)
|
||||
caput("X11MA-ES1-SD1:Proc1:NumFilter", samples)
|
||||
caput("X11MA-ES1-SD1:cam1:NumCycles", samples)
|
||||
if samples != eiger_averaging_number_of_samples:
|
||||
log ("Changed Eiger averaging number of samples: " + str(samples))
|
||||
# TODO: if increasing number of samples next read returns quicly, as if using previous sample number
|
||||
eiger_averaging_number_of_samples = samples
|
||||
caput("X11MA-ES1-SD1:Proc1:ResetFilter", 1)
|
||||
chrono_eiger=Chrono()
|
||||
return grab_frame(image, roi, wait_next, outliers_threshold, outliers_mask, retries, timeout)
|
||||
else:
|
||||
ret = grab_frames(image, samples, roi, wait_next, sleep, outliers_threshold, outliers_mask)
|
||||
ret = grab_frames(image, samples, roi, wait_next, sleep, outliers_threshold, outliers_mask, retries, timeout)
|
||||
return average_frames(ret) if samples > 1 else ret[0]
|
||||
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+4
-4
@@ -5,7 +5,7 @@ import ntpath
|
||||
import traceback
|
||||
from rsync import *
|
||||
|
||||
|
||||
ProviderCSV.setDefaultItemSeparator(", ")
|
||||
get_context().dataManager.createLogs=False
|
||||
"""
|
||||
OTF_START = "X11MA-OTF:GO"
|
||||
@@ -485,14 +485,14 @@ def check_sync_user_data(path, do_fork=_FORK_SYNC_USER):
|
||||
|
||||
_CURRENT_DATA_PATH = None
|
||||
def on_change_data_path(path):
|
||||
print "on_change_data_path: " + str(path)
|
||||
#print "on_change_data_path: " + str(path)
|
||||
global _CURRENT_DATA_PATH
|
||||
if path is None:
|
||||
print "Close data path"
|
||||
#print "Close data path"
|
||||
if _CURRENT_DATA_PATH is not None:
|
||||
check_sync_user_data(_CURRENT_DATA_PATH)
|
||||
else:
|
||||
print "Open data path: " + str(path)
|
||||
#print "Open data path: " + str(path)
|
||||
_CURRENT_DATA_PATH = path
|
||||
fork(write_metadata)
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user