bugfix gap pixels eiger assembler

This commit is contained in:
lhdamiani
2021-07-23 14:01:43 +02:00
parent 72bf793cfc
commit 06c230c048
14 changed files with 106 additions and 3594 deletions
+4 -2
View File
@@ -12,14 +12,16 @@ const std::string DETECTOR_TYPE = "eiger";
#define BYTES_PER_PACKET 4144
#define DATA_BYTES_PER_PACKET 4096
#define MODULE_X_SIZE 256
#define MODULE_Y_SIZE 512
#define MODULE_X_SIZE 512
#define MODULE_Y_SIZE 256
#define MODULE_N_PIXELS 131072
#define PIXEL_N_BYTES 2
#define GAP_X_MODULE_PIXELS 2
#define GAP_Y_MODULE_PIXELS 2
#define GAP_X_EIGERMOD_PIXELS 8
#define GAP_Y_EIGERMOD_PIXELS 36
#define EXTEND_X_PIXELS 3
#define EXTEND_Y_PIXELS 1
// #define N_BYTES_PER_IMAGE_LINE(bit_depth, n_submodules) ((n_submodules / 2 * MODULE_X_SIZE * bit_depth) / 8)
+1 -1
View File
@@ -1,4 +1,4 @@
detsize 1024 512
detsize 512 1024
hostname beb031+beb032
udp_dstmac 9c:dc:71:4d:2a:b5
+1 -1
View File
@@ -2,6 +2,6 @@
"detector_name": "cSAXS.EG01V01",
"detector_type": "eiger",
"n_modules": 4,
"image_n_pixels": 527364,
"image_n_pixels": 529420,
"start_udp_port": 50200
}
@@ -0,0 +1,22 @@
detsize 1024 512
hostname beb031+beb032
udp_dstmac 9c:dc:71:4d:2a:b5
udp_dstip 10.30.20.6
#top
0:udp_dstport 50200
0:udp_dstport2 50201
0:udp_srcip 10.30.20.201
0:rx_tcpport 1960
#bottom
1:udp_dstport 50202
1:udp_dstport2 50203
1:udp_srcip 10.30.20.201
1:rx_tcpport 1961
rx_hostname sf-daq-4
tengiga 1
+15 -15
View File
@@ -128,19 +128,19 @@ else
fi
# Start the eiger writer
# echo "Starting the ${STD_DET_WRITER}..."
# export PATH="/usr/lib64/mpich/bin:${PATH}";
# export LD_LIBRARY_PATH="/usr/lib64/mpich/lib:${LD_LIBRARY_PATH}";
echo "Starting the ${STD_DET_WRITER}..."
export PATH="/usr/lib64/mpich-3.2/bin:${PATH}";
export LD_LIBRARY_PATH="/usr/lib64/mpich-3.2/lib:${LD_LIBRARY_PATH}";
# if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then
# if [ -f "${CONFIG_FILE}" ]; then
# mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} &
# sleep 0.5
# else
# echo "Something went wrong while starting the ${STD_DET_WRITER}..."
# exit
# fi
# else
# echo "Error: ${STD_DET_WRITER} wasn't found..."
# exit
# fi
if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then
if [ -f "${CONFIG_FILE}" ]; then
mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} &
sleep 0.5
else
echo "Something went wrong while starting the ${STD_DET_WRITER}..."
exit
fi
else
echo "Error: ${STD_DET_WRITER} wasn't found..."
exit
fi
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1 +0,0 @@
IP:Port: 10.30.20.6 50200
Binary file not shown.
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
import glob
import os
import h5py
import numpy as np
from PIL import Image
import cv2
list_of_files = glob.glob('/home/hax_l/tests/*.h5')
latest_file = max(list_of_files, key=os.path.getctime)
print("FILE: ", latest_file)
hdf = h5py.File(latest_file,'r')
array = hdf["cSAXS.EG01V01/data"]
img = array[0,:,:].astype('uint16')
img = Image.fromarray(img).convert('RGB')
img.save("export_image.jpg", "JPEG")
img.show()
-29
View File
@@ -1,29 +0,0 @@
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
# These are more or less standard dacs, if you see strange effects
# you might need to tune them
dacs = np.array([ 0, 2480, 2900, 1400, 4000, 2556, 898, 848, 0, 855, 1100,
1100, 982, 895, 2000, 1550, 570, 0], dtype=np.int32)
tb = np.zeros((256,1024), dtype = np.int32)
# Create the desired pattern
for row in range(0,256,64):
for col in range(0,1024,64):
print(f'{row}, {col}')
tb[row:row+32, col:col+32] = 63
fig, ax = plt.subplots()
im = ax.imshow(tb)
fig.savefig('trim.png')
with open('trimbits.sn001', 'wb') as f:
dacs.tofile(f)
tb.tofile(f)
Binary file not shown.
+41 -39
View File
@@ -14,6 +14,7 @@ using namespace buffer_config;
EigerAssembler::EigerAssembler(const int n_modules, const int bit_depth):
n_modules_(n_modules),
n_rows_(n_modules/2),
n_eiger_modules_(n_modules/4),
bit_depth_(bit_depth),
n_bytes_per_frame_(MODULE_N_PIXELS * bit_depth / 8),
@@ -23,9 +24,9 @@ EigerAssembler::EigerAssembler(const int n_modules, const int bit_depth):
n_bytes_per_y_gap_(GAP_Y_MODULE_PIXELS * bit_depth / 8),
n_bytes_per_eiger_x_gap_(GAP_X_EIGERMOD_PIXELS * bit_depth / 8),
n_bytes_per_eiger_y_gap_(GAP_Y_EIGERMOD_PIXELS * bit_depth / 8),
n_bytes_per_image_line_(n_bytes_per_frame_line_ * 2 + n_bytes_per_x_gap_),
n_lines_per_frame_(DATA_BYTES_PER_PACKET / n_bytes_per_frame_line_ * n_packets_per_frame_),
image_bytes_((n_modules_ * n_bytes_per_frame_) + (2 * (MODULE_Y_SIZE * 2) * bit_depth_ / 8) + ((n_eiger_modules_) * (2 * n_bytes_per_image_line_)))
n_bytes_per_image_line_((n_bytes_per_frame_line_ + EXTEND_X_PIXELS * bit_depth / 8) * n_rows_),
n_lines_per_frame_(DATA_BYTES_PER_PACKET / n_bytes_per_frame_line_ * n_packets_per_frame_ + EXTEND_Y_PIXELS),
image_bytes_(n_bytes_per_image_line_ * n_lines_per_frame_ * n_rows_)
{
}
@@ -63,8 +64,8 @@ void EigerAssembler::assemble_image(const char* src_meta,
// init good image status = 0
image_meta->status = 0;
image_meta->id = frame_meta->id;
image_meta->height = n_modules_ / 2 * MODULE_Y_SIZE + GAP_Y_MODULE_PIXELS;
image_meta->width = n_modules_ / 2 * MODULE_X_SIZE + GAP_X_MODULE_PIXELS;
image_meta->height = n_rows_ * (MODULE_Y_SIZE + EXTEND_Y_PIXELS);
image_meta->width = n_rows_ * (MODULE_X_SIZE + EXTEND_X_PIXELS);
image_meta->dtype = (bit_depth_ <= 8) ? 1 : bit_depth_ / 8;
image_meta->encoding = 0;
image_meta->source_id = 0;
@@ -103,7 +104,7 @@ void EigerAssembler::assemble_image(const char* src_meta,
line_number = MODULE_Y_SIZE + GAP_Y_MODULE_PIXELS;
reverse_factor = MODULE_Y_SIZE - 1;
dest_offset += n_bytes_per_image_line_ *
(MODULE_Y_SIZE + GAP_Y_MODULE_PIXELS);
(MODULE_X_SIZE+EXTEND_X_PIXELS);
source_offset = (MODULE_Y_SIZE-1) * n_bytes_per_frame_line_;
}
@@ -114,41 +115,9 @@ void EigerAssembler::assemble_image(const char* src_meta,
uint32_t dest_module_line = line_number;
if (i_module_column == 1) {
dest_offset += n_bytes_per_frame_line_ + n_bytes_per_x_gap_;
dest_offset += n_bytes_per_frame_line_ + EXTEND_X_PIXELS * bit_depth_ / 8 ;
}
int counter = 0;
for (uint32_t frame_line = 0;
frame_line < n_lines_per_frame_; frame_line++) {
// void * destination, const void * source, size_t num
memcpy (
(char*)(dst_data + dest_offset),
(char*)(src_data + source_offset),
n_bytes_per_frame_line_
);
#ifdef DEBUG_OUTPUT
using namespace date;
// verifies the addresses for
// beginning and end of each frame
if (counter < 5 || counter > 508){
cout << " [" << std::chrono::system_clock::now();
cout << "] [MODULE " << i_module;
cout << "] (row " << i_module_row;
cout << ",column " << i_module_column;
cout << ") source_offset" << source_offset;
cout << " || dest_offset " << dest_offset;
cout << " || frame_line " << frame_line;
cout << " || COUNTER " << counter;
cout << endl;
}
#endif
counter += 1;
source_offset += reverse * n_bytes_per_frame_line_;
dest_offset += reverse * n_bytes_per_image_line_;
}
line_number += n_lines_per_frame_;
dest_module_line = line_number + n_lines_per_frame_ - 1;
#ifdef DEBUG_OUTPUT
using namespace date;
// if (i_module == 0){
@@ -163,6 +132,39 @@ void EigerAssembler::assemble_image(const char* src_meta,
// }
#endif
int counter = 0;
for (uint32_t frame_line = 0;
frame_line < n_lines_per_frame_ - 1; frame_line++) {
// void * destination, const void * source, size_t num
memcpy (
(char*)(dst_data + dest_offset),
(char*)(src_data + source_offset),
n_bytes_per_frame_line_
);
#ifdef DEBUG_OUTPUT
using namespace date;
// verifies the addresses for
// beginning and end of each frame
if (counter < 3 || frame_line > n_lines_per_frame_ - 3){
cout << " [" << std::chrono::system_clock::now();
cout << "] [MODULE " << i_module;
cout << "] (row " << i_module_row;
cout << " , column " << i_module_column;
cout << ") source_offset" << source_offset;
cout << " || dest_offset " << dest_offset;
cout << " || frame_line " << frame_line;
cout << " || COUNTER " << counter;
cout << endl;
}
#endif
counter += 1;
source_offset += reverse * n_bytes_per_frame_line_;
dest_offset += reverse * n_bytes_per_image_line_;
}
line_number += n_lines_per_frame_;
dest_module_line = line_number + n_lines_per_frame_ - 1;
// last module sets the last_image_status_
if (i_module == n_modules_ - 1){
last_image_status_ = image_meta->status;