Skip to content
Snippets Groups Projects
Commit 83677455 authored by Jack Christopher Hutchinson Rolph's avatar Jack Christopher Hutchinson Rolph
Browse files

Update PeakOTron.py

parent c58dd603
No related branches found
No related tags found
No related merge requests found
......@@ -1482,6 +1482,9 @@ class PeakOTron:
idxs_peaks, _ = find_peaks(density_bgsub,
distance=kwargs["peak_dist_nG"]*G_fft)
if(len(idxs_peaks)<2):
raise Exception("Less than 2 peaks found in spectrum. Spectrum cannot be fitted.")
########################################################################################################
## Find peaks widths with scipy 'peak_widths'. 'peak_rel_height' is used to find the appropriate width criterion.
......@@ -1533,6 +1536,9 @@ class PeakOTron:
idxs_peak_widths = idxs_peak_widths[_idxs_sort]
if(len(idxs_peaks)<2):
raise Exception("Less than 2 peaks found in spectrum. Spectrum cannot be fitted.")
########################################################################################################
## Calculate and store bin statistic information.
########################################################################################################
......@@ -1725,9 +1731,55 @@ class PeakOTron:
mu_DCR = DCR*(kwargs["t_0"] + kwargs["t_gate"])
########################################################################################################
## Store results in the class for fitting/reference.
## Check for nans and correct as necessary.
########################################################################################################
if(np.isnan(Q_0)):
if(self._verbose):
print("Q_0 returned nan in prefit. Setting Q_0 to 1 bin"):
Q_0 = 1
dQ_0 = 0.1
if(np.isnan(G)):
if(self._verbose):
print("G returned nan in prefit. Setting G to 1 bin"):
G = 1
dG = 0.1
if(np.isnan(mu)):
if(self._verbose):
print("mu returned nan in prefit. Setting mu to 1 p.e."):
mu = 1
dmu = 0.1
if(np.isnan(lbda)):
if(self._verbose):
print("lbda returned nan in prefit. Setting lbda to 1e-2."):
lbda = 1e-2
dlbda = 0.1
if(np.isnan(sigma_0)):
if(self._verbose):
print("sigma_0 returned nan in prefit. Setting sigma_0 to 1 bin."):
sigma_0 = 1
dsigma_0 = 0.1
if(np.isnan(sigma_1)):
if(self._verbose):
print("sigma_0 returned nan in prefit. Setting sigma_1 to 1 bin."):
sigma_1 = 1
dsigma_1 = 0.1
if(np.isnan(DCR)):
if(self._verbose):
print("DCR returned nan in prefit. Setting DCR to 1e-9 GHz."):
DCR = 1e-9
dDCR = 1e-2
########################################################################################################
## Store results in the class for fitting/reference.
########################################################################################################
self._hist_data["data"] = data
self._hist_data["bw"] = bw
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment