Skip to content

Commit

Permalink
bug fixing binning function
Browse files Browse the repository at this point in the history
  • Loading branch information
hposborn committed Nov 21, 2024
1 parent 3453c39 commit 7203a8a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions MonoTools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,14 +1423,13 @@ def bin_light_curve(time, flux, flux_err= None,
if new_time_bins is None:
# Create bins based on the specified bin_time
bins = np.arange(np.nanmin(time), np.nanmax(time) + 2 * bin_time, bin_time)
bin_indices = np.digitize(time, bins) - 1
else:
avbinsize=np.nanmedian(np.diff(new_time_bins))
#Making bin divisions half way between each defined x point here
bins=np.hstack((new_time_bins[0]-avbinsize,0.5*(new_time_bins[:-1]+new_time_bins[1:]),new_time_bins[-1]+0.5*avbinsize))
bin_indices = np.digitize(time, bins)
bins=np.hstack((new_time_bins[0]-avbinsize,0.5*(new_time_bins[:-1]+new_time_bins[1:]),new_time_bins[-1]+0.5*avbinsize,new_time_bins[-1]+1.5*avbinsize))

# Digitize the time array into the created bins
bin_indices = np.digitize(time, bins) - 1
print(bin_indices)

# Find non-empty bins
Expand Down

0 comments on commit 7203a8a

Please sign in to comment.