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

Update UVDA dark selection procedure

parent 807a3e87
No related branches found
No related tags found
No related merge requests found
function m_angle_uv, matrix
a = mean(matrix[10:45, 10:45])
b = mean(matrix[980:1014, 10:45])
c = mean(matrix[10:45, 980:1014])
d = mean(matrix[980:1014, 980:1014])
return, [a, b, c, d]
end
function m_center_uv, matrix
a = mean(matrix[454:574, 460:582])
return, a
end
function correzione_uvda, image, dark
ima_ndit1 = rebin(image, 1024, 1024, /sample)
ima_ndit2 = rebin(dark, 1024, 1024, /sample)
x = [m_angle_uv(ima_ndit2), m_center_uv(ima_ndit2)]
y = [m_angle_uv(ima_ndit1), m_center_uv(ima_ndit1)]
r = linfit(x, y, yfit = yfit)
ima = r[0] + ima_ndit2 * r[1]
s = size(image)
ima = rebin(ima, s[1], s[2])
return, ima
end
function metis_dark_uvda, data, header, cal_pack, error = error, quality_matrix = quality_matrix, history = history
dark = cal_pack.uv_channel.dark
......@@ -24,11 +59,27 @@ function metis_dark_uvda, data, header, cal_pack, error = error, quality_matrix
for i = 0, n_elements(dark) - 1 do begin
if $
(dark[i].dit eq dit) and $
(dark[i].ndit1 eq ndit1) and $
(dark[i].ndit2 eq ndit2) and $
(abs(dark[i].tsensor - tsensor) lt 5) and $
(flag_use_notfullset or dark[i].fullset) and $
(dark[i].extrapol eq 'False') then $
obt_available = [obt_available, dark[i].obt_beg]
endfor
; if not, search for extrapolated dark matrices with same parameters
if ~ isa(obt_available) and flag_use_extrapolated then begin
for i = 0, n_elements(dark) - 1 do begin
if $
(dark[i].dit eq dit) and $
(dark[i].ndit1 eq ndit1) and $
(dark[i].ndit2 eq ndit2) and $
(abs(dark[i].tsensor - tsensor) lt 5) and $
(dark[i].ndit1 eq ndit1) and (dark[i].ndit2 eq ndit2) and $
flag_use_notfullset and flag_use_extrapolated then $
(flag_use_notfullset or dark[i].fullset) and $
(dark[i].extrapol eq 'True') then $
obt_available = [obt_available, dark[i].obt_beg]
endfor
endif
; if not, exit with error code
if ~ isa(obt_available) then begin
......@@ -48,9 +99,6 @@ function metis_dark_uvda, data, header, cal_pack, error = error, quality_matrix
dark_file = dark[i].filename.cnt_1[obj_cnt - 1] else $
dark_file = dark[i].filename.cnt_2
; apply normalization if required
if flag_normalize_dark and masking.contains('disabled', /fold) then $
dark_image = correzione_uvda(data, cal_pack.path + dark_file) else $
dark_image = float(readfits(cal_pack.path + dark_file, /silent))
dark_nobin = dark_image
......@@ -59,6 +107,10 @@ function metis_dark_uvda, data, header, cal_pack, error = error, quality_matrix
dark_image = rebin(dark_image, header.naxis1, header.naxis2) * nbin
dark_image = dark_image * ndit1 * ndit2
; apply normalization if required
if flag_normalize_dark and masking.contains('disabled', /fold) then $
dark_image = correzione_uvda(data, dark_image)
mask = where(data eq 0., count)
data = data - dark_image
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment