Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions nslsii/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
import copy


def remove_zeros(shape):
"""
Remove any zeroes from the shape.
"""
return [dim for dim in shape if dim!=0]


def swap_dim1_dim2(shape):
"""
Swap the first two dimensions of the shape.
"""
shape[0], shape[1] = shape[1], shape[0]
return shape


def csx_fix_scaler_shape(d):
"""
Transform an Event Descriptor.
Expand All @@ -15,3 +30,17 @@ def csx_fix_scaler_shape(d):
if v['source'].startswith('PV:XF:23ID1-ES{Sclr:1}Wfrm'):
d['data_keys'][k]['shape'] = []
return d


def rsoxs_fix_shape(descriptor):
"""
Fix an RSOXS Event Descriptor.
"""
descriptor = copy.deepcopy(descriptor)
for key, value in descriptor['data_keys'].items():
shape = descriptor['data_keys'][key]['shape']
if shape:
shape = remove_zeros(shape)
descriptor['data_keys'][key]['shape'] = shape

return descriptor