changed bsacquisition to avoid asigning an array to an element of an array with scalar elements
This commit is contained in:
@ -9,32 +9,31 @@ from slic.core.acquisition.acquisition import Acquisition
|
|||||||
|
|
||||||
class BSCAcquisition(Acquisition):
|
class BSCAcquisition(Acquisition):
|
||||||
|
|
||||||
|
def setGroup(self,idx):
|
||||||
|
self.grp = idx
|
||||||
|
|
||||||
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
def _acquire(self, filename, channels=None, data_base_dir=None, scan_info=None, n_pulses=100, **kwargs):
|
||||||
|
|
||||||
|
if not hasattr(self,'grp'):
|
||||||
|
self.grp = 0
|
||||||
|
|
||||||
queue =channels[0] # abusing interface since BSAcquisition assume a list of channels
|
queue =channels[0] # abusing interface since BSAcquisition assume a list of channels
|
||||||
|
|
||||||
# allocating space
|
|
||||||
data={}
|
|
||||||
chns = queue.channels
|
|
||||||
for chn in chns:
|
|
||||||
data[chn]={'data':np.zeros((n_pulses))}
|
|
||||||
data['pulse_id']=np.zeros((n_pulses))
|
|
||||||
|
|
||||||
# clear the queue
|
# clear the queue
|
||||||
queue.flush()
|
queue.flush()
|
||||||
for i in range(n_pulses):
|
# gather data
|
||||||
msg = queue.__next__() # pull data from cache
|
data = [queue.__next__() for i in range(n_pulses)]
|
||||||
for chn in chns:
|
|
||||||
data[chn]['data'][i] = msg[chn]
|
|
||||||
data['pulse_id'][i]=msg['pid']
|
|
||||||
# write out the data file
|
# write out the data file
|
||||||
hid = h5py.File(filename,'w')
|
hid = h5py.File(filename,'a')
|
||||||
hid.create_dataset('pulse_id', data = data['pulse_id'])
|
for chn in queue.channels:
|
||||||
for chn in chns:
|
singledata = [ele[chn] for ele in data]
|
||||||
gid = hid.create_group(chn)
|
gid = hid.create_group(chn)
|
||||||
for key in data[chn].keys():
|
gid.create_dataset('data', data = singledata)
|
||||||
gid.create_dataset(key, data = data[chn][key])
|
singledata = [ele['pid'] for ele in data]
|
||||||
|
|
||||||
|
if self.grp == 0:
|
||||||
|
hid.create_dataset('pulse_id', data = singledata)
|
||||||
|
else:
|
||||||
|
hid.create_dataset('pulse_id_grp%d' % self.grp, data = singledata)
|
||||||
hid.close()
|
hid.close()
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,9 +94,13 @@ def writeData(hid, data, scanrun=1):
|
|||||||
dset.attrs['system'] = getDatasetSystem(name[0])
|
dset.attrs['system'] = getDatasetSystem(name[0])
|
||||||
dset.attrs['units'] = 'unknown'
|
dset.attrs['units'] = 'unknown'
|
||||||
# this part is obsolete - dimension should be given from the individual datasets
|
# this part is obsolete - dimension should be given from the individual datasets
|
||||||
if not 'pid' in data.keys():
|
shape = None
|
||||||
return
|
if 'pid' in data.keys():
|
||||||
shape = data['pid'].shape
|
shape = data['pid'].shape
|
||||||
|
if 'pulse_id' in data.keys():
|
||||||
|
shape = data['pulse_id'].shape
|
||||||
|
if shape is None:
|
||||||
|
return
|
||||||
ndim = len(shape)
|
ndim = len(shape)
|
||||||
nsam = shape[-1]
|
nsam = shape[-1]
|
||||||
nrec = 0
|
nrec = 0
|
||||||
|
Reference in New Issue
Block a user