Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change compute_psats to use last crossing of Rfrac=target_level #435

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading