Skip to content
Snippets Groups Projects
Commit 4d7a3e42 authored by Paolo Veglio's avatar Paolo Veglio
Browse files

fixed bug with conf_test where locut/hicut were reversed

parent 0d9d8c6f
No related branches found
No related tags found
No related merge requests found
import numpy as np import numpy as np
def test():
bt = np.arange(265, 275)
thr = np.array([267, 270, 273, 1, 1])
c = conf_test(bt, thr)
print(c)
def conf_test(rad, thr): def conf_test(rad, thr):
''' '''
...@@ -29,20 +35,20 @@ def conf_test(rad, thr): ...@@ -29,20 +35,20 @@ def conf_test(rad, thr):
thr = np.full((rad.shape[0], 4), thr[:4]).T thr = np.full((rad.shape[0], 4), thr[:4]).T
coeff = np.power(2, (thr[3] - 1)) coeff = np.power(2, (thr[3] - 1))
hicut = thr[0, :] hicut = thr[2, :]
beta = thr[1, :] beta = thr[1, :]
locut = thr[2, :] locut = thr[0, :]
power = thr[3, :] power = thr[3, :]
confidence = np.zeros(rad.shape) confidence = np.zeros(rad.shape)
alpha, gamma = np.empty(rad.shape), np.empty(rad.shape) alpha, gamma = np.empty(rad.shape), np.empty(rad.shape)
flipped = np.zeros(rad.shape) flipped = np.zeros(rad.shape)
gamma[hicut > locut] = thr[0, hicut > locut] gamma[hicut > locut] = thr[2, hicut > locut]
alpha[hicut > locut] = thr[2, hicut > locut] alpha[hicut > locut] = thr[0, hicut > locut]
flipped[hicut > locut] = 0 flipped[hicut > locut] = 0
gamma[hicut < locut] = thr[2, hicut < locut] gamma[hicut < locut] = thr[0, hicut < locut]
alpha[hicut < locut] = thr[0, hicut < locut] alpha[hicut < locut] = thr[2, hicut < locut]
flipped[hicut < locut] = 1 flipped[hicut < locut] = 1
# Rad between alpha and beta # Rad between alpha and beta
...@@ -51,13 +57,13 @@ def conf_test(rad, thr): ...@@ -51,13 +57,13 @@ def conf_test(rad, thr):
idx = np.nonzero((rad <= beta) & (flipped == 0)) idx = np.nonzero((rad <= beta) & (flipped == 0))
confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx]) confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx])
idx = np.nonzero((rad <= beta) & (flipped == 1)) idx = np.nonzero((rad <= beta) & (flipped == 1))
confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx]) confidence[idx] = 1.0 - coeff[idx] * np.power(s1[idx], power[idx])
# Rad between beta and gamma # Rad between beta and gamma
range_ = 2. * (beta - gamma) range_ = 2. * (beta - gamma)
s1 = (rad - alpha) / range_ s1 = (rad - gamma) / range_
idx = np.nonzero((rad > beta) & (flipped == 0)) idx = np.nonzero((rad > beta) & (flipped == 0))
confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx]) confidence[idx] = 1.0 - coeff[idx] * np.power(s1[idx], power[idx])
idx = np.nonzero((rad > beta) & (flipped == 1)) idx = np.nonzero((rad > beta) & (flipped == 1))
confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx]) confidence[idx] = coeff[idx] * np.power(s1[idx], power[idx])
...@@ -176,3 +182,7 @@ def conf_test_dble(rad, coeffs): ...@@ -176,3 +182,7 @@ def conf_test_dble(rad, coeffs):
confidence[confidence < 0] = 0 confidence[confidence < 0] = 0
return confidence return confidence
if __name__ == "__main__":
test()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment