Exemple #1
0
 def _update_fit(self):
     if self.perform_fit:
         N = self.number_of_resonances
         if N != 'auto':
             N = int(N)
         try:
             p = fitting.fit_multiple_lorentzians(self.frequency,
                                                  self.counts,
                                                  N,
                                                  threshold=self.threshold *
                                                  0.01)
         except Exception:
             logging.getLogger().debug('ODMR fit failed.', exc_info=True)
             p = np.nan * np.empty(4)
     else:
         p = np.nan * np.empty(4)
     self.fit_parameters = p
     self.fit_frequencies = p[1::3]
     self.fit_line_width = p[2::3]
     N = len(p) / 3
     contrast = np.empty(N)
     c = p[0]
     pp = p[1:].reshape((N, 3))
     for i, pi in enumerate(pp):
         a = pi[2]
         g = pi[1]
         A = np.abs(a / (np.pi * g))
         if a > 0:
             contrast[i] = 100 * A / (A + c)
         else:
             contrast[i] = 100 * A / c
     self.fit_contrast = contrast
Exemple #2
0
 def update_fit(self):
     if self.perform_fit:
         N = self.number_of_resonances
         if N != 'auto':
             N = int(N)
         try:
             p = fitting.fit_multiple_lorentzians(self.frequency,
                                                  self.counts,
                                                  N,
                                                  threshold=self.threshold *
                                                  0.01)
         except Exception:
             logging.getLogger().debug('ODMR fit failed.', exc_info=True)
             p = np.nan * np.empty(4)
     else:
         p = np.nan * np.empty(4)
     self.fit_parameters = p
     self.fit_frequencies = p[1::3]
     self.fit_line_width = p[2::3].mean()
     self.fit_contrast = -100 * p[3::3].mean() / (np.pi * p[2::3].mean() *
                                                  p[0])