Skip to content

Commit

Permalink
Merge pull request #435 from simonsobs/issue393
Browse files Browse the repository at this point in the history
Change compute_psats to use last crossing of Rfrac=target_level
  • Loading branch information
dpdutcher authored Aug 10, 2024
2 parents 26b1e7a + 72faa2c commit d58ecd5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sodetlib/operations/iv.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def compute_psats(iva, psat_level=0.9):
Array of length (nchan) with the p-sat computed for each channel (W)
"""
# calculates P_sat as P_TES when Rfrac = psat_level
# if the TES is at 90% R_n more than once, just take the first crossing
# if the TES is at 90% R_n more than once, just take the last crossing
for i in range(iva.nchans):
if np.isnan(iva.R_n[i]):
continue
Expand All @@ -218,23 +218,23 @@ def compute_psats(iva, psat_level=0.9):
R = iva.R[i]
R_n = iva.R_n[i]
p_tes = iva.p_tes[i]
cross_idx = np.where(R/R_n > level)[0]
cross_idx = np.where(R/R_n < level)[0]

if len(cross_idx) == 0:
iva.p_sat[i] = np.nan
continue

# Takes cross-index to be the first time Rfrac crosses psat_level
cross_idx = cross_idx[0]
# Takes cross-index to be the last time Rfrac crosses psat_level
cross_idx = cross_idx[-1]
if cross_idx == 0:
iva.p_sat[i] = np.nan
continue

iva.idxs[i, 2] = cross_idx
try:
iva.p_sat[i] = interp1d(
R[cross_idx-1:cross_idx+1]/R_n,
p_tes[cross_idx-1:cross_idx+1]
R[cross_idx:cross_idx+2]/R_n,
p_tes[cross_idx:cross_idx+2]
)(level)
except ValueError:
iva.p_sat[i] = np.nan
Expand Down

0 comments on commit d58ecd5

Please sign in to comment.