Skip to content

Commit

Permalink
Change logic of np.nan for ctrate_low and ctrate_high
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Feb 21, 2024
1 parent 205c415 commit 5778e1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions stingray/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base classes"""

from __future__ import annotations

from collections.abc import Iterable
Expand Down Expand Up @@ -2289,12 +2290,15 @@ def fill_bad_time_intervals(
high_time_arr = filtered_times[filt_hig_idx : buffer_size + filt_hig_idx]
high_time_arr = high_time_arr[high_time_arr < bti[1] + buffer_size]

ctrate_low = ctrate_high = np.nan

if len(low_time_arr) > 0 and (filt_low_t - low_time_arr[0]) > 0:
ctrate_low = np.count_nonzero(low_time_arr) / (filt_low_t - low_time_arr[0])
else:
ctrate_low = np.nan
if len(high_time_arr) > 0 and (high_time_arr[-1] - filt_hig_t) > 0:
ctrate_high = np.count_nonzero(high_time_arr) / (high_time_arr[-1] - filt_hig_t)
else:
ctrate_high = np.nan

if not np.isfinite(ctrate_low) and not np.isfinite(ctrate_high):
warnings.warn(
f"No valid data around to simulate the time series in interval "
Expand Down

0 comments on commit 5778e1f

Please sign in to comment.