From 750fe3b20f7435f5a6108aa67f7666e4067641b2 Mon Sep 17 00:00:00 2001
From: Roberto Susino <roberto.susino@inaf.it>
Date: Tue, 26 Oct 2021 08:51:02 +0200
Subject: [PATCH] Manage new bad-pixel maps including ref. rows

---
 metis_l1_prep.pro | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/metis_l1_prep.pro b/metis_l1_prep.pro
index 6e14929..85a7191 100755
--- a/metis_l1_prep.pro
+++ b/metis_l1_prep.pro
@@ -205,6 +205,13 @@ pro metis_l1_prep
 
 		bad_pixel_map = readfits(cal_pack.path + channel.bad_pixel_map[0].file_name, /silent)
 
+		; adjust the map based on the presence of the reference rows
+		
+		map_size = size(bad_pixel_map)
+		ref_rows = fxpar(primary_header, 'REF_ROWS', missing = -1)
+		if ref_rows ge 0 then first_row = ref_rows ? 2 : 0 else first_row = 0
+		bad_pixel_map = bad_pixel_map[*, first_row : first_row + map_size[1] - 1]
+
 		; rebin the bad-pixel map to the size of the image to be corrected
 
 		bad_pixel_map = rebin(bad_pixel_map, naxis1, naxis2) * bin_fact^2
-- 
GitLab