Vindaar / TimepixAnalysis

Contains code related to calibration and analysis of Timepix based detector + CAST related code
MIT License
20 stars 6 forks source link

[calibration] FeSpectrumCharge is of unexpected shape #39

Closed Vindaar closed 12 months ago

Vindaar commented 5 years ago

The Fe spectrum dataset of the charge values has an unexpected shape.

Since it's a 1D dataset, we normally would expect the shape to be (<num elements>, 1).

However, indeed it is just (<num elements>).

This itself is not a "problem", but it is unexpected. Originally I was of the opinion that a shape as such was not supported in HDF5 (no idea why exactly).

It happens due to the way we create that dataset. It's the only one we create with the write_dataset convienience proc: In TPA: https://github.com/Vindaar/TimepixAnalysis/blob/master/Analysis/ingrid/calibration.nim#L1068 In nimhdf5: https://github.com/Vindaar/nimhdf5/blob/master/src/nimhdf5/datasets.nim#L527-L531

whereas the other FeSpectrum* datasets are created as usual here: https://github.com/Vindaar/TimepixAnalysis/blob/master/Analysis/ingrid/calibration.nim#L744-L752 using create_dataset directly. It's interesting though that write_dataset hands the data.shape directly, which for a 1D dataset will just be @[<num_elements>]. On the other hand create_dataset in the FeSpectrum cases above is being called with an integer (nEventsPassed = eventSpectrum.len). So the "problem" is that in create_dataset the parsing of an int number of elements maps this to a tuple here: https://github.com/Vindaar/nimhdf5/blob/master/src/nimhdf5/datasets.nim#L376 whereas a sequence will be taken as is (a couple lines below). In this way it's actually a bug / design issue in nimhdf5.

Vindaar commented 12 months ago

Nowadays we want the datasets to be (<num elements>) and not (<num elements>, 1) anymore.