ClusterFile¶
-
template<typename ClusterType, typename Enable = std::enable_if_t<is_cluster_v<ClusterType>>>
class ClusterFile¶ Class to read and write cluster files Expects data to be laid out as:
int32_t frame_number uint32_t number_of_clusters int16_t x, int16_t y, int32_t data[9] * number_of_clusters int32_t frame_number uint32_t number_of_clusters etc.
Public Functions
-
inline ClusterFile(const std::filesystem::path &fname, size_t chunk_size = 1000, const std::string &mode = "r")¶
Construct a new Cluster File object.
- Parameters:
fname – path to the file
chunk_size – number of clusters to read at a time when iterating over the file
mode – mode to open the file in. “r” for reading, “w” for writing, “a” for appending
- Throws:
std::runtime_error – if the file could not be opened
-
inline ~ClusterFile()¶
-
inline ClusterVector<ClusterType> read_clusters(size_t n_clusters)¶
Read n_clusters clusters from the file discarding frame numbers. If EOF is reached the returned vector will have less than n_clusters clusters.
-
inline ClusterVector<ClusterType> read_frame()¶
Read a single frame from the file and return the clusters. The cluster vector will have the frame number set.
- Throws:
std::runtime_error – if the file is not opened for reading or the file pointer not at the beginning of a frame
-
inline void write_frame(const ClusterVector<ClusterType> &clusters)¶
-
inline size_t chunk_size() const¶
Return the chunk size.
-
inline void set_roi(ROI roi)¶
Set the region of interest to use when reading clusters. If set only clusters within the ROI will be read.
-
inline void set_noise_map(const NDView<int32_t, 2> noise_map)¶
Set the noise map to use when reading clusters. If set clusters below the noise level will be discarded. Selection criteria one of: Central pixel above noise, highest 2x2 sum above 2 * noise, total sum above 3 * noise.
-
inline void set_gain_map(const NDView<double, 2> gain_map)¶
Set the gain map to use when reading clusters. If set the gain map will be applied to the clusters that pass ROI and noise_map selection. The gain map is expected to be in ADU/energy.
-
inline void set_gain_map(const InvertedGainMap &gain_map)¶
-
inline void set_gain_map(const InvertedGainMap &&gain_map)¶
-
inline void close()¶
Close the file. If not closed the file will be closed in the destructor.
-
inline void open(const std::string &mode)¶
Open the file in specific mode.
Private Functions
-
ClusterVector<ClusterType> read_clusters_with_cut(size_t n_clusters)¶
-
ClusterVector<ClusterType> read_clusters_without_cut(size_t n_clusters)¶
-
ClusterVector<ClusterType> read_frame_with_cut()¶
-
ClusterVector<ClusterType> read_frame_without_cut()¶
-
bool is_selected(ClusterType &cl)¶
-
ClusterType read_one_cluster()¶
-
inline ClusterFile(const std::filesystem::path &fname, size_t chunk_size = 1000, const std::string &mode = "r")¶