def _create_indexed_workspace(self, fractional_peaks, ndim, hklm): # Create table with the number of columns we need indexed = CreateEmptyTableWorkspace() names = fractional_peaks.getColumnNames() types = fractional_peaks.columnTypes() # Insert the extra columns for the addtional indicies for i in range(ndim - 3): names.insert(5 + i, 'm{}'.format(i + 1)) types.insert(5 + i, 'double') names = np.array(names) types = np.array(types) # Create columns in the table workspace for name, column_type in zip(names, types): indexed.addColumn(column_type, name) # Copy all columns from original workspace, ignoring HKLs column_data = [] idx = np.arange(0, names.size) hkl_mask = (idx < 5) | (idx > 4 + (ndim - 3)) for name in names[hkl_mask]: column_data.append(fractional_peaks.column(name)) # Insert the addtional HKL columns into the data for i, col in enumerate(hklm.T.tolist()): column_data.insert(i + 2, col) # Insert the columns into the table workspace for i in range(fractional_peaks.rowCount()): row = [column_data[j][i] for j in range(indexed.columnCount())] indexed.addRow(row) return indexed
def _create_indexed_workspace(self, fractional_peaks, ndim, hklm): # Create table with the number of columns we need types = ['int', 'long64', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'float', 'str', 'float', 'float', 'V3D', 'V3D'] indexed = CreateEmptyTableWorkspace() names = fractional_peaks.getColumnNames() # Insert the extra columns for the addtional indicies for i in range(ndim - 3): names.insert(5 + i, 'm{}'.format(i + 1)) types.insert(5 + i, 'double') names = np.array(names) types = np.array(types) # Create columns in the table workspace for name, column_type in zip(names, types): indexed.addColumn(column_type, name) # Copy all columns from original workspace, ignoring HKLs column_data = [] idx = np.arange(0, names.size) hkl_mask = (idx < 5) | (idx > 4 + (ndim - 3)) for name in names[hkl_mask]: column_data.append(fractional_peaks.column(name)) # Insert the addtional HKL columns into the data for i, col in enumerate(hklm.T.tolist()): column_data.insert(i + 2, col) # Insert the columns into the table workspace for i in range(fractional_peaks.rowCount()): row = [column_data[j][i] for j in range(indexed.columnCount())] indexed.addRow(row) return indexed