def get_average_omega(exp_number, scan_number): """ Get average omega (omega-theta) :param exp_number: :param scan_number: :return: """ # get table workspace spice_table_name = util4.get_spice_table_name(exp_number, scan_number) spice_table = AnalysisDataService.retrieve(spice_table_name) # column index col_omega_index = spice_table.getColumnNames().index('omega') col_2theta_index = spice_table.getColumnNames().index('2theta') # get the vectors vec_size = spice_table.rowCount() vec_omega = numpy.ndarray(shape=(vec_size, ), dtype='float') vec_2theta = numpy.ndarray(shape=(vec_size, ), dtype='float') for i_row in range(vec_size): vec_omega[i_row] = spice_table.cell(i_row, col_omega_index) vec_2theta[i_row] = spice_table.cell(i_row, col_2theta_index) # END-FOR vec_omega -= vec_2theta * 0.5 return numpy.sum(vec_omega)
def get_average_spice_table(exp_number, scan_number, col_name): """ """ spice_table_name = util4.get_spice_table_name(exp_number, scan_number) # spice_table_name = 'HB3A_Exp%d_%04d_SpiceTable' % (exp_number, scan_number) # spice_table = mtd[spice_table_name] spice_table = AnalysisDataService.retrieve(spice_table_name) col_index = spice_table.getColumnNames().index(col_name) row_number = spice_table.rowCount() sum_item = 0. for i_row in range(row_number): sum_item += spice_table.cell(i_row, col_index) avg_value = sum_item / float(row_number) return avg_value