- a = params['curve'].data[params['block one']]
- b = params['curve'].data[params['block two']]
- assert a[:,params['x column']] == b[:,params['x column']]
- out = Data((a.shape[0],2), dtype=a.dtype)
- out[:,0] = a[:,params['x column']]
- out[:,1] = a[:,params['y column']] - b[:,params['y column']]
- outqueue.put(out)
+ data_A = params['curve'].data[params['block A']]
+ data_B = params['curve'].data[params['block B']]
+ # HACK? rely on params['curve'] being bound to the local hooke
+ # playlist (i.e. not a copy, as you would get by passing a
+ # curve through the queue). Ugh. Stupid queues. As an
+ # alternative, we could pass lookup information through the
+ # queue...
+ new = Data((data_A.shape[0], data_A.shape[1]+1), dtype=data_A.dtype)
+ new.info = copy.deepcopy(data.info)
+ new[:,:-1] = data_A
+
+ a_col = data_A.info['columns'].index(params['column A'])
+ b_col = data_A.info['columns'].index(params['column A'])
+ out = data_A[:,a_col] - data_B[:,b_col]
+
+ a_name,a_units = split_data_label(params['column A'])
+ b_name,b_units = split_data_label(params['column B'])
+ assert a_units == b_units, (
+ 'Unit missmatch: %s != %s' % (a_units, b_units))
+ if params['output column name'] == None:
+ params['output column name'] = (
+ 'difference of %s %s and %s %s' % (
+ block_A.info['name'], params['column A'],
+ block_B.info['name'], params['column B']))
+ new.info['columns'].append(
+ join_data_label(params['output distance column'], a_units)
+ new[:,-1] = out
+ params['curve'].data[params['block A']] = new
+