Skip to content

Commit

Permalink
Merge pull request #380 from simonsobs/polyfit_bugfix
Browse files Browse the repository at this point in the history
Add try/except to np.polyfit
  • Loading branch information
dpdutcher authored Aug 14, 2023
2 parents d1d10a5 + 46ff928 commit 5a579b5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sodetlib/operations/iv.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,20 @@ def analyze_iv(iva, psat_level=0.9, save=False, update_cfg=False, show_pb=False)
nb_fit_idx = (iva.nbiases + nb_idx) // 2
fin_idx = (np.isfinite(iva.i_bias[nb_fit_idx:]) &
np.isfinite(iva.resp[i, nb_fit_idx:]))
norm_fit = np.polyfit(iva.i_bias[nb_fit_idx:][fin_idx],
iva.resp[i, nb_fit_idx:][fin_idx], 1)
try:
norm_fit = np.polyfit(iva.i_bias[nb_fit_idx:][fin_idx],
iva.resp[i, nb_fit_idx:][fin_idx], 1)
except:
continue
iva.resp[i] -= norm_fit[1] # Put resp in real current units

fin_idx = (np.isfinite(iva.i_bias[:sc_idx]) &
np.isfinite(iva.resp[i, :sc_idx]))
sc_fit = np.polyfit(iva.i_bias[:sc_idx][fin_idx],
iva.resp[i, :sc_idx][fin_idx], 1)
try:
sc_fit = np.polyfit(iva.i_bias[:sc_idx][fin_idx],
iva.resp[i, :sc_idx][fin_idx], 1)
except:
continue

# subtract off unphysical y-offset in superconducting branch; this
# is probably due to an undetected phase wrap at the kink between
Expand Down

0 comments on commit 5a579b5

Please sign in to comment.