original_docstring:  Calculation of the event correlation function using Numba 
  
      :param events: 1D array of events values
      :param times: 1D array of times 
      :param cnt: 1D array of number of events in a pixel
      :param qqmask: 2D array q mask
      :param n_frames: int number of frames
  
  
      :return: CorrelationResult structure with correlation functions
      
docstring: Calculation of the event correlation function using Numba
docstring_tokens: Calculation of the event correlation function using Numba
code: def nbecorrts_q(events, times, cnt, qqmask, n_frames, calc_std=False, ttcf_par=0):
      """ Calculation of the event correlation function using Numba 
  
      :param events: 1D array of events values
      :param times: 1D array of times 
      :param cnt: 1D array of number of events in a pixel
      :param qqmask: 2D array q mask
      :param n_frames: int number of frames
  
  
      :return: CorrelationResult structure with correlation functions
      """
      print("start calculation of the correlation functions")
      t0 = time.perf_counter()
  
      qqmask = np.ravel(qqmask)[cnt > 0]
      cnt = cnt[cnt > 0]
  
      print("Number of used processors: ", nproc)
      num, mint = ncorrelatepm(events, times, cnt, qqmask, n_frames, nproc)  #  parallel
      qm = qqmask.max()
      res = np.zeros((qm, n_frames - 1), dtype=np.float32)
      if calc_std:
          dev = np.zeros_like(res)
      for q in range(1, qm + 1, 1):
          for_norm = qqmask[qqmask == q].size
          cor = num[q - 1,:,:]  # /q[q==2].size
          s = np.reshape(mint[q - 1,:], (n_frames, 1))  # /for_norm
          print("Number of pixels for q %d is %d" % (q, for_norm))
          print("Average photons per frame for q %d is %f" % (q, np.mean(s)))
          print("Average photons per frame per pixel for q %d is %f" % (q, np.mean(s) / for_norm))
  
          norm = np.dot(s, s.T) / n_frames
          cor = cor * for_norm / n_frames
          for i in range(1, n_frames):
              dia = np.diag(cor, k=i)
              sdia = np.diag(norm, k=i)
              ind = np.where(np.isfinite(dia))
              res[q - 1, i - 1] = np.mean(dia[ind]) / np.mean(sdia[ind])
              if calc_std:
                  dev[q - 1, i - 1] = np.std(dia[ind] / sdia[ind]) / len(sdia[ind]) ** 0.5
          if ttcf_par == q:
              trc = cor / norm
              tmp = np.diag(trc, k=-5)
              if np.sum(tmp) < 1:
                  trc += np.rot90(np.fliplr(trc))
              tmp = np.diag(trc, k=1)
              tmp = np.mean(tmp[tmp > 0])
              for j in range(n_frames - 1):
                  trc[j, j] = tmp
              del tmp
  
      print("Total correlation time %2.2f sec" % (time.perf_counter() - t0))
      # return wcf,mtcf,cor
      if ttcf_par == 0:
          trc = 0
      if not(calc_std):
          dev = 0
      return CorrelationResult(res, dev, trc)
code_tokens: def nbecorrts_q ( events , times , cnt , qqmask , n_frames , calc_std = False , ttcf_par = 0 ) : print ( "start calculation of the correlation functions" ) t0 = time . perf_counter ( ) qqmask = np . ravel ( qqmask ) [ cnt > 0 ] cnt = cnt [ cnt > 0 ] print ( "Number of used processors: " , nproc ) num , mint = ncorrelatepm ( events , times , cnt , qqmask , n_frames , nproc ) qm = qqmask . max ( ) res = np . zeros ( ( qm , n_frames - 1 ) , dtype = np . float32 ) if calc_std : dev = np . zeros_like ( res ) for q in range ( 1 , qm + 1 , 1 ) : for_norm = qqmask [ qqmask == q ] . size cor = num [ q - 1 , : , : ] s = np . reshape ( mint [ q - 1 , : ] , ( n_frames , 1 ) ) print ( "Number of pixels for q %d is %d" % ( q , for_norm ) ) print ( "Average photons per frame for q %d is %f" % ( q , np . mean ( s ) ) ) print ( "Average photons per frame per pixel for q %d is %f" % ( q , np . mean ( s ) / for_norm ) ) norm = np . dot ( s , s . T ) / n_frames cor = cor * for_norm / n_frames for i in range ( 1 , n_frames ) : dia = np . diag ( cor , k = i ) sdia = np . diag ( norm , k = i ) ind = np . where ( np . isfinite ( dia ) ) res [ q - 1 , i - 1 ] = np . mean ( dia [ ind ] ) / np . mean ( sdia [ ind ] ) if calc_std : dev [ q - 1 , i - 1 ] = np . std ( dia [ ind ] / sdia [ ind ] ) / len ( sdia [ ind ] ) ** 0.5 if ttcf_par == q : trc = cor / norm tmp = np . diag ( trc , k = - 5 ) if np . sum ( tmp ) < 1 : trc += np . rot90 ( np . fliplr ( trc ) ) tmp = np . diag ( trc , k = 1 ) tmp = np . mean ( tmp [ tmp > 0 ] ) for j in range ( n_frames - 1 ) : trc [ j , j ] = tmp del tmp print ( "Total correlation time %2.2f sec" % ( time . perf_counter ( ) - t0 ) ) if ttcf_par == 0 : trc = 0 if not ( calc_std ) : dev = 0 return CorrelationResult ( res , dev , trc )
short_docstring: Calculation of the event correlation function using Numba
short_docstring_tokens: Calculation of the event correlation function using Numba
comment: """ Calculation of the event correlation function using Numba 
  
      :param events: 1D array of events values
      :param times: 1D array of times 
      :param cnt: 1D array of number of events in a pixel
      :param qqmask: 2D array q mask
      :param n_frames: int number of frames
  
  
      :return: CorrelationResult structure with correlation functions
      """$SEP$#  parallel$SEP$# /q[q==2].size$SEP$# /for_norm$SEP$# return wcf,mtcf,cor