Spaces:
Runtime error
Runtime error
Commit
·
35719be
1
Parent(s):
ecbaf8f
fix odds
Browse files- temps/temps.py +14 -7
temps/temps.py
CHANGED
@@ -365,8 +365,7 @@ class TempsModule:
|
|
365 |
return self._calculate_odds(z, pz, zgrid)
|
366 |
return z, pz
|
367 |
|
368 |
-
def _calculate_odds(
|
369 |
-
self, z: np.ndarray, pz: np.ndarray, zgrid: np.ndarray
|
370 |
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
|
371 |
"""Calculate the odds for the estimated redshifts based on the cumulative distribution.
|
372 |
|
@@ -379,9 +378,17 @@ class TempsModule:
|
|
379 |
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing the predicted redshift values,
|
380 |
PDF values, and calculated odds.
|
381 |
"""
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
return z, pz, odds
|
|
|
365 |
return self._calculate_odds(z, pz, zgrid)
|
366 |
return z, pz
|
367 |
|
368 |
+
def _calculate_odds(self, z: np.ndarray, pz: np.ndarray, zgrid: np.ndarray
|
|
|
369 |
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
|
370 |
"""Calculate the odds for the estimated redshifts based on the cumulative distribution.
|
371 |
|
|
|
378 |
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing the predicted redshift values,
|
379 |
PDF values, and calculated odds.
|
380 |
"""
|
381 |
+
|
382 |
+
logger.info('Calculating ODDS values')
|
383 |
+
diff_matrix = np.abs(z[:, None] - zgrid[None, :])
|
384 |
+
idx_peak = np.argmax(pz, axis=1)
|
385 |
+
zpeak = zgrid[idx_peak]
|
386 |
+
idx_upper = np.argmin(np.abs((zpeak + 0.08)[:, None] - zgrid[None, :]), axis=1)
|
387 |
+
idx_lower = np.argmin(np.abs((zpeak - 0.08)[:, None] - zgrid[None, :]), axis=1)
|
388 |
+
|
389 |
+
odds = []
|
390 |
+
for jj in range(len(pz)):
|
391 |
+
odds.append(pz[jj,idx_lower[jj]:(idx_upper[jj]+1)].sum())
|
392 |
+
|
393 |
+
odds = np.array(odds)
|
394 |
return z, pz, odds
|