Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobachetti committed Sep 27, 2024
1 parent f762d35 commit f8fe13b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions stingray/gti.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,14 +1733,14 @@ def split_gtis_at_indices(gtis, index_list):


def find_large_bad_time_intervals(gtis, bti_length_limit=86400):
"""Find large bad time intervals in a list of GTIs, and split the GTI list accordingly.
"""Find large bad time intervals (BTIs) in a list of GTIs, and split the GTI list accordingly.
Parameters
----------
gtis : 2-d float array
List of GTIs of the form ``[[gti0_0, gti0_1], [gti1_0, gti1_1], ...]``
bti_length_limit : float
Maximum length of a bad time interval. If a BTI is longer than this, an edge will be
Maximum length of a BTI. If a BTI is longer than this, an edge will be
returned at the midpoint of the BTI.
Returns
Expand Down Expand Up @@ -1775,7 +1775,7 @@ def split_gtis_by_exposure(gtis, exposure_per_chunk, new_interval_if_gti_sep=Non
gtis : 2-d float array
List of GTIs of the form ``[[gti0_0, gti0_1], [gti1_0, gti1_1], ...]``
exposure_per_chunk : float
Total exposure of each chunk
Total exposure of each chunk, in seconds
Other Parameters
----------------
Expand All @@ -1801,7 +1801,7 @@ def split_gtis_by_exposure(gtis, exposure_per_chunk, new_interval_if_gti_sep=Non
"""
gtis = np.asanyarray(gtis)
total_exposure = np.sum(np.diff(gtis, axis=1))
rough_total_exposure = np.sum(np.diff(gtis, axis=1))
compulsory_edges = []
if new_interval_if_gti_sep is not None:
compulsory_edges = find_large_bad_time_intervals(gtis, new_interval_if_gti_sep)

Check warning on line 1807 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1803-L1807

Added lines #L1803 - L1807 were not covered by tests
Expand All @@ -1813,7 +1813,7 @@ def split_gtis_by_exposure(gtis, exposure_per_chunk, new_interval_if_gti_sep=Non
final_gti_list.extend(local_split_gtis)
return final_gti_list

Check warning on line 1814 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1809-L1814

Added lines #L1809 - L1814 were not covered by tests

n_intervals = int(np.rint(total_exposure / exposure_per_chunk))
n_intervals = int(np.rint(rough_total_exposure / exposure_per_chunk))

Check warning on line 1816 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1816

Added line #L1816 was not covered by tests

if n_intervals <= 1:
return np.asarray([gtis])

Check warning on line 1819 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1818-L1819

Added lines #L1818 - L1819 were not covered by tests
Expand All @@ -1836,11 +1836,10 @@ def split_gtis_by_exposure(gtis, exposure_per_chunk, new_interval_if_gti_sep=Non
for g in gtis:
exposure_edges.append(last_exposure)
last_exposure += g[1] - g[0]
total_exposure = last_exposure

Check warning on line 1839 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1834-L1839

Added lines #L1834 - L1839 were not covered by tests

exposure_edges = np.asarray(exposure_edges)

Check warning on line 1841 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1841

Added line #L1841 was not covered by tests

total_exposure = last_exposure

exposure_per_interval = total_exposure / n_intervals
exposure_intervals = np.arange(0, total_exposure + exposure_per_interval, exposure_per_interval)

Check warning on line 1844 in stingray/gti.py

View check run for this annotation

Codecov / codecov/patch

stingray/gti.py#L1843-L1844

Added lines #L1843 - L1844 were not covered by tests

Expand Down

0 comments on commit f8fe13b

Please sign in to comment.