NuSTAR / nustar-gen-utils

Repository for (hopefully) useful NuSTAR python tools
MIT License
9 stars 9 forks source link

Issue with how the bitwise operators (like ~) are used #114

Closed qwert3434 closed 11 months ago

qwert3434 commented 1 year ago

In some functions (like wrapper.extract_det1_events), (~clobber) are used to reverse the Bool parameters. This is causing new files not being generated whether clobber is True or False. "not clobber" should be used instead of ~clobber. Because ~ is a bitwise operator so ~True will be ~(0001)=1110 which is -2 in two's complement. (A simple test result is attached)

There are other places that uses bitwise operators like util.straylight_background it uses "all_mask = all_mask & ~rm"(line 495). Both & and ~ are bitwise operators. I didn't check exactly what the code wants to do but they are not the same with 'and' and 'not' operators. Since there's an issue with using ~clobber, the use of other bitwise operators might need a double check as well. bitwise_operator_issue

bwgref commented 1 year ago

It's great to call this out. Next step is to submit a pull request that fixes this.

qwert3434 commented 1 year ago

It's great to call this out. Next step is to submit a pull request that fixes this.

Cool. I will fix it and run some tests locally first to make sure it works as intended, then submit a pull request.

bwgref commented 11 months ago

Closed in #115