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):
|
||||
|
||||
def setGroup(self,idx):
|
||||
self.grp = idx
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
queue.flush()
|
||||
for i in range(n_pulses):
|
||||
msg = queue.__next__() # pull data from cache
|
||||
for chn in chns:
|
||||
data[chn]['data'][i] = msg[chn]
|
||||
data['pulse_id'][i]=msg['pid']
|
||||
# gather data
|
||||
data = [queue.__next__() for i in range(n_pulses)]
|
||||
# write out the data file
|
||||
hid = h5py.File(filename,'w')
|
||||
hid.create_dataset('pulse_id', data = data['pulse_id'])
|
||||
for chn in chns:
|
||||
hid = h5py.File(filename,'a')
|
||||
for chn in queue.channels:
|
||||
singledata = [ele[chn] for ele in data]
|
||||
gid = hid.create_group(chn)
|
||||
for key in data[chn].keys():
|
||||
gid.create_dataset(key, data = data[chn][key])
|
||||
gid.create_dataset('data', data = singledata)
|
||||
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()
|
||||
|
||||
|
||||
|
@ -94,9 +94,13 @@ def writeData(hid, data, scanrun=1):
|
||||
dset.attrs['system'] = getDatasetSystem(name[0])
|
||||
dset.attrs['units'] = 'unknown'
|
||||
# this part is obsolete - dimension should be given from the individual datasets
|
||||
if not 'pid' in data.keys():
|
||||
return
|
||||
shape = None
|
||||
if 'pid' in data.keys():
|
||||
shape = data['pid'].shape
|
||||
if 'pulse_id' in data.keys():
|
||||
shape = data['pulse_id'].shape
|
||||
if shape is None:
|
||||
return
|
||||
ndim = len(shape)
|
||||
nsam = shape[-1]
|
||||
nrec = 0
|
||||
|
Reference in New Issue
Block a user