Skip to content
Snippets Groups Projects
Commit 89c1ee03 authored by David Hammer's avatar David Hammer
Browse files

LPD: check gain values, mask extreme / nan values

parent 0e210d4b
No related branches found
No related tags found
1 merge request!12Snapshot: field test deployed version as of end of run 202201
...@@ -31,8 +31,8 @@ extern "C" { ...@@ -31,8 +31,8 @@ extern "C" {
const size_t data_stride_cell = Y * data_stride_y; const size_t data_stride_cell = Y * data_stride_y;
const size_t data_index = memory_cell * data_stride_cell + y * data_stride_y + x * data_stride_x; const size_t data_index = memory_cell * data_stride_cell + y * data_stride_y + x * data_stride_x;
const unsigned short raw_data_value = data[data_index]; const unsigned short raw_data_value = data[data_index];
const unsigned char gain = raw_data_value >> 12; const unsigned char gain = (raw_data_value >> 12) & 0x0003;
float corrected = (float)(raw_data_value & 0xfff); float corrected = (float)(raw_data_value & 0x0fff);
const size_t gm_map_stride_gain = 1; const size_t gm_map_stride_gain = 1;
const size_t gm_map_stride_x = 3 * gm_map_stride_gain; const size_t gm_map_stride_x = 3 * gm_map_stride_gain;
...@@ -46,7 +46,8 @@ extern "C" { ...@@ -46,7 +46,8 @@ extern "C" {
y * gm_map_stride_y + y * gm_map_stride_y +
x * gm_map_stride_x; x * gm_map_stride_x;
if ((corr_flags & BPMASK) && bad_pixel_map[gm_map_index]) { if (gain > 2 || ((corr_flags & BPMASK) && bad_pixel_map[gm_map_index])) {
// now also checking for illegal gain value
corrected = bad_pixel_mask_value; corrected = bad_pixel_mask_value;
} else { } else {
// TODO: save GPU memory by combining maps // TODO: save GPU memory by combining maps
...@@ -62,6 +63,9 @@ extern "C" { ...@@ -62,6 +63,9 @@ extern "C" {
if (corr_flags & FF_CORR) { if (corr_flags & FF_CORR) {
corrected *= flatfield_map[gm_map_index]; corrected *= flatfield_map[gm_map_index];
} }
if (corrected < -1e7 || corrected > 1e7 || isnan(corrected)) {
corrected = bad_pixel_mask_value;
}
} }
} }
{% if output_data_dtype == "half" %} {% if output_data_dtype == "half" %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment