Skip to content
Snippets Groups Projects
Commit 77bf37fa authored by Roberto Susino's avatar Roberto Susino
Browse files

Add management of errors in UV pipeline

parent a33897b7
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,10 @@ pro metis_l2_prep_uv
journal, ' sess_num = ' + header.sess_num
journal, ' nbin = ' + string(sqrt(header.nbin), format = '(I0)')
; error is the quadratic relative error
error = 0.
; calibration block
case header.datatype of
......@@ -63,7 +67,7 @@ pro metis_l2_prep_uv
; header.nsumexp = header.ndit1 * header.ndit2
; ====================================
data = metis_dark_uvda(data, header, cal_pack, history = history)
data = metis_dark_uvda(data, header, cal_pack, error = error, quality_matrix = quality_matrix, history = history)
; ====================================
; for data already subtracted of dark
......@@ -74,15 +78,13 @@ pro metis_l2_prep_uv
; history = ['Dark correction: ', ' ' + file]
; ====================================
data = metis_flat_field(data, header, cal_pack, history = history)
data = metis_vignetting(data, header, cal_pack, history = history)
data = metis_rad_cal(data, header, cal_pack, history = history)
data = metis_flat_field(data, header, cal_pack, error = error, quality_matrix = quality_matrix, history = history)
data = metis_vignetting(data, header, cal_pack, error = error, quality_matrix = quality_matrix, history = history)
data = metis_rad_cal(data, header, cal_pack, error = error, quality_matrix = quality_matrix, history = history)
; ====================================
; for simple radiometric calibration
; data = data/header.xposure
; cal_pack.uv_channel.cal_units = 'DN/s'
; history = [history, 'Radiometric calibration: ', ' exposure normalisation only']
; ====================================
; ====================================
......@@ -135,7 +137,7 @@ pro metis_l2_prep_uv
fxaddpar, primary_header, 'FILENAME', file_name
fxaddpar, primary_header, 'PARENT', file_basename(input.file_name)
fxaddpar, primary_header, 'LEVEL', 'L2-draft'
fxaddpar, primary_header, 'LEVEL', 'L2'
fxaddpar, primary_header, 'ORIGIN', ''
fxaddpar, primary_header, 'CREATOR', 'metis_l2_prep_uv.pro'
fxaddpar, primary_header, 'VERS_SW', input.sw_version
......@@ -148,6 +150,8 @@ pro metis_l2_prep_uv
fxaddpar, primary_header, 'XPOSURE', header.xposure
fxaddpar, primary_header, 'NSUMEXP', header.nsumexp
sxdelpar, primary_header, 'BLANK'
; append wcs keywords
wcs = metis_wcs(header, cal_pack, ref_detector = ref_detector)
......@@ -160,10 +164,6 @@ pro metis_l2_prep_uv
history = [history, 'Update WCS and solar ephemeris:', ' SKD version = ' + kernel_version]
; delete useless keywords
sxdelpar, primary_header, 'BLANK'
; add the history keyword
for k = 0, n_elements(history) - 1 do $
......@@ -201,7 +201,7 @@ pro metis_l2_prep_uv
fxaddpar, extension_header, 'PCOUNT', 0, 'Parameter count'
fxaddpar, extension_header, 'GCOUNT', 1, 'Group count'
fxaddpar, extension_header, 'EXTNAME', 'Error matrix', 'Extension name'
error_matrix = intarr(header.naxis1, header.naxis2)
error_matrix = data * sqrt(error)
if not ref_detector then error_matrix = metis_rectify(error_matrix, 'UV')
fits_add_checksum, extension_header, error_matrix
mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment