fixing read bug

This commit is contained in:
froejdh_e 2025-01-10 15:33:56 +01:00
parent caf7b4ecdb
commit 7550a2cb97
3 changed files with 20 additions and 20 deletions

View File

@ -75,18 +75,18 @@ void define_cluster_finder_mt_bindings(py::module &m) {
.def("sync", &ClusterFinderMT<uint16_t, pd_type>::sync)
.def("stop", &ClusterFinderMT<uint16_t, pd_type>::stop)
.def("start", &ClusterFinderMT<uint16_t, pd_type>::start)
.def_property_readonly("pedestal",
[](ClusterFinderMT<uint16_t, pd_type> &self) {
.def("pedestal",
[](ClusterFinderMT<uint16_t, pd_type> &self, size_t thread_index) {
auto pd = new NDArray<pd_type, 2>{};
*pd = self.pedestal();
*pd = self.pedestal(thread_index);
return return_image_data(pd);
})
.def_property_readonly("noise",
[](ClusterFinderMT<uint16_t, pd_type> &self) {
},py::arg("thread_index") = 0)
.def("noise",
[](ClusterFinderMT<uint16_t, pd_type> &self, size_t thread_index) {
auto arr = new NDArray<pd_type, 2>{};
*arr = self.noise();
*arr = self.noise(thread_index);
return return_image_data(arr);
});
},py::arg("thread_index") = 0);
}
void define_cluster_collector_bindings(py::module &m) {

View File

@ -35,7 +35,7 @@ void define_cluster_file_io_bindings(py::module &m) {
[](ClusterFile &self) {
auto v = new ClusterVector<int32_t>(self.read_frame());
return v;
},py::return_value_policy::take_ownership)
})
.def("write_frame", &ClusterFile::write_frame)
.def("read_cluster_with_cut",
[](ClusterFile &self, size_t n_clusters,

View File

@ -72,7 +72,7 @@ ClusterVector<int32_t> ClusterFile::read_clusters(size_t n_clusters) {
} else {
nn = nph;
}
nph_read += fread(reinterpret_cast<void *>(buf + nph_read),
nph_read += fread((buf + nph_read*clusters.item_size()),
clusters.item_size(), nn, fp);
m_num_left = nph - nn; // write back the number of photons left
}
@ -87,7 +87,7 @@ ClusterVector<int32_t> ClusterFile::read_clusters(size_t n_clusters) {
else
nn = nph;
nph_read += fread(reinterpret_cast<void *>(buf + nph_read),
nph_read += fread((buf + nph_read*clusters.item_size()),
clusters.item_size(), nn, fp);
m_num_left = nph - nn;
}