From 479ca4de85a98bf0e3f4ccc92dfde3429e8c7186 Mon Sep 17 00:00:00 2001
From: Roberto Susino <roberto.susino@inaf.it>
Date: Thu, 16 Dec 2021 10:12:04 +0100
Subject: [PATCH] Fix bug in Metis WCS keyword structure

---
 metis_wcs.pro | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/metis_wcs.pro b/metis_wcs.pro
index 74b4d42..3944d91 100644
--- a/metis_wcs.pro
+++ b/metis_wcs.pro
@@ -63,11 +63,12 @@ function metis_wcs, header, cal_pack, ref_detector = ref_detector
 
 	pc = [[cos(roll), -sin(roll)], [sin(roll), cos(roll)]]
 
+	ctype1 = 'HPLN-TAN'
+	ctype2 = 'HPLT-TAN'
+
 	; if requested, transform the wcs matrix to the detector reference frame and adjust the boresight and spacecraft pointing parameters
 
 	if keyword_set(ref_detector) then begin
-		ctype1 = 'HPLT-TAN'
-		ctype2 = 'HPLN-TAN'
 		if header.filter.contains('UV', /fold) then begin
 			borpix_prime = borpix
 			borpix[0] = detector_size - (borpix_prime[1] - 1.)
@@ -88,11 +89,8 @@ function metis_wcs, header, cal_pack, ref_detector = ref_detector
 			roll = roll + !dpi/2.
 			pc = [[cos(roll), -sin(roll)], [sin(roll), cos(roll)]]
 		endif
-	endif else begin
-		ctype1 = 'HPLN-TAN'
-		ctype2 = 'HPLT-TAN'
-	endelse
-
+	endif
+	
 	; get sun's center pixel
 
 	sunval = [0., 0.]
@@ -187,14 +185,14 @@ function metis_wcs, header, cal_pack, ref_detector = ref_detector
 		name: 'IO_YCEN', $
 		value: borpix[1], $
 		comment: '[pixel] Metis IO center location along axis 2'}
-	; wcs.add, { $
-	; 	name: 'FS_XCEN', $
-	; 	value: crpix[0], $
-	; 	comment: '[pixel] Metis field-stop center location along axis 1'}
-	; wcs.add, { $
-	; 	name: 'FS_YCEN', $
-	; 	value: crpix[1], $
-	; 	comment: '[pixel] Metis field-stop center location along axis 2'}
+	wcs.add, { $
+		name: 'FS_XCEN', $
+		value: crpix[0], $
+		comment: '[pixel] Metis field-stop center location along axis 1'}
+	wcs.add, { $
+		name: 'FS_YCEN', $
+		value: crpix[1], $
+		comment: '[pixel] Metis field-stop center location along axis 2'}
 	wcs.add, { $
 		name: 'SC_XCEN', $
 		value: pntpix[0], $
-- 
GitLab