parameters: (self, logbook_ws, data_array, progress)
docstring: Fills out the logbook with the requested meta-data.
docstring_summary: Fills out the logbook with the requested meta-data.
docstring_tokens: Fills out the logbook with the requested meta - data .
function: def _fill_logbook(self, logbook_ws, data_array, progress):
          """Fills out the logbook with the requested meta-data."""
          n_entries = len(self._metadata_headers)
          entry_not_found_msg = "The requested entry: {}, is not present in the raw data"
          operators = ["+", "-", "*", "//"]
          cache_entries_ops = {}
  
          for file_no, file_name in enumerate(data_array):
              # reporting progress each 10% of the data
              if file_no % (len(data_array)/10) == 0:
                  progress.report("Filling logbook table...")
              file_path = os.path.join(self._data_directory, file_name + '.nxs')
  
              with h5py.File(file_path, 'r') as f:
                  rowData = np.empty(n_entries, dtype=object)
                  rowData[0] = str(file_name)
                  for entry_no, entry in enumerate(self._metadata_entries, 1):
                      if any(op in entry for op in operators):
                          if entry in cache_entries_ops:
                              list_entries, binary_operations = cache_entries_ops[entry]
                              binary_operations = binary_operations.copy()
                          else:
                              list_entries, binary_operations = self._process_regex(entry)
                              cache_entries_ops[entry] = (list_entries, list(binary_operations))
                          # load all entries from the file
                          values = [0]*len(list_entries)
                          for split_entry_no, split_entry in enumerate(list_entries):
                              try:
                                  split_entry, index = self._get_index(split_entry)
                                  data = f.get(split_entry)[index]
                              except TypeError:
                                  values[split_entry_no] = ""
                                  self.log().warning(entry_not_found_msg.format(entry))
                                  continue
                              else:
                                  if isinstance(data, np.bytes_):
                                      if any(op in operators[1:] for op in binary_operations):
                                          self.log().warning("Only 'sum' operation is supported for string entries")
                                          values[0] = "N/A"
                                          binary_operations = []
                                          break
                                      else:
                                          data = data.decode('utf-8')
                                          data = data.replace(',', ';')  # needed for CSV output
                              values[split_entry_no] = data
                          values, binary_operations = self._perform_binary_operations(values, binary_operations,
                                                                                      operations=['*', '//'])
                          values, _ = self._perform_binary_operations(values, binary_operations,
                                                                      operations=['+', '-'])
                          if isinstance(values, np.ndarray):
                              tmp_data = ""
                              for value in values[0]:
                                  tmp_data += str(value) + ','
                              rowData[entry_no] = tmp_data[:-1]
                          else:
                              data = self._perform_cast(values[0], self._metadata_headers[entry_no][0])
                              rowData[entry_no] = data
                      else:
                          try:
                              entry, index = self._get_index(entry)
                              data = f.get(entry)[index]
                          except TypeError:
                              data = "Not found"
                              self.log().warning(entry_not_found_msg.format(entry))
  
                          if isinstance(data, np.ndarray):
                              tmp_data = ""
                              for array in data:
                                  tmp_data += ",".join(array)
                              data = tmp_data
                          elif isinstance(data, np.bytes_):
                              data = data.decode('utf-8')
                              data = str(data.replace(',', ';')).strip() # needed for CSV output
                          data = self._perform_cast(data, self._metadata_headers[entry_no][0])
                          rowData[entry_no] = data
                  mtd[logbook_ws].addRow(rowData)
function_tokens: def _fill_logbook ( self , logbook_ws , data_array , progress ) : n_entries = len ( self . _metadata_headers ) entry_not_found_msg = "The requested entry: {}, is not present in the raw data" operators = [ "+" , "-" , "*" , "//" ] cache_entries_ops = { } for file_no , file_name in enumerate ( data_array ) : # reporting progress each 10% of the data if file_no % ( len ( data_array ) / 10 ) == 0 : progress . report ( "Filling logbook table..." ) file_path = os . path . join ( self . _data_directory , file_name + '.nxs' ) with h5py . File ( file_path , 'r' ) as f : rowData = np . empty ( n_entries , dtype = object ) rowData [ 0 ] = str ( file_name ) for entry_no , entry in enumerate ( self . _metadata_entries , 1 ) : if any ( op in entry for op in operators ) : if entry in cache_entries_ops : list_entries , binary_operations = cache_entries_ops [ entry ] binary_operations = binary_operations . copy ( ) else : list_entries , binary_operations = self . _process_regex ( entry ) cache_entries_ops [ entry ] = ( list_entries , list ( binary_operations ) ) # load all entries from the file values = [ 0 ] * len ( list_entries ) for split_entry_no , split_entry in enumerate ( list_entries ) : try : split_entry , index = self . _get_index ( split_entry ) data = f . get ( split_entry ) [ index ] except TypeError : values [ split_entry_no ] = "" self . log ( ) . warning ( entry_not_found_msg . format ( entry ) ) continue else : if isinstance ( data , np . bytes_ ) : if any ( op in operators [ 1 : ] for op in binary_operations ) : self . log ( ) . warning ( "Only 'sum' operation is supported for string entries" ) values [ 0 ] = "N/A" binary_operations = [ ] break else : data = data . decode ( 'utf-8' ) data = data . replace ( ',' , ';' ) # needed for CSV output values [ split_entry_no ] = data values , binary_operations = self . _perform_binary_operations ( values , binary_operations , operations = [ '*' , '//' ] ) values , _ = self . _perform_binary_operations ( values , binary_operations , operations = [ '+' , '-' ] ) if isinstance ( values , np . ndarray ) : tmp_data = "" for value in values [ 0 ] : tmp_data += str ( value ) + ',' rowData [ entry_no ] = tmp_data [ : - 1 ] else : data = self . _perform_cast ( values [ 0 ] , self . _metadata_headers [ entry_no ] [ 0 ] ) rowData [ entry_no ] = data else : try : entry , index = self . _get_index ( entry ) data = f . get ( entry ) [ index ] except TypeError : data = "Not found" self . log ( ) . warning ( entry_not_found_msg . format ( entry ) ) if isinstance ( data , np . ndarray ) : tmp_data = "" for array in data : tmp_data += "," . join ( array ) data = tmp_data elif isinstance ( data , np . bytes_ ) : data = data . decode ( 'utf-8' ) data = str ( data . replace ( ',' , ';' ) ) . strip ( ) # needed for CSV output data = self . _perform_cast ( data , self . _metadata_headers [ entry_no ] [ 0 ] ) rowData [ entry_no ] = data mtd [ logbook_ws ] . addRow ( rowData )