parameters: (scan_number, spice_file_name, spice_table_ws_name)
return_statement: return info_list, error_message
docstring: process SPICE table
          :param scan_number:
          :param spice_file_name:
          :param spice_table_ws_name:
          :return: list/None (information for scan) and string (error message)
docstring_summary: process SPICE table
          :param scan_number:
          :param spice_file_name:
          :param spice_table_ws_name:
          :return: list/None (information for scan) and string (error message)
docstring_tokens: process SPICE table : param scan_number : : param spice_file_name : : param spice_table_ws_name : : return : list / None ( information for scan ) and string ( error message )
function: def retrieve_scan_info_spice(scan_number, spice_file_name, spice_table_ws_name):
          """
          process SPICE table
          :param scan_number:
          :param spice_file_name:
          :param spice_table_ws_name:
          :return: list/None (information for scan) and string (error message)
          """
          # check inputs
          if os.path.exists(spice_file_name) is False:
              raise RuntimeError('Parsing error')
  
          error_message = ''
  
          # Load SPICE file if the workspace does not exist
          if AnalysisDataService.doesExist(spice_table_ws_name) is False:
              mantidsimple.LoadSpiceAscii(Filename=spice_file_name,
                                          OutputWorkspace=spice_table_ws_name,
                                          RunInfoWorkspace='TempInfo')
  
          # Get workspace
          spice_table_ws = AnalysisDataService.retrieve(spice_table_ws_name)
          num_rows = spice_table_ws.rowCount()
  
          if num_rows == 0:
              # it is an empty table
              error_message += 'Scan %d: empty spice table.\n' % scan_number
              return None, error_message
  
          # process the columns
          col_name_list = spice_table_ws.getColumnNames()
          h_col_index = col_name_list.index('h')
          k_col_index = col_name_list.index('k')
          l_col_index = col_name_list.index('l')
          col_2theta_index = col_name_list.index('2theta')
          m1_col_index = col_name_list.index('m1')
          time_col_index = col_name_list.index('time')
          det_count_col_index = col_name_list.index('detector')
          # optional as T-Sample
          if 'tsample' in col_name_list:
              tsample_col_index = col_name_list.index('tsample')
          else:
              tsample_col_index = None
          # 2theta
  
          # do some simple statistics
          max_count = 0
          max_pt = 0
          max_h = max_k = max_l = 0
          max_tsample = 0.
  
          two_theta = m1 = -1
  
          for i_row in range(num_rows):
              det_count = spice_table_ws.cell(i_row, det_count_col_index)
              count_time = spice_table_ws.cell(i_row, time_col_index)
              # normalize max count to count time
              det_count = float(det_count) / count_time
              if det_count > max_count:
                  max_count = det_count
                  max_pt = spice_table_ws.cell(i_row, 0)  # pt_col_index is always 0
                  max_h = spice_table_ws.cell(i_row, h_col_index)
                  max_k = spice_table_ws.cell(i_row, k_col_index)
                  max_l = spice_table_ws.cell(i_row, l_col_index)
                  two_theta = spice_table_ws.cell(i_row, col_2theta_index)
                  m1 = spice_table_ws.cell(i_row, m1_col_index)
                  # t-sample is not a mandatory sample log in SPICE
                  if tsample_col_index is None:
                      max_tsample = 0.
                  else:
                      max_tsample = spice_table_ws.cell(i_row, tsample_col_index)
          # END-FOR
  
          # calculate wavelength
          wavelength = get_hb3a_wavelength(m1)
          if wavelength is None:
              q_range = 0.
              error_message += 'Scan number {0} has invalid m1 for wavelength.\n'.format(scan_number)
          else:
              q_range = 4. * math.pi * math.sin(two_theta / 180. * math.pi * 0.5) / wavelength
  
          # appending to list
          info_list = [max_count, scan_number, max_pt, max_h, max_k, max_l,
                       q_range, max_tsample, two_theta]
  
          return info_list, error_message
function_tokens: def retrieve_scan_info_spice ( scan_number , spice_file_name , spice_table_ws_name ) : # check inputs if os . path . exists ( spice_file_name ) is False : raise RuntimeError ( 'Parsing error' ) error_message = '' # Load SPICE file if the workspace does not exist if AnalysisDataService . doesExist ( spice_table_ws_name ) is False : mantidsimple . LoadSpiceAscii ( Filename = spice_file_name , OutputWorkspace = spice_table_ws_name , RunInfoWorkspace = 'TempInfo' ) # Get workspace spice_table_ws = AnalysisDataService . retrieve ( spice_table_ws_name ) num_rows = spice_table_ws . rowCount ( ) if num_rows == 0 : # it is an empty table error_message += 'Scan %d: empty spice table.\n' % scan_number return None , error_message # process the columns col_name_list = spice_table_ws . getColumnNames ( ) h_col_index = col_name_list . index ( 'h' ) k_col_index = col_name_list . index ( 'k' ) l_col_index = col_name_list . index ( 'l' ) col_2theta_index = col_name_list . index ( '2theta' ) m1_col_index = col_name_list . index ( 'm1' ) time_col_index = col_name_list . index ( 'time' ) det_count_col_index = col_name_list . index ( 'detector' ) # optional as T-Sample if 'tsample' in col_name_list : tsample_col_index = col_name_list . index ( 'tsample' ) else : tsample_col_index = None # 2theta # do some simple statistics max_count = 0 max_pt = 0 max_h = max_k = max_l = 0 max_tsample = 0. two_theta = m1 = - 1 for i_row in range ( num_rows ) : det_count = spice_table_ws . cell ( i_row , det_count_col_index ) count_time = spice_table_ws . cell ( i_row , time_col_index ) # normalize max count to count time det_count = float ( det_count ) / count_time if det_count > max_count : max_count = det_count max_pt = spice_table_ws . cell ( i_row , 0 ) # pt_col_index is always 0 max_h = spice_table_ws . cell ( i_row , h_col_index ) max_k = spice_table_ws . cell ( i_row , k_col_index ) max_l = spice_table_ws . cell ( i_row , l_col_index ) two_theta = spice_table_ws . cell ( i_row , col_2theta_index ) m1 = spice_table_ws . cell ( i_row , m1_col_index ) # t-sample is not a mandatory sample log in SPICE if tsample_col_index is None : max_tsample = 0. else : max_tsample = spice_table_ws . cell ( i_row , tsample_col_index ) # END-FOR # calculate wavelength wavelength = get_hb3a_wavelength ( m1 ) if wavelength is None : q_range = 0. error_message += 'Scan number {0} has invalid m1 for wavelength.\n' . format ( scan_number ) else : q_range = 4. * math . pi * math . sin ( two_theta / 180. * math . pi * 0.5 ) / wavelength # appending to list info_list = [ max_count , scan_number , max_pt , max_h , max_k , max_l , q_range , max_tsample , two_theta ] return info_list , error_message