-
Notifications
You must be signed in to change notification settings - Fork 10
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 Quantization effect #308
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev_master #308 +/- ##
==============================================
+ Coverage 80.28% 80.34% +0.06%
==============================================
Files 147 148 +1
Lines 14844 14898 +54
==============================================
+ Hits 11917 11970 +53
- Misses 2927 2928 +1 ☔ View full report in Codecov by Sentry. |
Awesome! Can't wait to add these to the IRDB. Specifying a signed dtype will 'wrap around' on overflow to negative values. Having a positive flux value be converted to negative values is probably never what the end users wants, as no detector works this way: my_data = np.array([3.8, 8.1, 130000.2])
np.floor(my_data).astype("uint16")
# Works fine, overflow capped to maximum value:
# array([ 3, 8, 64464], dtype=uint16)
np.floor(my_data).astype("int16")
# Works against users intentions, overflow wraps around to negative values:
# array([ 3, 8, -1072], dtype=int16) Note that the non-linearity effect should have already replaced values that are larger than what the detector can measure with the maximum value (that is, the saturation value). However, the non-linearity effect is not always turned on. The simplest change would be to simply disallow using signed integer types completely. Another option would be to explicitly replace values with the maximum and minimum, e.g.
The default is |
Thanks for considering these edge-cases! Maybe for now it would be fine to log a warning when a signed integer type is used? |
A warning would be good as well |
Add a new effect
electronic.Quantization
, which does the "flooring" previously performed withinShotNoise
and also sets the data type tounsigned integer
(32 bit) by default. This can be changed by passing thedtype
keyword argument to any dtype accepted by Numpy. A warning will be logged if the selected data type is not an integer, since usually the outcome of flooring should be some kind of integer.Warning
As this takes the flooring out of
ShotNoise
, it will probably (slightly) change (increase) any previous output unless the newQuantization
effect is added in the corresponding IRDB YAML file.