refactoring and log of coorinate work

This commit is contained in:
2022-09-02 12:46:51 +02:00
parent a54e580664
commit 45e8ab680f
8 changed files with 215 additions and 154 deletions

View File

@@ -190,7 +190,7 @@ class epics_cam(object):
def set_param(self,**kwargs):
param=[]
for k,v in kwargs:
for k,v in kwargs.items():
if k=='gain':
pv_gain=self.getPv('AMPGAIN')
param.append((pv_gain,v))
@@ -214,8 +214,8 @@ class epics_cam(object):
param.append((pv_rye,v[1]+v[3]))
elif k=='mono8':
pv_mono8=self.getPv('FORCEMONO8')
param.append((pv_mono8,vv))
self.update_params(param)
param.append((pv_mono8,v))
self.update_params(*param)
def set_exposure(self,exp):
try:
@@ -246,16 +246,16 @@ class epics_cam(object):
#def update_params(self, **kargs):
def update_params(self, *args):
"""update parameters on camera"""
pv_cam=self.getPv('CAMERA')
pv_cam.put(CameraStatus.IDLE, wait=True)
for pv, val in args:
if not pv.connected:
_log.info('force connect {}'.format(pv))
pv.force_connect() #force to connect pv
_log.debug("updating {} = {}".format(pv.pvname, val))
pv.put(val, wait=True)
pv_cam=self.getPv('CAMERA')
pv_cs = self.getPv('CAMERASTATUS')
#pv_set_param=self.getPv("SET_PARAM")
pv_cam.put(CameraStatus.IDLE, wait=True)
#pv_set_param.put(1, wait=True)
pv_cam.put(CameraStatus.RUNNING, wait=True)
self.update_size()
@@ -308,11 +308,13 @@ class epics_cam(object):
img=PIL.Image.open(fn)
#assert(img.mode=='L') # 8 bit grayscale
assert(sz==img.size)
if img.mode in ('L'):
if img.mode=='L':
#imgSeq[i, :, :]=np.asarray(img)
imgSeq[i,:,:]=np.array(img.getdata()).reshape(sz[::-1])
elif img.mode=='LA':
imgSeq[i, :, :]=np.asarray(img)[:,:,0]
imgSeq[i, :, :]=np.asarray(img)[:, :, 0]
elif img.mode=='I':
imgSeq[i, :, :]=np.asarray(img)
else:
raise TypeError(f'unsupported image mode format {img.mode}')
pic=imgSeq[i]