From 5c0777a98ab307c35d4186e49b00a6d9c04c3369 Mon Sep 17 00:00:00 2001
From: Roberto Susino <roberto.susino@inaf.it>
Date: Thu, 9 Jun 2022 08:31:01 +0200
Subject: [PATCH] Optimize radiometric calibration procedure

---
 metis_rad_cal.pro | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/metis_rad_cal.pro b/metis_rad_cal.pro
index e8d0f15..b0bd58d 100644
--- a/metis_rad_cal.pro
+++ b/metis_rad_cal.pro
@@ -12,7 +12,7 @@ function metis_rad_cal, data, header, cal_pack, polarimetric = polarimetric, nor
 		if keyword_set(polarimetric) then pmp_factor = 2. else pmp_factor = 1.
 
 		ndit = header.ndit
-	end
+	endif
 
 	if header.filter.contains('UV', /fold) then begin
 		channel = cal_pack.uv_channel
@@ -82,12 +82,17 @@ function metis_rad_cal, data, header, cal_pack, polarimetric = polarimetric, nor
 		
 		cal_factor = cal_factor/rad_factor
 		
-		cal_error = sqrt((radiometry.rad_response.error/radiometry.rad_response.value)^2 + (cal_pack.instrument.pupil_area.error/cal_pack.instrument.pupil_area.value)^2 + (channel.angular_pixel.error/channel.angular_pixel.value)^2 + (unit_error/unit_factor)^2)
+		cal_error = sqrt((radiometry.rad_response.error/radiometry.rad_response.value)^2 $
+			+ (cal_pack.instrument.pupil_area.error/cal_pack.instrument.pupil_area.value)^2 $
+			+ (channel.angular_pixel.error/channel.angular_pixel.value)^2 $
+			+ (unit_error/unit_factor)^2)
 		
-		history = [history, '  cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN']
+		if header.filter.contains('VL', /fold) then begin
+			history = [history, '  cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN']
 
-		journal, '  total cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN'
-		journal, '  cal. factor error = ' + string(cal_error, format = '(E8.2)') + ' ' + units + '/DN'
+			journal, '  total cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN'
+			journal, '  cal. factor error = ' + string(cal_error, format = '(E8.2)') + ' ' + units + '/DN'
+		endif
 	endelse
 		
 	; radiometric calibration
-- 
GitLab