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

Off-by-one bug in gain estimated by the charging model #404

Closed
lucabaldini opened this issue Sep 20, 2022 · 0 comments
Closed

Off-by-one bug in gain estimated by the charging model #404

lucabaldini opened this issue Sep 20, 2022 · 0 comments
Assignees

Comments

@lucabaldini
Copy link
Owner

The following line in instrument/charging.py:

g = self.__gain_data[:,:,i-1]

introduces a subtle bug, as we later update the value of g in place before assigning it to the next time slice:

g -= r.T * delta_max / k_c * (1 - delta / delta_max) * dt
g += delta / tau_d * dt
self.__gain_data[:,:,i] = g

and this is actually updating the value of the gain either at time slice i (which is what we want) and at time slice i-1 (which we don't). As a result, at the end of the loop, the gain is off by one everywhere but in the very last bin.

Luckily, all we have to do is to replace the incriminated line with:

g = numpy.copy(self.__gain_data[:,:,i-1])

and we are good.

Original url: https://bitbucket.org/ixpesw/ixpeobssim/issues/404
Created on 2021-04-07T11:06:57.360903+00:00

@lucabaldini lucabaldini self-assigned this Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant