diff --git a/metis_dark_uvda.pro b/metis_dark_uvda.pro index fd88c411940197025ede857652203b4904d5572f..b62e7490ab1e14a8ff934bae7eb7b58d234242bc 100644 --- a/metis_dark_uvda.pro +++ b/metis_dark_uvda.pro @@ -45,9 +45,9 @@ function metis_dark_uvda, data, header, cal_pack, history = history endfor if not isa(obt_available) then begin - dark_file = 'applicable file not found - correction not applied' - - goto, jump + journal, 'Error 12: UV applicable dark file not found.' + journal + exit, status = 12 endif delta_obt = min(abs(obt_beg - obt_available), j) @@ -78,7 +78,15 @@ function metis_dark_uvda, data, header, cal_pack, history = history jump: if ~ isa(history) then history = !null - history = [history, 'Dark correction: ', ' ' + dark_file] + history = [history, 'Dark-current correction: ', ' ' + dark_file] + + journal, 'Dark-current correction:' + journal, ' dit = ' + string(dit, format = '(F0)') + ' s' + journal, ' ndit1 = ' + string(ndit1, format = '(I0)') + journal, ' ndit2 = ' + string(ndit2, format = '(I0)') + journal, ' obj_cnt = ' + string(obj_cnt, format = '(I0)') + journal, ' tsensor = ' + string(tsensor, format = '(F0)') + ' degC' + journal, ' dark file = ' + dark_file return, data end diff --git a/metis_dark_vlda.pro b/metis_dark_vlda.pro index 61e6593ebc493666fe44e0d28e2b36d936c87590..0a89a2866af7a1c1c0733c10151c5e1a5045a436 100644 --- a/metis_dark_vlda.pro +++ b/metis_dark_vlda.pro @@ -6,6 +6,7 @@ function metis_dark_vlda, data, header, cal_pack, history = history dit = header.dit/1000.D0 ndit = header.ndit + xposure = dit * ndit nbin = sqrt(header.nbin) tsensor = header.tsensor obt_beg = header.obt_beg/1000.D0 ; check why obt_beg must be divided by 1000. @@ -38,8 +39,9 @@ function metis_dark_vlda, data, header, cal_pack, history = history bias_image = float(readfits(cal_pack.path + bias[i].file_name, /silent)) dark_file = bias[i].file_name endif else begin - bias_image = fltarr(header.naxis1, header.naxis2) - dark_file = 'applicable bias file not found - correction not applied' + journal, 'Error 02: VL applicable bias file not found.' + journal + exit, status = 2 endelse dark_obt_available = !null @@ -53,15 +55,16 @@ function metis_dark_vlda, data, header, cal_pack, history = history dark_image = float(readfits(cal_pack.path + dark[i].file_name, /silent)) dark_file = [dark_file, dark[i].file_name] endif else begin - dark_image = fltarr(header.naxis1, header.naxis2) - dark_file = [dark_file, 'applicable dark file not found - correction not applied'] + journal, 'Error 03: VL applicable dark file not found.' + journal + exit, status = 3 endelse bias_image = rebin(bias_image, header.naxis1, header.naxis2) * nbin^2 dark_image = rebin(dark_image, header.naxis1, header.naxis2) * nbin^2 mask = where(data eq 0.) - data = data - (bias_image * ndit + header.xposure * dark_image) + data = data - (bias_image * ndit + dark_image * xposure) data[mask] = 0. jump: @@ -69,5 +72,11 @@ function metis_dark_vlda, data, header, cal_pack, history = history if ~ isa(history) then history = !null history = [history, 'Bias and dark-current corrections: ', ' ' + dark_file] + journal, 'Bias and dark-current correction:' + journal, ' dit = ' + string(dit, format = '(F0)') + ' s' + journal, ' ndit = ' + string(ndit, format = '(I0)') + journal, ' xposure = ' + string(xposure, format = '(F0)') + ' s' + journal, ' tsensor = ' + string(tsensor, format = '(F0)') + ' degC' + journal, ' bias/dark file = ' + dark_file return, data end diff --git a/metis_flat_field.pro b/metis_flat_field.pro index 91aaf11df6c078b11188da22b71c28a354a175c9..e3a039cd54528752c540175365041b8214a25069 100644 --- a/metis_flat_field.pro +++ b/metis_flat_field.pro @@ -1,5 +1,7 @@ function metis_flat_field, data, header, cal_pack, history = history + journal, 'Flat-field correction:' + if header.filter.contains('VL', /fold) then begin ff_info = cal_pack.vl_channel.flat_field @@ -9,6 +11,8 @@ function metis_flat_field, data, header, cal_pack, history = history first_row = header.ref_rows eq 'Included' ? 2 : 0 detector_size = cal_pack.vl_channel.detector_size.value ff_image = ff_image[*, first_row : first_row + detector_size - 1] + + journal, ' VL ref. rows = ' + header.ref_rows.tolower() endif if header.filter.contains('UV', /fold) then begin @@ -30,5 +34,7 @@ function metis_flat_field, data, header, cal_pack, history = history if ~ isa(history) then history = !null history = [history, 'Flat-field correction: ', ' ' + ff_file] + journal, ' flat-field file = ' + ff_file + return, data end diff --git a/metis_l2_prep_uv.pro b/metis_l2_prep_uv.pro index debdbb6ee5d03d6266c647d0f38d4aef6e14f819..de9a0d4f33461df1d63b0f17d2405eb74b6a01a9 100644 --- a/metis_l2_prep_uv.pro +++ b/metis_l2_prep_uv.pro @@ -12,10 +12,15 @@ pro metis_l2_prep_uv input = json_parse('input/contents.json', /toarray, /tostruct) + journal, 'File ' + file_basename(input.file_name) + ; load the spice kernels load_spice_kernels, input.spice_kernels, kernel_list = kernel_list, kernel_version = kernel_version + journal, 'SPICE kernel files correctly loaded:' + journal, ' SDK version= ' + kernel_version + ; read the calibration package index cal_pack = json_parse(input.cal_pack_path + '/index.json', /toarray, /tostruct) @@ -24,6 +29,10 @@ pro metis_l2_prep_uv cal_pack = create_struct('path', input.cal_pack_path + path_sep(), cal_pack) + journal, 'Calibration package correctly imported:' + journal, ' version = ' + cal_pack.version + journal, ' validity range = ' + string(cal_pack.validity_range.start, cal_pack.validity_range._end, format = '(A, "-", A)') + ; read the primary hdu data = mrdfits(input.file_name, 0, primary_header, /silent) @@ -36,13 +45,15 @@ pro metis_l2_prep_uv header = fits_hdr2struct(primary_header) - ; read the house-keeping extension - - hk_table = mrdfits(input.file_name, 'house-keeping', hk_extension_header, /silent) + journal, 'L1 FITS file correctly read:' + journal, ' datatype = ' + string(header.datatype, format = '(I0)') + journal, ' sess_num = ' + header.sess_num + journal, ' nbin = ' + string(sqrt(header.nbin), format = '(I0)') ; calibration block - if header.datatype eq 1 then begin + case header.datatype of + 1 : begin data = double(data) ; ==================================== @@ -82,21 +93,28 @@ pro metis_l2_prep_uv btype = 'UV Lyman-alpha intensity' bunit = cal_pack.uv_channel.cal_units - endif + end - if header.datatype eq 4 then begin + 4 : begin ; calibration of temporal noise images btype = 'UV temporal standard deviation' bunit = 'DN' history = !null - endif + end - if header.datatype eq 6 then begin + 6 : begin ; calibration of cr/sep log matrices btype = 'UV cosmic-ray matrix' bunit = 'DN' history = !null - endif + end + + else : begin + journal, 'Error 11: wrong input data product (expected data types 1, 4, or 6).' + journal + exit, status = 11 + end + endcase ; definitions for the primary header ; version of the fits file @@ -162,6 +180,9 @@ pro metis_l2_prep_uv fits_add_checksum, primary_header, data mwrfits, data, out_file_name, primary_header, /no_comment, /create, /silent + journal, 'Fits file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the quality matrix extension_header = !null @@ -172,6 +193,8 @@ pro metis_l2_prep_uv fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -183,6 +206,8 @@ pro metis_l2_prep_uv fits_add_checksum, extension_header, error_matrix mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; write the auxiliary information file output = { $ @@ -197,13 +222,12 @@ pro metis_l2_prep_uv load_spice_kernels, kernel_list = kernel_list, /unload + journal, 'SPICE kernel files unloaded.' + ; close the log + journal, 'Exiting without errors.' journal + exit, status = 0 - - error_handling: - journal, 'Errors occurred while processing.' - journal - exit, status = 1 end diff --git a/metis_l2_prep_vl_generic.pro b/metis_l2_prep_vl_generic.pro index 9ed677ef0e8974274da6fc2c7ea2b6075c64b5c0..8bd4cc7d65d2592254142a4f1edef3993c6688ed 100644 --- a/metis_l2_prep_vl_generic.pro +++ b/metis_l2_prep_vl_generic.pro @@ -16,6 +16,9 @@ pro metis_l2_prep_vl_generic load_spice_kernels, input.spice_kernels, kernel_list = kernel_list, kernel_version = kernel_version + journal, 'SPICE kernel files correctly loaded:' + journal, ' SDK version= ' + kernel_version + ; read the calibration package cal_pack = json_parse(input.cal_pack_path + '/index.json', /toarray, /tostruct) @@ -24,6 +27,10 @@ pro metis_l2_prep_vl_generic cal_pack = create_struct('path', input.cal_pack_path + path_sep(), cal_pack) + journal, 'Calibration package correctly imported:' + journal, ' version = ' + cal_pack.version + journal, ' validity range = ' + string(cal_pack.validity_range.start, cal_pack.validity_range._end, format = '(A, "-", A)') + ; read the primary hdu data = mrdfits(input.file_name, 0, primary_header, /silent) @@ -36,13 +43,18 @@ pro metis_l2_prep_vl_generic header = fits_hdr2struct(primary_header) - ; read the house-keeping extension - - hk_table = mrdfits(input.file_name, 'house-keeping', hk_extension_header, /silent) + journal, 'L1 FITS file correctly read:' + journal, ' filename = ' + file_basename(input.file_name) + journal, ' datatype = ' + string(header.datatype, format = '(I0)') + journal, ' sess_num = ' + header.sess_num + journal, ' seq_num = ' + string(header.seq_num, format = '(I0)') + journal, ' pol_id = ' + string(header.pol_id, format = '(I0)') + journal, ' nbin = ' + string(sqrt(header.nbin), format = '(I0)') ; calibration block - if header.datatype eq 0 then begin + case header.datatype of + 0 : begin data = double(data) ; ==================================== @@ -76,21 +88,28 @@ pro metis_l2_prep_vl_generic endelse bunit = cal_pack.vl_channel.cal_units - endif + end - if header.datatype eq 3 then begin + 3 : begin ; calibration of temporal noise images btype = 'VL temporal standard deviation' bunit = 'DN' history = !null - endif + end - if header.datatype eq 5 then begin + 5 : begin ; calibration of cr/sep log matrices btype = 'VL cosmic-ray matrix' bunit = 'DN' history = !null - endif + end + + else : begin + journal, 'Error 01: wrong input data product (expected data types 0, 3, or 5).' + journal + exit, status = 1 + end + endcase ; definitions for the primary header ; version of the fits file @@ -152,6 +171,9 @@ pro metis_l2_prep_vl_generic fits_add_checksum, primary_header, data mwrfits, data, out_file_name, primary_header, /no_comment, /create, /silent + journal, 'Fits file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the quality matrix extension_header = !null @@ -162,6 +184,8 @@ pro metis_l2_prep_vl_generic fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -173,6 +197,8 @@ pro metis_l2_prep_vl_generic fits_add_checksum, extension_header, intarr(header.naxis1, header.naxis2) mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; write the auxiliary information file output = { $ @@ -187,13 +213,12 @@ pro metis_l2_prep_vl_generic load_spice_kernels, kernel_list = kernel_list, /unload + journal, 'SPICE kernel files unloaded.' + ; close the log + journal, 'Exiting without errors.' journal + exit, status = 0 - - error_handling: - journal, 'Errors occurred while processing.', /continue - journal - exit, status = 1 -end +end \ No newline at end of file diff --git a/metis_l2_prep_vl_polariz.pro b/metis_l2_prep_vl_polariz.pro old mode 100644 new mode 100755 index 5c25a327f63c1ad52f078d96408e6f2c66c65fb2..5094519ca476d7a43e2a6d24500f6b49c07ca8f8 --- a/metis_l2_prep_vl_polariz.pro +++ b/metis_l2_prep_vl_polariz.pro @@ -16,6 +16,9 @@ pro metis_l2_prep_vl_polariz load_spice_kernels, input.spice_kernels, kernel_list = kernel_list, kernel_version = kernel_version + journal, 'SPICE kernel files correctly loaded:' + journal, ' SDK version= ' + kernel_version + ; read the calibration package cal_pack = json_parse(input.cal_pack_path + '/index.json', /toarray, /tostruct) @@ -24,13 +27,18 @@ pro metis_l2_prep_vl_polariz cal_pack = create_struct('path', input.cal_pack_path + path_sep(), cal_pack) + journal, 'Calibration package correctly imported:' + journal, ' version = ' + cal_pack.version + journal, ' validity range = ' + string(cal_pack.validity_range.start, cal_pack.validity_range._end, format = '(A, "-", A)') + n = n_elements(input.file_name) ; check on the number of input images (= npol = 4) if n ne 4 then begin - error_message = 'number of input images is not equal to 4' - goto, error_handling + journal, 'Error 07: wrong number of input images (expected 4).' + journal + exit, status = 7 endif ; calibration block @@ -56,12 +64,20 @@ pro metis_l2_prep_vl_polariz ; header.nsumexp = header.ndit ; ==================================== + ; check data type + + if header.datatype ne 0 then begin + journal, 'Error 01: wrong input data product (expected data type 0).' + journal + exit, status = 1 + endif + ; check consistency of polarization state if header.pol_id lt 1 or header.pol_id gt 4 then begin - error_message = 'image no. ' + string(k, format = '(I0)') + $ - ' has inconsistent polarization state' - goto, error_handling + journal, 'Error 04: image has inconsistent polarization state.' + journal + exit, status = 4 endif ; check consistency of pmp raw voltages (dacpol) @@ -71,10 +87,18 @@ pro metis_l2_prep_vl_polariz header.dac1pol2 ne header.dac2pol2 or $ header.dac1pol3 ne header.dac2pol3 or $ header.dac1pol4 ne header.dac2pol4 then begin - error_message = 'image no. ' + string(k, format = '(I0)') + ' has inconsistent PMP voltages' - goto, error_handling + journal, 'Error 05: image has inconsistent PMP voltages.' + journal + exit, status = 5 endif + journal, 'Reading L1 FITS file: ' + file_basename(input.file_name[k]) + ' ...' + journal, ' datatype = ' + string(header.datatype, format = '(I0)') + journal, ' sess_num = ' + header.sess_num + journal, ' seq_num = ' + string(header.seq_num, format = '(I0)') + journal, ' pol_id = ' + string(header.pol_id, format = '(I0)') + journal, ' nbin = ' + string(sqrt(header.nbin), format = '(I0)') + ; pile up images and headers data = [[[data]], [[image]]] @@ -82,17 +106,18 @@ pro metis_l2_prep_vl_polariz ; read and update the quality matrix - quality_matrix = quality_matrix * mrdfits(input.file_name[k], 'quality matrix', /silent) + quality_matrix *= mrdfits(input.file_name[k], 'quality matrix', /silent) ; apply dark correction to compute stokes i and total brightness tb_history = !null + image_subdark = metis_dark_vlda(image, header, cal_pack, history = tb_history) ; ==================================== ; for data already subtracted of dark ; file = file_basename(header.parent, '.fits') + '_subdark.fits' - ; image_subdark = mrdfits('VL subdark/' + file, 0, /silent) + ; image_subdark = mrdfits('input/VL_subdark/' + file, 0, /silent) ; image_subdark = rebin(image_subdark, header.naxis1, header.naxis2) ; image_subdark = image_subdark * header.nbin * header.ndit ; tb_history = ['Dark correction: ', ' ' + file] @@ -118,10 +143,15 @@ pro metis_l2_prep_vl_polariz header.obt_beg = obt_beg header.obt_end = obt_end header.date_avg = date_avg - header.tsensor = mean(data_header.tsensor) header.pmptemp = mean(data_header.pmptemp) + journal, 'Average values computed:' + journal, ' obt_beg = ' + string(header.obt_beg, format = '(F0)') + journal, ' date_beg = ' + header.date_avg + journal, ' tsensor = ' + string(header.tsensor, format = '(F0)') + journal, ' pmptemp = ' + string(header.pmptemp, format = '(F0)') + ; read the demodulation object of the calibration package demod_info = cal_pack.vl_channel.demodulation @@ -132,13 +162,21 @@ pro metis_l2_prep_vl_polariz ; apply the demodulation + journal, 'Demodulation:' + demod_tensor = fltarr(header.naxis1, header.naxis2, 4) + + stokes_name = ['I', 'Q', 'U'] stokes = dblarr(header.naxis1, header.naxis2, 3) stokes_subdark = dblarr(header.naxis1, header.naxis2, 3) - stokes_name = ['I', 'Q', 'U'] for i = 0, 2 do begin + + journal, ' stokes = ' + stokes_name[i] + for j = 0, 3 do begin + journal, ' pol_id = ' + string(data_header[j].pol_id, format = '(I0)') + ; check the polarization state of the image and select the corresponding dacpol value case data_header[j].pol_id of @@ -152,16 +190,27 @@ pro metis_l2_prep_vl_polariz k = where(dacpol_cal.dacpol eq dacpol) angle = dacpol_cal.angle[k] - - n = where(demod_info.angle eq angle[0] and demod_info.stokes eq stokes_name[i]) + angle = angle[0] + + journal, ' pol. angle = ' + string(angle, format = '(F0.1)') + + n = where(demod_info.angle eq angle and demod_info.stokes eq stokes_name[i], count) + + if count ne 1 then begin + journal, 'Error 06: applicable demodulation-tensor element file not found.' + journal + exit, status = 6 + endif + demod_file = demod_info[n].file_name - demod_image = float(readfits(cal_pack.path + demod_file, /silent)) ; rebin the demodulation tensor image to match image size demod_image = rebin(demod_image, header.naxis1, header.naxis2) demod_tensor[*, *, j] = demod_image + + journal, ' demod. tensor file = ' + demod_file endfor ; compute the stokes parameters @@ -183,6 +232,8 @@ pro metis_l2_prep_vl_polariz ; compute the tb from the dark-subtracted stokes i and apply other calibrations + journal, 'Calibrating total brightness...' + tb_image = reform(stokes_subdark[*, *, 0]) tb_image = metis_flat_field(tb_image, header, cal_pack, history = tb_history) tb_image = metis_vignetting(tb_image, header, cal_pack, history = tb_history) @@ -190,6 +241,8 @@ pro metis_l2_prep_vl_polariz ; compute the pb from the stokes q and u and apply other calibrations + journal, 'Calibrating polarized brightness...' + pb_image = sqrt(reform(stokes[*, *, 1])^2 + reform(stokes[*, *, 2])^2) pb_image = metis_flat_field(pb_image, header, cal_pack, history = pb_history) pb_image = metis_vignetting(pb_image, header, cal_pack, history = pb_history) @@ -197,7 +250,9 @@ pro metis_l2_prep_vl_polariz ; compute the polarization angle from the stokes q and u - pol_angle = 0.5d0 * atan(stokes[*, *, 2], stokes[*, *, 1]) * !radeg + pol_angle = 0.5D0 * atan(stokes[*, *, 2], stokes[*, *, 1]) * !radeg + + journal, 'Polarization angle correctly computed.' ; definitions for the primary header ; version of the fits file @@ -296,6 +351,9 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, primary_pb_header, pb_image mwrfits, pb_image, out_file_name, primary_pb_header, /no_comment, /create, /silent + journal, 'Polarized-brightness FITS file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the quality matrix extension_header = !null @@ -306,6 +364,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -317,6 +377,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, error_matrix mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; keywords specific for total brightness images primary_tb_header = primary_header @@ -345,6 +407,9 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, primary_tb_header, tb_image mwrfits, tb_image, out_file_name, primary_tb_header, /no_comment, /create, /silent + journal, 'Total-brightness FITS file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the quality matrix extension_header = !null @@ -355,6 +420,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -366,6 +433,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, error_matrix mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; keywords specific for polarization-angle images primary_polangle_header = primary_header @@ -394,6 +463,9 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, primary_polangle_header, pol_angle mwrfits, pol_angle, out_file_name, primary_polangle_header, /no_comment, /create, /silent + journal, 'Polarization-angle FITS file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the quality matrix extension_header = !null @@ -404,6 +476,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -415,18 +489,26 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, error_matrix mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; management of stokes images + journal, 'Calibrating Stokes parameter I...' + i = reform(stokes_subdark[*, *, 0]) i = metis_flat_field(i, header, cal_pack) i = metis_vignetting(i, header, cal_pack) i = metis_rad_cal(i, header, cal_pack, /polarimetric) + journal, 'Calibrating Stokes parameter Q...' + q = reform(stokes[*, *, 1]) q = metis_flat_field(q, header, cal_pack) q = metis_vignetting(q, header, cal_pack) q = metis_rad_cal(q, header, cal_pack, /polarimetric) + journal, 'Calibrating Stokes parameter U...' + u = reform(stokes[*, *, 2]) u = metis_flat_field(u, header, cal_pack) u = metis_vignetting(u, header, cal_pack) @@ -459,6 +541,9 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, primary_stokes_header, i mwrfits, i, out_file_name, primary_stokes_header, /no_comment, /create, /silent + journal, 'Stokes parameters FITS file created:' + journal, ' file name = ' + file_basename(out_file_name) + ; add the extension with the stokes q image extension_header = !null @@ -473,6 +558,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, q mwrfits, q, out_file_name, extension_header, /no_comment, /silent + journal, 'Q parameter extension correctly added.' + ; add the extension with the stokes u image extension_header = !null @@ -487,6 +574,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, u mwrfits, u, out_file_name, extension_header, /no_comment, /silent + journal, 'U parameter extension correctly added.' + ; add the extension with the quality matrix extension_header = !null @@ -497,6 +586,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, quality_matrix mwrfits, quality_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Quality-matrix extension correctly added.' + ; add the extension with the error matrix extension_header = !null @@ -508,6 +599,8 @@ pro metis_l2_prep_vl_polariz fits_add_checksum, extension_header, error_matrix mwrfits, error_matrix, out_file_name, extension_header, /no_comment, /silent + journal, 'Error-matrix extension correctly added.' + ; write the auxiliary information file output = { $ @@ -522,15 +615,12 @@ pro metis_l2_prep_vl_polariz load_spice_kernels, kernel_list = kernel_list, /unload - ; close the log + journal, 'SPICE kernel files unloaded.' - journal - ;exit, status = 0 - return + ; close the log - error_handling: - journal, 'Errors occurred while processing:' - journal, ' ' + error_message + journal, 'Exiting without errors.' journal - exit, status = 1 + + exit, status = 0 end diff --git a/metis_rad_cal.pro b/metis_rad_cal.pro index 7b236a48dbfd77a2b46d646481301c81ffa00329..5b3b8b64a2a3eeee01ec453fbece8642f636d076 100644 --- a/metis_rad_cal.pro +++ b/metis_rad_cal.pro @@ -10,14 +10,16 @@ function metis_rad_cal, data, header, cal_pack, polarimetric = polarimetric, his rad_info = cal_pack.vl_channel.radiometry[0] units = cal_pack.vl_channel.cal_units unit_factor = rad_info.msb.value + ndit = header.ndit end if header.filter.contains('UV', /fold) then begin angular_pixel = cal_pack.uv_channel.angular_pixel.value * header.nbin rad_info = cal_pack.uv_channel.radiometry[0] units = cal_pack.uv_channel.cal_units - pmp_factor = 1.D0 unit_factor = 1.D0 + pmp_factor = 1.D0 + ndit = header.ndit1 * header.ndit2 endif rad_factor = rad_info.rad_response.value * pmp_factor * $ @@ -25,12 +27,21 @@ function metis_rad_cal, data, header, cal_pack, polarimetric = polarimetric, his angular_pixel * $ unit_factor - cal_factor = 1. / rad_factor / header.xposure + xposure = header.dit/1000.D0 * ndit + cal_factor = 1./rad_factor/xposure data = data * cal_factor if ~ isa(history) then history = !null history = [history, 'Radiometric calibration:', ' cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN'] + journal, 'Radiometric calibration:' + journal, ' rad. response = ' + string(rad_info.rad_response.value, format = '(F0)') + ' DN/phot.' + journal, ' pupil area = ' + string(cal_pack.instrument.pupil_area.value, format = '(F0)') + ' cm²' + journal, ' pixel solid angle = ' + string(angular_pixel, format = '(E8.2)') + ' sr' + journal, ' exposure time = ' + string(xposure, format = '(F0)') + ' s' + journal, ' pmp corr. factor = ' + string(pmp_factor, format = '(F0)') + journal, ' total cal. factor = ' + string(cal_factor, format = '(E8.2)') + ' ' + units + '/DN' + return, data end diff --git a/metis_vignetting.pro b/metis_vignetting.pro index 08f8574efa69c8502ef51cba81366aa5a332ac24..1edffdd1d75e812ef6b06aa9183afa2dfe385e1c 100644 --- a/metis_vignetting.pro +++ b/metis_vignetting.pro @@ -1,5 +1,7 @@ function metis_vignetting, data, header, cal_pack, history = history + journal, 'Vignetting correction:' + if header.filter.contains('VL', /fold) then vig_info = cal_pack.vl_channel.vignetting if header.filter.contains('UV', /fold) then vig_info = cal_pack.uv_channel.vignetting @@ -29,6 +31,8 @@ function metis_vignetting, data, header, cal_pack, history = history vig_image[*, 0 : abs(dy) - 1] = 0. vig_image = rotate(vig_image, 3) vig_image = reverse(vig_image, 1) + + journal, ' UV shift applied = [' + string(dx, format = '(F0.1)') + ', ' + string(dy, format = '(F0.1)') + '] pixel' endif vig_image = rebin(vig_image, header.naxis1, header.naxis2) @@ -41,7 +45,9 @@ function metis_vignetting, data, header, cal_pack, history = history data[mask] = 0. if ~ isa(history) then history = !null - history = [history, 'Vignetting correction: ', ' ' + vig_file + ' shifted by [' + string(dx, format = '(f0.1)') + ', ' + string(dy, format = '(f0.1)') + '] pixel'] + history = [history, 'Vignetting correction: ', ' ' + vig_file + ' shifted by [' + string(dx, format = '(F0.1)') + ', ' + string(dy, format = '(F0.1)') + '] pixel'] + + journal, ' vign. function file = ' + vig_file return, data end