MythenFileReader¶
File reader to read mythen hdf5 files written by Epics.
The EpicsMythenFileReader inherits from a wrapper class based on the C++ API of the HDF5 C Library. The provided dataset need to have fields data storing the photon counts,
DetectorAngle storing the detector position in degrees and CounterMask storing which counters are active. The field CounterMask stores an integer representation of a 3-digit bit string, where each bit is set to 1 if the counter is active.
Example¶
CounterMask: 4 // binary representation 1 0 0
only channel 0 is active
CounterMask: 3 // binary representation 0 1 1
channel 1 and 2 are active
-
class EpicsMythenFileReader : public angcal::HDF5FileReader¶
class to read a series of MythenFiles following Epics file format (e.g. base_name_0000.h5, base_name_0001.h5, …). Frames are indexed consecutively over all files of the series, when all frames of a file are read the next file is opened.
Public Functions
-
EpicsMythenFileReader(const std::filesystem::path &fname, std::optional<const std::filesystem::path> incident_intensities_filename = std::nullopt)¶
-
std::tuple<EpicsMythenHeader, MythenFrame> read_frame()¶
-
std::tuple<EpicsMythenHeader, MythenFrame> read_frame(size_t frame_index)¶
-
std::tuple<NDArray<EpicsMythenHeader, 1>, NDArray<uint32_t, 2>> read_n(size_t n_frames)¶
-
void read_into(std::byte *buffer, EpicsMythenHeader *header = nullptr)¶
-
void read_into(std::byte *buffer, size_t n_frames, EpicsMythenHeader *headers = nullptr)¶
-
EpicsMythenHeader read_header(size_t frame_index)¶
read header of frame at frame_index, does NOT move cursor
-
double read_detector_angle(size_t frame_index) const¶
-
uint64_t read_incident_intensity(size_t frame_index)¶
-
void seek(size_t frame_index)¶
-
size_t tell() const¶
-
size_t total_frames() const¶
-
size_t n_files() const¶
-
size_t pixels_per_frame() const¶
-
size_t bytes_per_frame() const¶
-
std::filesystem::path current_file() const¶
-
std::string base_name() const¶
-
inline void open_file(const std::string &filename_)¶
-
inline void close_file()¶
-
inline HDF5Dataset get_dataset(const std::string &dataset_name) const¶
Private Functions
-
void parse_fname(const std::filesystem::path &fname)¶
-
void scan_files()¶
-
void open_file(size_t file_index)¶
-
std::filesystem::path fpath(size_t file_index) const¶
-
size_t get_file_index(size_t frame_index) const¶
index of the file in the series storing frame_index
-
size_t frame_index_in_file(size_t frame_index) const¶
index of frame_index within its file
-
template<typename T>
T read_attribute(const std::string &dataset_name, size_t frame_index) const¶ reads the value of an NDAttributes dataset for frame_index
Note
throws if the dataset does not exist or if the data type of the dataset does not match T
- Parameters:
dataset_name – name of dataset in /entry/instrument/NDAttributes/
frame_index – index of the frame to read the attribute for
- Returns:
value of the attribute
-
template<typename T>
void check_dtype() const¶ throws if T does not match the data type of the photon counts
Private Members
-
std::filesystem::path m_path = {}¶
-
std::string m_base_name = {}¶
-
size_t m_max_digits_file_index = {}¶
-
size_t m_offset = {0}¶
-
size_t m_current_file_index = {0}¶
-
size_t m_current_frame_index = {0}¶
-
std::vector<size_t> m_last_frame_in_file = {}¶
-
size_t m_total_frames = {0}¶
-
size_t m_cols = {}¶
number of strips per frame
-
const std::type_info *m_dtype = {nullptr}¶
data type of photon counts
-
std::ifstream incident_intensities_file = {}¶
-
EpicsMythenFileReader(const std::filesystem::path &fname, std::optional<const std::filesystem::path> incident_intensities_filename = std::nullopt)¶
MythenFrame¶
-
struct MythenFrame : public aare::Frame¶
Public Functions
-
MythenFrame() = delete¶
-
inline MythenFrame(aare::Frame &&frame)¶
-
MythenFrame(MythenFrame&&) = default¶
-
inline NDView<uint32_t, 1> photon_counts()¶
photon counts for each channel stored as 1d array
-
inline uint32_t photon_counts(size_t col, size_t row = 0) const¶
photon counts at specfic channel
- Parameters:
col – channel index
row – row index (default: 0)
-
inline ssize_t size() const¶
size of frame (given in pixels)
-
MythenFrame() = delete¶
MythenHeader¶
-
struct EpicsMythenHeader¶
Public Members
-
double detector_angle = {}¶
detector angle of the acquisition [degrees]
-
uint64_t incident_intensity = {}¶
incident intensity of the acquisition
-
double exposure_time = {}¶
exposure time in seconds
-
std::array<uint8_t, 3> channel_mask = {}¶
counter mask given as binary representation (counter 0 is most significant bit)
-
double detector_angle = {}¶