Build Packages / Build documentation (push) Successful in 1m47s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 22m9s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 12m31s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 13m14s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 22m22s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m55s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 5m55s
Build Packages / Unit tests (push) Successful in 1h3m54s
Build Packages / Validation Battery (push) Successful in 38m20s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 26m32s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 37m6s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 21m17s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 37m4s
Build Packages / Generate python client (push) Successful in 1m7s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 23m17s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 29m26s
Build Packages / Create release (push) Successful in 1m19s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 40m18s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 39m23s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 24m34s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 33m22s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 14m55s
* jfjoch_viewer: The file browser and the open dialog list every format the viewer opens, including frames numbered in their extension (`name.001`) and `.cbf.gz`, `.mccd`, `.sfrm`, `.nxs`, `.cxi` and `.xtc` files. * jfjoch_viewer: After processing a CBF, marCCD, SMV or SFRM sweep, the images stay on screen with the results drawn over them. * rugnux: No more Ceres thread warnings on machines with fewer than 16 CPU threads. Reviewed-on: #99 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
94 lines
4.5 KiB
C++
94 lines
4.5 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "JFJochReader.h"
|
|
#include "JFJochReaderSpots.h"
|
|
#include "HDF5ImageSource.h"
|
|
#include "HDF5MetadataSource.h"
|
|
#include "../writer/HDF5Objects.h"
|
|
#include "../image_analysis/IntegrationOutcome.h"
|
|
|
|
// Composes one shared raw-image source with one or more metadata sources ("snapshots") over the
|
|
// same images: the original _master.h5 plus optional reprocessing _process.h5 results. The active
|
|
// snapshot supplies the dataset and per-image metadata; the image source always supplies pixels,
|
|
// so switching snapshots never reloads image data.
|
|
//
|
|
// SWMR / growing files are NOT supported: a file opened here is expected to be final. Dataset
|
|
// extents, image counts and per-image metadata are read once at open and never re-polled, so a
|
|
// file still being written will be seen at whatever size it had at open - to pick up new frames,
|
|
// close and reopen it.
|
|
class JFJochHDF5Reader : public JFJochReader {
|
|
HDF5ImageSource image_source_;
|
|
std::map<std::string, std::shared_ptr<HDF5MetadataSource> > snapshots_;
|
|
std::shared_ptr<HDF5MetadataSource> active_metadata_;
|
|
std::string active_snapshot_;
|
|
size_t number_of_images = 0;
|
|
// False for a file of per-image analysis without the images (a _process.h5 of an input it could
|
|
// not link to): its images have metadata, and their pixels come from pixel_reader_ where one is given.
|
|
bool has_pixels = false;
|
|
JFJochReader *pixel_reader_ = nullptr;
|
|
|
|
bool LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset,
|
|
DataMessage &message,
|
|
std::vector<uint8_t> &buffer,
|
|
int64_t image_number,
|
|
bool update_dataset) override;
|
|
|
|
HDF5ImageLocator::Location GetImageLocation(int64_t image_number) const;
|
|
|
|
public:
|
|
~JFJochHDF5Reader() override = default;
|
|
|
|
// pixels is the reader of the sweep the file was processed from, for a file that holds no images of
|
|
// its own - the _process.h5 of a CBF, marCCD, SMV or SFRM sweep: image i of the file is then frame
|
|
// /entry/detector/number[i] of that sweep. The caller keeps it open while this file is.
|
|
void ReadFile(const std::string &filename, JFJochReader *pixels = nullptr);
|
|
|
|
uint64_t GetNumberOfImages() const override;
|
|
|
|
void Close() override;
|
|
|
|
// stride is the step in the SOURCE between consecutive images of the derived file: image i of the
|
|
// output comes from source image first_image + i * stride. Pass the stride the caller processed
|
|
// with, or the linked pictures and the per-image analysis describe different frames.
|
|
std::vector<HDF5DataSourceMessage> GetHDF5DataSource(
|
|
uint64_t first_image = 0,
|
|
std::optional<uint64_t> image_count = {},
|
|
uint64_t stride = 1
|
|
) const;
|
|
|
|
// Pixel format of the stored images. Needed by anything that links to them instead of writing
|
|
// its own, since the experiment describes the reader's container rather than the file.
|
|
[[nodiscard]] StoredPixelFormat GetStoredPixelFormat() const;
|
|
|
|
std::vector<IntegrationOutcome> ReadReflections(size_t start_image = 0, std::optional<size_t> end_image = {}) const;
|
|
|
|
std::vector<SpotToSave> ReadSpots(int64_t image) const override;
|
|
// True if the loaded file stores spot-finding results; false for a plain DECTRIS dataset (no
|
|
// /entry/MX), so callers can find spots instead of reusing absent ones.
|
|
[[nodiscard]] bool HasStoredSpots() const;
|
|
|
|
CompressedImage ReadCalibration(std::vector<uint8_t> &tmp, const std::string &name) const;
|
|
|
|
bool ReadRawImage(int64_t image_number, JFJochReaderRawImage &image) override;
|
|
|
|
// Metadata snapshots over the same images. The original file is registered as "Original" on
|
|
// ReadFile and is the initial active snapshot; reprocessing results can be added later.
|
|
void RegisterSnapshot(const std::string &name, const std::string &master_path);
|
|
void RemoveSnapshot(const std::string &name); // "Original" cannot be removed
|
|
void SetActiveSnapshot(const std::string &name);
|
|
std::vector<std::string> SnapshotNames() const;
|
|
std::string ActiveSnapshot() const;
|
|
|
|
// All snapshot datasets (name -> dataset), for overlaying every run's plots at once.
|
|
std::vector<std::pair<std::string, std::shared_ptr<const JFJochReaderDataset>>> AllSnapshotDatasets() const;
|
|
};
|