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

Fix count rate estimation error for particularly bad GTIs #798

Merged
merged 3 commits into from
Feb 21, 2024

Conversation

matteobachetti
Copy link
Member

@matteobachetti matteobachetti commented Feb 8, 2024

In StingrayTimeseries.fill_bad_time_intervals, when the buffer size is small and count rates are low, there was the possibility that the count rate estimation failed with a numpy error. E.g., the test test_no_counts_in_buffer I added failed. Here, I catch the condition and warn that this is happening. Also, I made the estimation more robust when only one of the GTIs on the side of the bad time intervals has good data.

@pep8speaks
Copy link

pep8speaks commented Feb 8, 2024

Hello @matteobachetti! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-02-21 09:20:51 UTC

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5777271) 96.27% compared to head (5778e1f) 96.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #798      +/-   ##
==========================================
+ Coverage   96.27%   96.39%   +0.11%     
==========================================
  Files          44       44              
  Lines        8855     8866      +11     
==========================================
+ Hits         8525     8546      +21     
+ Misses        330      320      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@dhuppenkothen dhuppenkothen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a philosophical level, I think I'd prefer an if-else logic where you first try to set either ctrate variable to something sensible and only if that doesn't work set it to NaN, rather than set it to NaN by default. This is mainly because it makes it easier to think through the logic ("this should be a value, and if it's not, we'll set it to NaN so things fail gracefully"). But that seems like a bit of an abstract point I'm not sure is worth arguing about. :)

@matteobachetti
Copy link
Member Author

Good point. Sometimes I tend to think about the logic that makes it easier to cover all options with tests, rather than making the code easier to read 😅. I changed the logic slightly following your suggested approach

@matteobachetti matteobachetti added this pull request to the merge queue Feb 21, 2024
Merged via the queue into main with commit 72816e0 Feb 21, 2024
16 of 17 checks passed
@matteobachetti matteobachetti deleted the fix_ctrate_estimation branch February 21, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants