xpsi-group / xpsi

X-PSI: X-ray Pulse Simulation and Inference
Other
34 stars 21 forks source link

Do not always round down when saving synthetic data as integers #366

Closed thjsal closed 4 months ago

thjsal commented 7 months ago

Examples in Modeling tutorial and in examples_fast directory currently always round down the float values when saving the newly created synthetic data as integers in this line:

np.savetxt(os.path.join(directory, name+'_realisation.dat'),
           synthetic,
           fmt = '%u')

To avoid systematic differences between the model and the synthetic data, it would be better to round the numbers here to the nearest integers using e.g., np.round(synthetic).

DevarshiChoudhury commented 6 months ago

I was thinking about this and while it deviates from the model prediction, perhaps the choice to truncate it (i.e., e.g.,5.99 and 5.01 both become 5) was made since counts have to be whole numbers and shouldn't exceed what the model predicts

thjsal commented 6 months ago

I wonder though why the detection could not exceed what the model predicts. If the model predicts 5.99 counts for a one phase-energy bin, I would still think that I would most likely observe 6 counts instead of 5 counts.

thjsal commented 5 months ago

I realized this issue was a bit self made actually. The numbers are indeed already in integers if using the signal in which noise has been added. Only if saving the non-noisy data in the integer format (as Bas and I were testing), one should be careful in how the numbers are rounded. I added example of this as a commented line of code in the linked pull request.