Modifications in preparation to MAX IV experiment

This commit is contained in:
2024-01-27 21:23:56 +01:00
parent 2446643489
commit f5f86d9ab6
250 changed files with 9363 additions and 3022 deletions

View File

@@ -8,14 +8,14 @@
#include "../writer/HDF5Writer.h"
#include "../writer/HDF5NXmx.h"
#include "../compression/JFJochCompressor.h"
#include "../image_analysis/RadialIntegrationProfile.h"
#include "../image_analysis/AzimuthalIntegrationProfile.h"
using namespace std::literals::chrono_literals;
TEST_CASE("HDF5DataSet_scalar", "[HDF5][Unit]") {
uint16_t tmp_scalar = 16788;
{
HDF5File file("scratch1.h5", true, true, false);
HDF5File file("scratch1.h5", true, false);
file.SaveScalar("scalar", tmp_scalar);
}
{
@@ -38,7 +38,7 @@ TEST_CASE("HDF5DataSet_string", "[HDF5][Unit]") {
std::string tmp_string = "HDF5Content";
{
HDF5File file("scratch2.h5", true, true, false);
HDF5File file("scratch2.h5", true, false);
file.SaveScalar("str", tmp_string);
}
{
@@ -62,7 +62,7 @@ TEST_CASE("HDF5DataSet_vector", "[HDF5][Unit]") {
{
RegisterHDF5Filter();
HDF5File file("scratch3.h5", true, true, false);
HDF5File file("scratch3.h5", true, false);
file.SaveVector("vec", tmp_vector);
}
@@ -94,18 +94,18 @@ TEST_CASE("HDF5DataSet_vector", "[HDF5][Unit]") {
TEST_CASE("HDF5File_Delete", "[HDF5][Unit]") {
uint16_t tmp_scalar = 16788;
{
HDF5File file("scratch1.h5", true, true, false);
HDF5File file("scratch1.h5", true, false);
file.SaveScalar("scalar", tmp_scalar);
}
{
HDF5File file("scratch1.h5", false, true, false);
HDF5File file("scratch1.h5", false, false);
std::unique_ptr<HDF5DataSet> scalar_dataset;
REQUIRE_NOTHROW(scalar_dataset = std::make_unique<HDF5DataSet>(file, "scalar"));
file.Delete("/scalar");
}
{
HDF5File file("scratch1.h5", false, true, false);
HDF5File file("scratch1.h5", false, false);
std::unique_ptr<HDF5DataSet> scalar_dataset;
REQUIRE_THROWS(scalar_dataset = std::make_unique<HDF5DataSet>(file, "scalar"));
}
@@ -123,7 +123,7 @@ TEST_CASE("HDF5MasterFile", "[HDF5][Full]") {
StartMessage start_message;
x.FillMessage(start_message);
EndMessage end_message;
end_message.number_of_images = x.GetImageNum();
end_message.max_image_number = x.GetImageNum();
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
x.FilePrefix("test02");
@@ -142,20 +142,20 @@ TEST_CASE("HDF5MasterFile_RadInt", "[HDF5][Full]") {
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);
x.QSpacingForAzimInt_recipA(0.1).LowQForAzimInt_recipA(0.1).HighQForAzimInt_recipA(4);
x.FilePrefix("test01_rad_int").ImagesPerTrigger(950);
RadialIntegrationMapping mapping(x);
RadialIntegrationProfile profile(mapping, x);
AzimuthalIntegrationMapping mapping(x);
AzimuthalIntegrationProfile profile(mapping);
StartMessage start_message;
x.FillMessage(start_message);
start_message.rad_int_bin_to_q = mapping.GetBinToQ();
start_message.az_int_bin_to_q = mapping.GetBinToQ();
EndMessage end_message;
end_message.number_of_images = x.GetImageNum();
end_message.rad_int_result["avg1"] = profile.GetResult();
end_message.rad_int_result["avg2"] = profile.GetResult();
end_message.max_image_number = x.GetImageNum();
end_message.az_int_result["avg1"] = profile.GetResult();
end_message.az_int_result["avg2"] = profile.GetResult();
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}
@@ -227,9 +227,9 @@ 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);
x.QSpacingForAzimInt_recipA(0.1).LowQForAzimInt_recipA(0.1).HighQForAzimInt_recipA(4);
RadialIntegrationMapping mapping(x);
AzimuthalIntegrationMapping mapping(x);
std::vector<float> rad_int_profile(mapping.GetBinNumber(), 4.0);
std::vector<float> rad_int_avg(mapping.GetBinNumber(), 0.33);
@@ -237,7 +237,7 @@ TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
x.FilePrefix("test02_1p10_rad_int").ImagesPerTrigger(5).DataFileCount(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
StartMessage start_message;
x.FillMessage(start_message);
start_message.rad_int_bin_to_q = mapping.GetBinToQ();
start_message.az_int_bin_to_q = mapping.GetBinToQ();
HDF5Writer file_set(start_message);
std::vector<uint16_t> image(x.GetPixelsNum());
@@ -246,7 +246,7 @@ TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
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.az_int_profile = std::vector<float>(mapping.GetBinNumber(), i);
message.number = i;
REQUIRE_NOTHROW(file_set.Write(message));
@@ -268,7 +268,7 @@ TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
x.FillMessage(start_message);
EndMessage end_message;
end_message.number_of_images = x.GetImageNum();
end_message.max_image_number = x.GetImageNum();
HDF5Writer writer(start_message);
std::vector<uint16_t> image(x.GetPixelsNum());
@@ -288,7 +288,7 @@ TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}
{
HDF5File file("vds_master.h5", false, true, false);
HDF5File file("vds_master.h5", false, false);
std::unique_ptr<HDF5DataSet> dataset;
REQUIRE_NOTHROW(dataset = std::make_unique<HDF5DataSet>(file,"/entry/data/data"));
HDF5DataSpace file_space(*dataset);
@@ -322,7 +322,7 @@ TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
x.FillMessage(start_message);
EndMessage end_message;
end_message.number_of_images = x.GetImageNum() - 1;
end_message.max_image_number = x.GetImageNum() - 1;
HDF5Writer writer(start_message);
@@ -344,12 +344,12 @@ TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}
{
HDF5File file("vds_missing_master.h5", false, true, false);
HDF5File file("vds_missing_master.h5", false, false);
std::unique_ptr<HDF5DataSet> dataset;
REQUIRE_NOTHROW(dataset = std::make_unique<HDF5DataSet>(file,"/entry/data/data"));
HDF5DataSpace file_space(*dataset);
REQUIRE(file_space.GetNumOfDimensions() == 3);
REQUIRE(file_space.GetDimensions()[0] == x.GetImageNum()-1);
REQUIRE(file_space.GetDimensions()[0] == x.GetImageNum() -1);
REQUIRE(file_space.GetDimensions()[1] == x.GetYPixelsNum());
REQUIRE(file_space.GetDimensions()[2] == x.GetXPixelsNum());
@@ -378,7 +378,7 @@ TEST_CASE("HDF5Writer_VDS_zero_images", "[HDF5][Full]") {
x.FillMessage(start_message);
EndMessage end_message;
end_message.number_of_images = 0;
end_message.max_image_number = 0;
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}