DiffractionExperiment: Remove 2x2 binning to simplify transformation code
This commit is contained in:
@@ -343,53 +343,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd" ,"") {
|
||||
REQUIRE(input_1[(511+512)*1024 + 800] == output[CONVERTED_MODULE_SIZE * (nmodules - 2) + 1030 + 800 + 6]);
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_bin_2x2" ,"") {
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2, 0, 0, false));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Compression(JFJochProtoBuf::BSHUF_ZSTD).Binning2x2(true);
|
||||
|
||||
FrameTransformation transformation(experiment);
|
||||
|
||||
std::mt19937 g1(1987);
|
||||
std::uniform_int_distribution<int16_t> dist;
|
||||
|
||||
std::vector<int16_t> input_0(nmodules*RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < nmodules*RAW_MODULE_SIZE; i++)
|
||||
input_0[i] = (i % 1024) + (i / 1024);
|
||||
|
||||
std::vector<int16_t> input_1(nmodules*RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < nmodules*RAW_MODULE_SIZE; i++)
|
||||
input_1[i] = 10;
|
||||
|
||||
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
|
||||
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
transformation.Pack();
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.SaveCompressedImage(output_compressed.data()));
|
||||
|
||||
REQUIRE(bshuf_read_uint64_BE(output_compressed.data()) == experiment.GetPixelsNum() * experiment.GetPixelDepth());
|
||||
REQUIRE(bshuf_read_uint32_BE(output_compressed.data()+8) == JFJochBitShuffleCompressor::DefaultBlockSize * experiment.GetPixelDepth());
|
||||
|
||||
output_compressed.resize(compressed_size);
|
||||
std::vector<int16_t> output;
|
||||
REQUIRE_NOTHROW(JFJochDecompress(output, experiment.GetCompressionAlgorithmEnum(), output_compressed,
|
||||
experiment.GetPixelsNum()));
|
||||
|
||||
REQUIRE(output[0] == 0 + 1 + 1 + 2);
|
||||
REQUIRE(output[1] == 2 + 3 + 3 + 4);
|
||||
|
||||
REQUIRE(output[(513/2)*(1030/2) * 2] == 510 + 511 + 511 + 512); // line 510 + 511
|
||||
REQUIRE(output[(514/2)*(1030/2) * 2] == 1024 + 1025 + 1025 + 1026); // line 1024 + 1025
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_rle" ,"") {
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
@@ -520,57 +473,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
|
||||
REQUIRE(4 * input_1[(511+512)*1024 + 800] == output[CONVERTED_MODULE_SIZE * (nmodules - 2) + 1030 + 800 + 6]);
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
|
||||
const uint16_t nmodules = 4;
|
||||
const uint16_t ndatastreams = 2;
|
||||
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 2, 0, 0, false));
|
||||
experiment.DataStreams(ndatastreams);
|
||||
|
||||
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD).Binning2x2(true);
|
||||
|
||||
REQUIRE(experiment.GetSummation() == 4);
|
||||
|
||||
FrameTransformation transformation(experiment);
|
||||
|
||||
std::mt19937 g1(1987);
|
||||
std::uniform_int_distribution<int16_t> dist;
|
||||
|
||||
std::vector<int16_t> input_0(nmodules*RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < nmodules*RAW_MODULE_SIZE; i++)
|
||||
input_0[i] = (i % 1024) + (i / 1024);
|
||||
|
||||
std::vector<int16_t> input_1(nmodules*RAW_MODULE_SIZE);
|
||||
for (int i = 0; i < nmodules*RAW_MODULE_SIZE; i++)
|
||||
input_1[i] = 10;
|
||||
|
||||
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
|
||||
|
||||
for (int frame = 0; frame < experiment.GetSummation(); frame++) {
|
||||
for (int i = 0; i < nmodules; i++) {
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
|
||||
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
|
||||
}
|
||||
}
|
||||
|
||||
size_t compressed_size;
|
||||
transformation.Pack();
|
||||
REQUIRE_NOTHROW(compressed_size = transformation.SaveCompressedImage(output_compressed.data()));
|
||||
|
||||
REQUIRE(bshuf_read_uint64_BE(output_compressed.data()) == experiment.GetPixelsNum() * experiment.GetPixelDepth());
|
||||
REQUIRE(bshuf_read_uint32_BE(output_compressed.data()+8) == JFJochBitShuffleCompressor::DefaultBlockSize * experiment.GetPixelDepth());
|
||||
|
||||
output_compressed.resize(compressed_size);
|
||||
std::vector<int32_t> output;
|
||||
REQUIRE_NOTHROW(JFJochDecompress(output, experiment.GetCompressionAlgorithmEnum(), output_compressed,
|
||||
experiment.GetPixelsNum()));
|
||||
|
||||
REQUIRE(output[0] == 4 * (0 + 1 + 1 + 2));
|
||||
REQUIRE(output[1] == 4 * (2 + 3 + 3 + 4));
|
||||
|
||||
REQUIRE(output[(513/2)*(1030/2) * 2] == 4 * (510 + 511 + 511 + 512)); // line 510 + 511
|
||||
REQUIRE(output[(514/2)*(1030/2) * 2] == 4 * (1024 + 1025 + 1025 + 1026)); // line 1024 + 1025
|
||||
}
|
||||
|
||||
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
|
||||
// Ensure that previous frame is properly cleaned with PackStandardOutput()
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
Reference in New Issue
Block a user