Skip to content

Commit

Permalink
perf: use slices of points in results of edd.UpdateNXdataReader to im…
Browse files Browse the repository at this point in the history
…prove speed when used with common.UpdateNXvalueProcessor
  • Loading branch information
keara-soloway committed Oct 24, 2024
1 parent 05394fe commit da94f03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CHAP/common/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2809,8 +2809,8 @@ def process(self, data, nxfilename, data_points=None, inputdir=None):
except Exception as exc:
self.logger.error(f'Error updating {data_point["nxpath"]} for '
f'data point {data_point["index"]}: {exc}')
self.logger.info(
f'Successfully updated data_points {list_to_string(indices)}')
else:
self.logger.debug(f'Updated data point {data_point}')

nxfile.close()

Expand Down
40 changes: 19 additions & 21 deletions CHAP/edd/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,28 +849,26 @@ def read(self, spec_file, scan_number, detector_ids=None, inputdir='.'):
detector_data = {id_: detector_data[:,i,:]
for i, id_ in enumerate(detector_ids)}
spec_scan_data = scanparser.spec_scan_data
motor_vals_relative = scanparser.spec_scan_motor_vals_relative
data_points = []
self.logger.info(f'Getting {scanparser.spec_scan_npts} data points')
for i in range(scanparser.spec_scan_npts):
self.logger.debug(f'Getting data point for scan step index {i}')
index = dataset_point_index_offset + i
data_points += [
{'nxpath': f'entry/data/{k}', 'index': index, 'value': v}
for k, v in smb_par_values.items()]
data_points += [
{'nxpath': f'entry/data/{id_}', 'index': index,
'value': data[i]}
for id_, data in detector_data.items()]
data_points += [
{'nxpath': f'entry/data/{c}', 'index': index,
'value': spec_scan_data[counters[c]][i]}
for c in counters]
step = scanparser.get_scan_step(i)
data_points += [
{'nxpath': f'entry/data/{a}', 'index': index,
'value': round(motor_vals_relative[j][step[j]], 3)}
for j, a in enumerate(scan_axes)]
idx = slice(dataset_point_index_offset,
dataset_point_index_offset + scanparser.spec_scan_npts)
data_points = [
{'nxpath': f'entry/data/{k}',
'value': [v] * scanparser.spec_scan_npts,
'index': idx}
for k, v in smb_par_values.items()]
data_points.extend([
{'nxpath': f'entry/data/{id_}',
'value': data,
'index': idx}
for id_, data in detector_data.items()
])
data_points.extend([
{'nxpath': f'entry/data/{c}',
'value': spec_scan_data[counters[c]],
'index': idx}
for c in counters
])

return data_points

Expand Down

0 comments on commit da94f03

Please sign in to comment.