Candmaker doesn't centre the wide pulses (width > 2) if DM is low and native time sampling of data is large
sujaymate opened this issue · comments
Describe the bug
I am running your_candmaker
on a data with ~16 ms native time-sampling and it doesn't centre the pulse if the width is > 2 and DM is low. After little bit of debugging I think there is a bug in the candmaker.py
in the if block below:
Lines 191 to 205 in 8845caf
I think this happens only if the DM of the pulse is low and time sampling is large. In this case, the nsamp
is less than self.min_samp
. So if the width is > 2, the if block at line 196 is evaluated as true. Then the variables nsamp_read
and nstart_read
are redefined. In this case the if
/else
block on line 199 and 202 is treated as independent block and the else
is evaluated to be true as nsamp_read > self.min_samp
setting the nsamp_read
back to nstart
. This means the pulse is not centred. A simple fix is to replace if
statement on line 199 with elif
so the entire if
/else
block between 196 to 202 is treated as one and not two independent ones.
To Reproduce
Running candmaker on pulses with width > 2, low DM and large native time-sampling.
Expected behavior
I think the if
statement on line 199 above should be replaced with elif
. Screenshots of buggy behaviour and expected behaviour below.
Screenshots
An example of the bug. In this case, the nsample_read
is reset by the else
block.
If the second if
is replaced with elif
, then the behaviour is correct and value set by the first if
block will be used as final one (which is the correct one)
Versions (please provide the versions of the the following packages):
- your: 0.6.7
- matplotlib: 3.3.2
- numpy: 1.19.2
- h5py: 2.10.0
- scikit-image: Not using
- scipy: 1.6.1
- numba: 0.51.2
- astropy: 4.0.2
- pandas: 1.1.3
- rich: 12.6.0
If someone from the devs confirm the bug, I can fix it and create a pull request.
Hi, @sujaymate please go ahead and submit a PR. Thanks.
Hi @devanshkv , created the PR.
Fixed with #105/