File writer and spot finding improvements

This commit is contained in:
2024-04-08 11:18:50 +02:00
parent 15d99c6162
commit c6d2b5eedf
72 changed files with 690 additions and 893 deletions

View File

@@ -15,7 +15,7 @@ using namespace std::literals::chrono_literals;
TEST_CASE("HDF5DataSet_scalar", "[HDF5][Unit]") {
uint16_t tmp_scalar = 16788;
{
HDF5File file("scratch1.h5", true, false);
HDF5File file("scratch1.h5");
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, false);
HDF5File file("scratch2.h5");
file.SaveScalar("str", tmp_string);
}
{
@@ -62,7 +62,7 @@ TEST_CASE("HDF5DataSet_vector", "[HDF5][Unit]") {
{
RegisterHDF5Filter();
HDF5File file("scratch3.h5", true, false);
HDF5File file("scratch3.h5");
file.SaveVector("vec", tmp_vector);
}
@@ -97,7 +97,7 @@ TEST_CASE("HDF5DataSet_vector_string", "[HDF5][Unit]") {
{
RegisterHDF5Filter();
HDF5File file("scratch4.h5", true, false);
HDF5File file("scratch4.h5");
REQUIRE_NOTHROW(file.SaveVector("vec", tmp_vector));
}
@@ -115,28 +115,6 @@ TEST_CASE("HDF5DataSet_vector_string", "[HDF5][Unit]") {
REQUIRE (H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
}
TEST_CASE("HDF5File_Delete", "[HDF5][Unit]") {
uint16_t tmp_scalar = 16788;
{
HDF5File file("scratch1.h5", true, false);
file.SaveScalar("scalar", tmp_scalar);
}
{
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, false);
std::unique_ptr<HDF5DataSet> scalar_dataset;
REQUIRE_THROWS(scalar_dataset = std::make_unique<HDF5DataSet>(file, "scalar"));
}
remove("scratch1.h5");
REQUIRE (H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
}
TEST_CASE("HDF5MasterFile", "[HDF5][Full]") {
{
RegisterHDF5Filter();
@@ -194,7 +172,7 @@ TEST_CASE("HDF5Writer", "[HDF5][Full]") {
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
std::vector<SpotToSave> spots;
x.FilePrefix("test02_1p10").ImagesPerTrigger(5).DataFileCount(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
x.FilePrefix("test02_1p10").ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
StartMessage start_message;
x.FillMessage(start_message);
@@ -230,7 +208,7 @@ TEST_CASE("HDF5Writer_Spots", "[HDF5][Full]") {
spots.push_back({20,50,12});
spots.push_back({1000,500,3});
x.FilePrefix("test02_1p10_spots").ImagesPerTrigger(5).DataFileCount(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
x.FilePrefix("test02_1p10_spots").ImagesPerTrigger(5).ImagesPerFile(3).Compression(CompressionAlgorithm::NO_COMPRESSION);
StartMessage start_message;
x.FillMessage(start_message);
@@ -269,7 +247,7 @@ TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
std::vector<float> rad_int_profile(mapping.GetBinNumber(), 4.0);
std::vector<float> rad_int_avg(mapping.GetBinNumber(), 0.33);
x.FilePrefix("test02_1p10_rad_int").ImagesPerTrigger(5).DataFileCount(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
x.FilePrefix("test02_1p10_rad_int").ImagesPerTrigger(5).ImagesPerFile(3).Compression(CompressionAlgorithm::NO_COMPRESSION);
StartMessage start_message;
x.FillMessage(start_message);
start_message.az_int_bin_to_q = mapping.GetBinToQ();
@@ -299,7 +277,7 @@ TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
DiffractionExperiment x(DetectorGeometry(1));
x.ImagesPerTrigger(5).DataFileCount(5).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds");
x.ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds");
{
RegisterHDF5Filter();
@@ -333,7 +311,7 @@ TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}
{
HDF5File file("vds_master.h5", false, false);
HDF5ReadOnlyFile file("vds_master.h5");
std::unique_ptr<HDF5DataSet> dataset;
REQUIRE_NOTHROW(dataset = std::make_unique<HDF5DataSet>(file,"/entry/data/data"));
HDF5DataSpace file_space(*dataset);
@@ -358,7 +336,7 @@ TEST_CASE("HDF5Writer_VDS", "[HDF5][Full]") {
TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
DiffractionExperiment x(DetectorGeometry(1));
x.ImagesPerTrigger(5).DataFileCount(5).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds_missing");
x.ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds_missing");
{
RegisterHDF5Filter();
@@ -394,7 +372,7 @@ TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
REQUIRE_NOTHROW(HDF5Metadata::NXmx(start_message, end_message));
}
{
HDF5File file("vds_missing_master.h5", false, false);
HDF5ReadOnlyFile file("vds_missing_master.h5");
std::unique_ptr<HDF5DataSet> dataset;
REQUIRE_NOTHROW(dataset = std::make_unique<HDF5DataSet>(file,"/entry/data/data"));
HDF5DataSpace file_space(*dataset);
@@ -419,7 +397,7 @@ TEST_CASE("HDF5Writer_VDS_missing", "[HDF5][Full]") {
TEST_CASE("HDF5Writer_VDS_zero_images", "[HDF5][Full]") {
DiffractionExperiment x(DetectorGeometry(1));
x.ImagesPerTrigger(5).DataFileCount(5).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds_zero");
x.ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION).FilePrefix("vds_zero");
{
RegisterHDF5Filter();