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

Version 1.0

parent 4b2ecbac
No related branches found
No related tags found
No related merge requests found
function decode_obt, t_coarse, t_fine, to_double = to_double, from_double = from_double
if keyword_set(from_double) then begin
obt = t_coarse
t_coarse = ulong(obt)
t_fine = uint((obt - t_coarse) * 65536.0D)
endif
if keyword_set(to_double) then begin
return, double(t_coarse) + double(t_fine)/65536.0D
endif
return, t_coarse.tostring() + ':' + t_fine.tostring()
end
\ No newline at end of file
......@@ -5,6 +5,6 @@ function interpol_param, hk_table, par_name, time
times = strsplit(hk_table.gen_time[i[j]], ":", /extract)
hk_time[j] = double(times[0]) + double(times[1])/65536.0D
endfor
value = interpol(float(hk_table.cal_val[i]), hk_time, time)
value = interpol(float(hk_table.eng_val[i]), hk_time, time)
return, value
end
\ No newline at end of file
......@@ -46,24 +46,24 @@ pro metis_l1_prep
; read l0 fits structure
fits_info, input.l0_file_name, n_ext = n_ext, extname = extname, /silent
fits_info, input.file_name, n_ext = n_ext, extname = extname, /silent
; read the primary hdu
ext_no = 0
image = mrdfits(input.l0_file_name, ext_no, primary_header, /silent)
image = mrdfits(input.file_name, ext_no, primary_header, /silent)
; if the data is not an image, read the data binary-table extension
if fxpar(primary_header, 'NAXIS') eq 0 then begin
ext_no += 1
data_bin_table = mrdfits(input.l0_file_name, ext_no, data_extension_header, /silent)
data_bin_table = mrdfits(input.file_name, ext_no, data_extension_header, /silent)
endif else data_bin_table = !null
; read the metadata extension
ext_no += 1
metadata_bin_table = mrdfits(input.l0_file_name, ext_no, metadata_extension_header, /silent)
metadata_bin_table = mrdfits(input.file_name, ext_no, metadata_extension_header, /silent)
; identify the data product and its nominal size
......@@ -88,7 +88,7 @@ pro metis_l1_prep
if datatype eq 2 then begin
if fxpar(metadata_extension_header, 'M') eq 256 then begin
ext_no += 1
accumul_vector = mrdfits(input.l0_file_name, ext_no, vector_extension_header, /silent)
accumul_vector = mrdfits(input.file_name, ext_no, vector_extension_header, /silent)
endif else accumul_vector = !null
endif
......@@ -152,20 +152,20 @@ pro metis_l1_prep
; join the metadata extension header to the primary header removing unwanted keywords
i = where(strmid(primary_header, 0, 8) eq 'COMP_RAT')
i = where(strmid(primary_header, 0, 8) eq 'DATASUM ')
j = where(strmid(metadata_extension_header, 0, 8) eq 'EXTNAME ')
n = n_elements(metadata_extension_header)
k = where(strmid(metadata_extension_header, 0, 8) eq 'TFORM1 ')
primary_header = [ $
primary_header[0 : i], $
metadata_extension_header[j + 1 : n - 2], $
primary_header[i + 1 : *] $
primary_header[0 : i - 1], $
metadata_extension_header[j + 1 : k - 1], $
primary_header[i : *] $
]
; adjust the primary header (it is almost the same for all data product types)
fxaddpar, primary_header, 'FILENAME', file_name, 'FITS filename'
fxaddpar, primary_header, 'PARENT', file_basename(input.l0_file_name), 'Name of the parent file that got processed to the current one', before = 'APID'
fxaddpar, primary_header, 'PARENT', file_basename(input.file_name), 'Name of the parent file that got processed to the current one', before = 'APID'
fxaddpar, primary_header, 'DATE', date, 'Date and time of FITS file creation', before = 'OBT_BEG'
fxaddpar, primary_header, 'DATE-OBS', date_beg, 'Same as DATE-BEG', before = 'OBT_BEG'
fxaddpar, primary_header, 'DATE-BEG', date_beg, 'Start time of observation', before = 'OBT_BEG'
......@@ -217,7 +217,7 @@ pro metis_l1_prep
; add keywords for file history
fxaddpar, primary_header, 'HISTORY', 'Third history line'
; fxaddpar, primary_header, 'HISTORY', ''
; remove unused keywords
......@@ -288,11 +288,11 @@ pro metis_l1_prep
output = { $
file_name: out_file_name, $
l0_file_name: input.l0_file_name, $
log_file_name: '' $
l0_file_name: input.file_name, $
log_file_name: 'output/metis_l1_prep_log.txt' $
}
openw, unit, 'output/contents.json'
openw, unit, 'output/contents.json', /get_lun
printf, unit, output, /implied_print
free_lun, unit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment