HDF5DataFile: Save radial integration result
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <iostream>
|
||||
#include <bitshuffle/bitshuffle.h>
|
||||
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../writer/HDF5Objects.h"
|
||||
#include "../writer/HDF5Writer.h"
|
||||
#include "../writer/HDF5NXmx.h"
|
||||
#include "../compression/JFJochCompressor.h"
|
||||
#include "../image_analysis/RadialIntegrationProfile.h"
|
||||
|
||||
using namespace std::literals::chrono_literals;
|
||||
|
||||
@@ -195,6 +195,41 @@ TEST_CASE("HDF5Writer_Spots", "[HDF5][Full]") {
|
||||
REQUIRE (H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
|
||||
RadialIntegrationMapping mapping(x);
|
||||
RadialIntegrationProfile profile(mapping);
|
||||
|
||||
std::vector<float> rad_int_profile(mapping.GetBinNumber(), 4.0);
|
||||
std::vector<float> rad_int_avg(mapping.GetBinNumber(), 0.33);
|
||||
|
||||
x.FilePrefix("test02_1p10_spots").ImagesPerTrigger(5).DataFileCount(2).Compression(JFJochProtoBuf::NO_COMPRESSION);
|
||||
StartMessage start_message;
|
||||
x.FillMessage(start_message);
|
||||
start_message.rad_int_bin_to_q = mapping.GetBinToQ();
|
||||
|
||||
HDF5Writer file_set(start_message);
|
||||
std::vector<uint16_t> image(x.GetPixelsNum());
|
||||
|
||||
for (int i = 0; i < x.GetImageNum(); i++) {
|
||||
DataMessage message{};
|
||||
message.image.data = (uint8_t *) image.data();
|
||||
message.image.size = x.GetPixelsNum() * x.GetPixelDepth();
|
||||
message.rad_int_profile = std::vector<float>(mapping.GetBinNumber(), i);
|
||||
message.number = i;
|
||||
|
||||
REQUIRE_NOTHROW(file_set.Write(message));
|
||||
}
|
||||
}
|
||||
// No leftover HDF5 objects
|
||||
REQUIRE (H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
|
||||
DiffractionExperiment x(DetectorGeometry(1));
|
||||
|
||||
@@ -345,7 +380,6 @@ TEST_CASE("HDF5Objects_ExtractFilename", "[HDF5]") {
|
||||
REQUIRE(ExtractFilename("dir1/dir2/filename_data_000001.h5") == "filename_data_000001.h5");
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("HDF5DataType", "[HDF5]") {
|
||||
HDF5DataType type1(1,true);
|
||||
REQUIRE(type1.GetElemSize() == 1);
|
||||
|
||||
+23
-10
@@ -5,9 +5,10 @@
|
||||
#include "../compression/JFJochCompressor.h"
|
||||
|
||||
HDF5DataFile::HDF5DataFile(const std::string &in_filename, int64_t width, int64_t height,
|
||||
int64_t pixel_depth_byte, bool is_signed, CompressionAlgorithm compression,
|
||||
int64_t pixel_depth_byte, bool is_signed, const std::vector<float>& in_rad_int_bin_to_q,
|
||||
CompressionAlgorithm compression,
|
||||
size_t in_max_spots) : data_type(pixel_depth_byte, is_signed),
|
||||
max_spots(in_max_spots) {
|
||||
max_spots(in_max_spots), rad_int_bin_to_q(in_rad_int_bin_to_q) {
|
||||
max_image_number = 0;
|
||||
nimages = 0;
|
||||
|
||||
@@ -27,14 +28,17 @@ HDF5DataFile::~HDF5DataFile() {
|
||||
data_set.reset();
|
||||
|
||||
if (!spot_count.empty()) {
|
||||
HDF5Group group(*data_file, "/entry/result");
|
||||
group.NXClass("NXcollection");
|
||||
std::vector<hsize_t> dims = {spot_count.size(), max_spots};
|
||||
group.SaveVector("nPeaks", spot_count);
|
||||
group.SaveVector("peakXPosRaw", spot_x, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
group.SaveVector("peakYPosRaw", spot_y, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
group.SaveVector("peakTotalIntensity", spot_intensity, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
group.SaveVector("indexingResult", indexing_result);
|
||||
result_group->SaveVector("nPeaks", spot_count);
|
||||
result_group->SaveVector("peakXPosRaw", spot_x, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
result_group->SaveVector("peakYPosRaw", spot_y, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
result_group->SaveVector("peakTotalIntensity", spot_intensity, dims, CompressionAlgorithm::BSHUF_LZ4);
|
||||
result_group->SaveVector("indexingResult", indexing_result);
|
||||
|
||||
if (!rad_int_bin_to_q.empty())
|
||||
rad_int_group->SaveVector("bin_to_q", rad_int_bin_to_q);
|
||||
if (!rad_int_file_avg.empty() && (rad_int_file_avg.size() == rad_int_bin_to_q.size()))
|
||||
rad_int_group->SaveVector("file_avg", rad_int_file_avg);
|
||||
|
||||
HDF5Group group_exp(*data_file, "/entry/jungfrau");
|
||||
group_exp.NXClass("NXcollection");
|
||||
@@ -42,7 +46,8 @@ HDF5DataFile::~HDF5DataFile() {
|
||||
group_exp.SaveVector("info", jf_info);
|
||||
group_exp.SaveVector("timestamp", timestamp);
|
||||
}
|
||||
|
||||
rad_int_group.reset();
|
||||
result_group.reset();
|
||||
data_file.reset();
|
||||
}
|
||||
|
||||
@@ -51,6 +56,11 @@ void HDF5DataFile::CreateFile() {
|
||||
HDF5Group(*data_file, "/entry").NXClass("NXentry");
|
||||
HDF5Group(*data_file, "/entry/data").NXClass("NXdata");
|
||||
|
||||
result_group = std::make_unique<HDF5Group>(*data_file, "/entry/result");
|
||||
result_group->NXClass("NXcollection");
|
||||
|
||||
rad_int_group = std::make_unique<HDF5Group>(*data_file, "/entry/result/rad_int");
|
||||
|
||||
HDF5DataSpace data_space({1, ypixel, xpixel},{H5S_UNLIMITED, ypixel, xpixel});
|
||||
data_set = std::make_unique<HDF5DataSet>(*data_file, "/entry/data/data", data_type, data_space, dcpl);
|
||||
|
||||
@@ -99,6 +109,9 @@ void HDF5DataFile::Write(const DataMessage &msg, uint64_t image_number) {
|
||||
bunch_id[image_number] = msg.bunch_id;
|
||||
jf_info[image_number] = msg.jf_info;
|
||||
timestamp[image_number] = msg.timestamp;
|
||||
|
||||
if (!msg.rad_int_profile.empty() && (msg.rad_int_profile.size() == rad_int_bin_to_q.size()))
|
||||
rad_int_group->SaveVector("img" + std::to_string(image_number), msg.rad_int_profile);
|
||||
}
|
||||
|
||||
HDF5DataFileStatistics HDF5DataFile::GetStatistics() const {
|
||||
|
||||
@@ -24,6 +24,9 @@ class HDF5DataFile {
|
||||
std::unique_ptr<HDF5File> data_file = nullptr;
|
||||
std::unique_ptr<HDF5DataSet> data_set = nullptr;
|
||||
|
||||
std::unique_ptr<HDF5Group> result_group = nullptr;
|
||||
std::unique_ptr<HDF5Group> rad_int_group = nullptr;
|
||||
|
||||
size_t xpixel;
|
||||
size_t ypixel;
|
||||
size_t max_image_number;
|
||||
@@ -37,6 +40,9 @@ class HDF5DataFile {
|
||||
std::vector<uint32_t> jf_info;
|
||||
std::vector<uint64_t> timestamp;
|
||||
|
||||
std::vector<float> rad_int_bin_to_q;
|
||||
std::vector<float> rad_int_file_avg;
|
||||
|
||||
std::vector<float> spot_x;
|
||||
std::vector<float> spot_y;
|
||||
std::vector<float> spot_intensity;
|
||||
@@ -48,9 +54,11 @@ class HDF5DataFile {
|
||||
void CreateFile();
|
||||
public:
|
||||
HDF5DataFile(const std::string& name, int64_t width, int64_t height, int64_t pixel_depth_byte,
|
||||
bool is_signed, CompressionAlgorithm compression = CompressionAlgorithm::BSHUF_LZ4,
|
||||
bool is_signed, const std::vector<float>& rad_int_bin_to_q,
|
||||
CompressionAlgorithm compression = CompressionAlgorithm::BSHUF_LZ4,
|
||||
size_t max_spots = 0);
|
||||
~HDF5DataFile();
|
||||
|
||||
void Write(const DataMessage& msg, uint64_t image_number);
|
||||
HDF5DataFileStatistics GetStatistics() const;
|
||||
size_t GetNumImages() const;
|
||||
|
||||
@@ -12,6 +12,7 @@ HDF5Writer::HDF5Writer(const StartMessage &request)
|
||||
request.image_size_x, request.image_size_y,
|
||||
request.pixel_bit_depth / 8,
|
||||
request.pixel_signed,
|
||||
request.rad_int_bin_to_q,
|
||||
request.compression_algorithm,
|
||||
request.max_spot_count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user