Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tolerance when computing "good segments" for ExposureBins and TimeEnergyBins #19

Open
AdamGoldstein-USRA opened this issue Dec 18, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@AdamGoldstein-USRA
Copy link
Collaborator

ExposureBins and TimeEnergyBins calculate "good segments," which are contiguous segments of data separated by bad time intervals (typically no data). This is determined by comparing the high edge of a bin to the low edge of the next bin, and if they are not the same, then the end of the good segment is declared, and a new segment starts. The implementation in ExposureBins, for example, is

mask = (self.lo_edges[1:] != self.hi_edges[:-1])

There are cases when self.lo_edges[1:] and self.hi_edges[:-1] are slightly different, usually by rounding/numerical precision limitations, especially on older files that use 32-bit floats. This causes an incorrect segmentation of the data. An improvement is to implement a tolerance:

mask = np.abs(self.lo_edges[1:] - self.hi_edges[:-1]) > tol

where tol is the tolerance in seconds allowed. As an example, tol=1e-4 is sufficient for BATSE continuous data.

The keyword option of tol could either be added as an option to the _calculate_good_segments() method and passed via an option in the initializer, or have the initializer set a private tolerance variable and _calculate_good_segments() uses that private variable.

@BillCleveland-USRA
Copy link
Contributor

Move the implementation fro CGRO to Core.

@AdamGoldstein-USRA
Copy link
Collaborator Author

This should also be applied to TimeChannelBins. An example of how this is addressed in gdt-cgro.

@AdamGoldstein-USRA AdamGoldstein-USRA added the enhancement New feature or request label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants