Loading check_quality.pro +5 −5 Original line number Original line Diff line number Diff line function check_quality, data, cal_pack, filter = filter function check_quality, data, cal_pack, filter if filter.contains('VL', /fold) then $ if not keyword_set(filter) then filter = 'VL' channel = cal_pack.vl_channel else $ channel = cal_pack.uv_channel if filter.contains('VL', /fold) then channel = cal_pack.vl_channel else channel = cal_pack.uv_channel levels = channel.sat_level.value levels = channel.sat_level.value Loading fits_hdr2struct.pro +1 −1 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ function fits_hdr2struct, string_hdr tag = tag.trim() tag = tag.trim() if tag eq '' then continue if tag eq '' then continue if tag.startswith('end', /fold) or tag.contains('continue', /fold) then continue if tag.startswith('end', /fold) or tag.contains('continue', /fold) then continue if isa(struct) then if where(tag_names(struct) eq tag) ge 0 then continue if isa(struct) then if (tag_names(struct)).hasvalue(tag) then continue struct = create_struct(struct, tag.replace('-', ' '), fxpar(string_hdr, tag)) struct = create_struct(struct, tag.replace('-', ' '), fxpar(string_hdr, tag)) endfor endfor Loading get_light_time.pro +5 −5 Original line number Original line Diff line number Diff line function get_light_time, utc, body, target, radvel = radvel function get_light_time, utc, target, observer, rad_velocity = rad_velocity ; convert the requested date into ephemeris time ; convert the requested date into ephemeris time cspice_str2et, utc, et cspice_str2et, utc, et ; coordinates of the body wrt the target in the j2000 system ; coordinates of the target wrt the target in the j2000 system cspice_spkezr, body, et, 'J2000', 'NONE', target, state, ltime cspice_spkezr, target, et, 'J2000', 'NONE', observer, state, light_time ; radial component of the velocity ; radial component of the velocity radvel = 1000.d0 * total(state[0 : 2] * state[3 : 5])/sqrt(total(state[0 : 2]^2)) rad_velocity = 1000. * total(state[0 : 2] * state[3 : 5])/sqrt(total(state[0 : 2]^2)) return, ltime return, light_time end end interpol_param.pro +9 −6 Original line number Original line Diff line number Diff line function interpol_param, table, par_name, date, empty_params = empty_params function interpol_param, table, par_name, date, empty_params = empty_params sample = where(table.par_name eq par_name, n) if not keyword_set(empty_params) then empty_params = !null s = where(table.par_name eq par_name, n) if n eq 0 then return, 0.0 par_time = table.gen_time[s] par_val = table.eng_val[s] par_date = dblarr(n) par_date = dblarr(n) for k = 0, n - 1 do par_date[k] = date_conv(table.gen_time[sample[k]], 'JULIAN') for i = 0, n - 1 do par_date[i] = date_conv(par_time[i], 'JULIAN') if total(table.eng_val[sample].contains('N/A')) then begin if max(par_val.contains('N/A')) then begin table.eng_val[sample] = table.raw_val[sample] empty_params = [empty_params, par_name] empty_params = [empty_params, par_name] par_val = table.raw_val[s] endif endif par_val = float(table.eng_val[sample]) s = sort(par_date) s = sort(par_date) par_val = par_val[s] par_val = par_val[s] par_date = par_date[s] par_date = par_date[s] jul_date = date_conv(date, 'JULIAN') jul_date = date_conv(date, 'JULIAN') if jul_date ge min(par_date) and jul_date le max(par_date) then value = interpol(par_val, par_date, jul_date) else value = 0.0 if jul_date ge min(par_date) and jul_date le max(par_date) then value = interpol(float(par_val), par_date, jul_date) else value = 0.0 if finite(value) then return, value else return, 0.0 if finite(value) then return, value else return, 0.0 end end metis_l1_prep.pro 100644 → 100755 +23 −19 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,10 @@ pro metis_l1_prep cal_pack = create_struct('path', input.cal_pack_path + path_sep(), cal_pack) 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 ; read the primary hdu data = mrdfits(input.file_name, 0, primary_header, /silent) data = mrdfits(input.file_name, 0, primary_header, /silent) Loading Loading @@ -100,7 +104,8 @@ pro metis_l1_prep date_beg_string = date_beg_string.replace('-', '') date_beg_string = date_beg_string.replace('-', '') date_beg_string = date_beg_string.replace(':', '') date_beg_string = date_beg_string.replace(':', '') journal, 'UTC time of start acquisition = ' + date_beg journal, 'Calculated UTC time of start acquisition:' journal, ' time = ' + date_beg ; name of the fits file ; name of the fits file Loading Loading @@ -130,11 +135,11 @@ pro metis_l1_prep ; instrument/telescope/detector keywords ; instrument/telescope/detector keywords detector = filter + 'D' detector = filter + 'D' waveband = cal_pack.vl_channel.name telescope = 'SOLO/Metis/' + detector telescope = 'SOLO/Metis/' + detector wavelnth = channel.bandpass.value[1] wavelnth = channel.bandpass.value[1] wavemin = channel.bandpass.value[0] wavemin = channel.bandpass.value[0] wavemax = channel.bandpass.value[2] wavemax = channel.bandpass.value[2] waveband = channel.name ; campaign keywords ; campaign keywords Loading Loading @@ -177,7 +182,7 @@ pro metis_l1_prep ; evaluate the quality matrix ; evaluate the quality matrix quality_matrix = check_quality(data, cal_pack, filter = filter) quality_matrix = check_quality(data, cal_pack, filter) ; correct values including binning factor only for vl and uv images and accumulation matrices ; correct values including binning factor only for vl and uv images and accumulation matrices Loading @@ -191,7 +196,7 @@ pro metis_l1_prep journal, ' data was rebinned:' journal, ' data was rebinned:' journal, ' new size = ' + string(naxis1, format = '(I0)') + '×' + string(naxis2, format = '(I0)') journal, ' new size = ' + string(naxis1, format = '(I0)') + '×' + string(naxis2, format = '(I0)') endif else begin endif else begin quality_matrix = check_quality(data, cal_pack, filter = filter) quality_matrix = check_quality(data, cal_pack, filter) journal, 'Data was not binned during acquistion.' journal, 'Data was not binned during acquistion.' endelse endelse Loading Loading @@ -222,16 +227,18 @@ pro metis_l1_prep if datatype le 2 then begin if datatype le 2 then begin nsumexp = ndit * ndit1 * ndit2 nsumexp = ndit * ndit1 * ndit2 xposure = dit/1000. * nsumexp xposure = dit/1000.D0 * nsumexp data = long(data) * nsumexp data = long(data) * nsumexp if ~ isa(comment) then comment = !null if ~ isa(comment) then comment = !null comment = [comment, 'Image values were corrected for the total exposure time.'] comment = [comment, 'Image values were corrected for the total exposure time.'] journal, 'Image values were corrected for the total exposure time.' journal, 'Image values were corrected for the total exposure time:' journal, ' dit = ' + string(dit, format = '(I0)') journal, ' nsumexp = ' + string(nsumexp, format = '(I0)') endif else begin endif else begin nsumexp = 1 nsumexp = 1 xposure = dit/1000. xposure = dit/1000.D0 endelse endelse ; adjust the primary header (it is almost the same for all data product types) ; adjust the primary header (it is almost the same for all data product types) Loading Loading @@ -398,10 +405,10 @@ pro metis_l1_prep ; append solar keywords ; append solar keywords ephemerides = solo_get_ephemerides(header, constants = cal_pack.constants) ephemeris = solo_get_ephemeris(header, cal_pack) foreach element, ephemerides do fxaddpar, primary_header, element.name, element.value, element.comment, before = 'DATATYPE' foreach element, ephemeris do fxaddpar, primary_header, element.name, element.value, element.comment, before = 'DATATYPE' fxaddpar, primary_header, 'HISTORY', 'WCS and solar ephemerides:' fxaddpar, primary_header, 'HISTORY', 'WCS and solar ephemeris:' fxaddpar, primary_header, 'HISTORY', ' SKD version = ' + kernel_version fxaddpar, primary_header, 'HISTORY', ' SKD version = ' + kernel_version ; remove redundant and misleading keywords ; remove redundant and misleading keywords Loading Loading @@ -469,6 +476,8 @@ pro metis_l1_prep fxaddpar, quality_matrix_header, 'EXTNAME', 'Quality matrix', 'Extension name' fxaddpar, quality_matrix_header, 'EXTNAME', 'Quality matrix', 'Extension name' fits_add_checksum, quality_matrix_header, quality_matrix fits_add_checksum, quality_matrix_header, quality_matrix mwrfits, quality_matrix, out_file_name, quality_matrix_header, /no_comment, /silent mwrfits, quality_matrix, out_file_name, quality_matrix_header, /no_comment, /silent journal, 'Quality-matrix extension correctly added.' endif endif ; build the telemetry extension ; build the telemetry extension Loading @@ -481,7 +490,7 @@ pro metis_l1_prep hk_bin_table = make_bin_table(hk_table) hk_bin_table = make_bin_table(hk_table) mwrfits, hk_bin_table, out_file_name, hk_extension_header, /no_comment, /silent mwrfits, hk_bin_table, out_file_name, hk_extension_header, /no_comment, /silent journal, ' HK binary-table extension correctly added' journal, 'HK binary-table extension correctly added.' ; unload the spice kernels ; unload the spice kernels Loading @@ -500,16 +509,11 @@ pro metis_l1_prep json_write, output, 'output/contents.json' json_write, output, 'output/contents.json' journal, 'Output saved.' journal, 'Output saved' ;close the log ;close the log journal, 'Exiting without errors.' journal, 'Exiting without errors.' journal journal exit, status = 0 exit, status = 0 error_handling: journal, 'Errors occurred while processing.' journal exit, status = 1 end end Loading
check_quality.pro +5 −5 Original line number Original line Diff line number Diff line function check_quality, data, cal_pack, filter = filter function check_quality, data, cal_pack, filter if filter.contains('VL', /fold) then $ if not keyword_set(filter) then filter = 'VL' channel = cal_pack.vl_channel else $ channel = cal_pack.uv_channel if filter.contains('VL', /fold) then channel = cal_pack.vl_channel else channel = cal_pack.uv_channel levels = channel.sat_level.value levels = channel.sat_level.value Loading
fits_hdr2struct.pro +1 −1 Original line number Original line Diff line number Diff line Loading @@ -7,7 +7,7 @@ function fits_hdr2struct, string_hdr tag = tag.trim() tag = tag.trim() if tag eq '' then continue if tag eq '' then continue if tag.startswith('end', /fold) or tag.contains('continue', /fold) then continue if tag.startswith('end', /fold) or tag.contains('continue', /fold) then continue if isa(struct) then if where(tag_names(struct) eq tag) ge 0 then continue if isa(struct) then if (tag_names(struct)).hasvalue(tag) then continue struct = create_struct(struct, tag.replace('-', ' '), fxpar(string_hdr, tag)) struct = create_struct(struct, tag.replace('-', ' '), fxpar(string_hdr, tag)) endfor endfor Loading
get_light_time.pro +5 −5 Original line number Original line Diff line number Diff line function get_light_time, utc, body, target, radvel = radvel function get_light_time, utc, target, observer, rad_velocity = rad_velocity ; convert the requested date into ephemeris time ; convert the requested date into ephemeris time cspice_str2et, utc, et cspice_str2et, utc, et ; coordinates of the body wrt the target in the j2000 system ; coordinates of the target wrt the target in the j2000 system cspice_spkezr, body, et, 'J2000', 'NONE', target, state, ltime cspice_spkezr, target, et, 'J2000', 'NONE', observer, state, light_time ; radial component of the velocity ; radial component of the velocity radvel = 1000.d0 * total(state[0 : 2] * state[3 : 5])/sqrt(total(state[0 : 2]^2)) rad_velocity = 1000. * total(state[0 : 2] * state[3 : 5])/sqrt(total(state[0 : 2]^2)) return, ltime return, light_time end end
interpol_param.pro +9 −6 Original line number Original line Diff line number Diff line function interpol_param, table, par_name, date, empty_params = empty_params function interpol_param, table, par_name, date, empty_params = empty_params sample = where(table.par_name eq par_name, n) if not keyword_set(empty_params) then empty_params = !null s = where(table.par_name eq par_name, n) if n eq 0 then return, 0.0 par_time = table.gen_time[s] par_val = table.eng_val[s] par_date = dblarr(n) par_date = dblarr(n) for k = 0, n - 1 do par_date[k] = date_conv(table.gen_time[sample[k]], 'JULIAN') for i = 0, n - 1 do par_date[i] = date_conv(par_time[i], 'JULIAN') if total(table.eng_val[sample].contains('N/A')) then begin if max(par_val.contains('N/A')) then begin table.eng_val[sample] = table.raw_val[sample] empty_params = [empty_params, par_name] empty_params = [empty_params, par_name] par_val = table.raw_val[s] endif endif par_val = float(table.eng_val[sample]) s = sort(par_date) s = sort(par_date) par_val = par_val[s] par_val = par_val[s] par_date = par_date[s] par_date = par_date[s] jul_date = date_conv(date, 'JULIAN') jul_date = date_conv(date, 'JULIAN') if jul_date ge min(par_date) and jul_date le max(par_date) then value = interpol(par_val, par_date, jul_date) else value = 0.0 if jul_date ge min(par_date) and jul_date le max(par_date) then value = interpol(float(par_val), par_date, jul_date) else value = 0.0 if finite(value) then return, value else return, 0.0 if finite(value) then return, value else return, 0.0 end end
metis_l1_prep.pro 100644 → 100755 +23 −19 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,10 @@ pro metis_l1_prep cal_pack = create_struct('path', input.cal_pack_path + path_sep(), cal_pack) 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 ; read the primary hdu data = mrdfits(input.file_name, 0, primary_header, /silent) data = mrdfits(input.file_name, 0, primary_header, /silent) Loading Loading @@ -100,7 +104,8 @@ pro metis_l1_prep date_beg_string = date_beg_string.replace('-', '') date_beg_string = date_beg_string.replace('-', '') date_beg_string = date_beg_string.replace(':', '') date_beg_string = date_beg_string.replace(':', '') journal, 'UTC time of start acquisition = ' + date_beg journal, 'Calculated UTC time of start acquisition:' journal, ' time = ' + date_beg ; name of the fits file ; name of the fits file Loading Loading @@ -130,11 +135,11 @@ pro metis_l1_prep ; instrument/telescope/detector keywords ; instrument/telescope/detector keywords detector = filter + 'D' detector = filter + 'D' waveband = cal_pack.vl_channel.name telescope = 'SOLO/Metis/' + detector telescope = 'SOLO/Metis/' + detector wavelnth = channel.bandpass.value[1] wavelnth = channel.bandpass.value[1] wavemin = channel.bandpass.value[0] wavemin = channel.bandpass.value[0] wavemax = channel.bandpass.value[2] wavemax = channel.bandpass.value[2] waveband = channel.name ; campaign keywords ; campaign keywords Loading Loading @@ -177,7 +182,7 @@ pro metis_l1_prep ; evaluate the quality matrix ; evaluate the quality matrix quality_matrix = check_quality(data, cal_pack, filter = filter) quality_matrix = check_quality(data, cal_pack, filter) ; correct values including binning factor only for vl and uv images and accumulation matrices ; correct values including binning factor only for vl and uv images and accumulation matrices Loading @@ -191,7 +196,7 @@ pro metis_l1_prep journal, ' data was rebinned:' journal, ' data was rebinned:' journal, ' new size = ' + string(naxis1, format = '(I0)') + '×' + string(naxis2, format = '(I0)') journal, ' new size = ' + string(naxis1, format = '(I0)') + '×' + string(naxis2, format = '(I0)') endif else begin endif else begin quality_matrix = check_quality(data, cal_pack, filter = filter) quality_matrix = check_quality(data, cal_pack, filter) journal, 'Data was not binned during acquistion.' journal, 'Data was not binned during acquistion.' endelse endelse Loading Loading @@ -222,16 +227,18 @@ pro metis_l1_prep if datatype le 2 then begin if datatype le 2 then begin nsumexp = ndit * ndit1 * ndit2 nsumexp = ndit * ndit1 * ndit2 xposure = dit/1000. * nsumexp xposure = dit/1000.D0 * nsumexp data = long(data) * nsumexp data = long(data) * nsumexp if ~ isa(comment) then comment = !null if ~ isa(comment) then comment = !null comment = [comment, 'Image values were corrected for the total exposure time.'] comment = [comment, 'Image values were corrected for the total exposure time.'] journal, 'Image values were corrected for the total exposure time.' journal, 'Image values were corrected for the total exposure time:' journal, ' dit = ' + string(dit, format = '(I0)') journal, ' nsumexp = ' + string(nsumexp, format = '(I0)') endif else begin endif else begin nsumexp = 1 nsumexp = 1 xposure = dit/1000. xposure = dit/1000.D0 endelse endelse ; adjust the primary header (it is almost the same for all data product types) ; adjust the primary header (it is almost the same for all data product types) Loading Loading @@ -398,10 +405,10 @@ pro metis_l1_prep ; append solar keywords ; append solar keywords ephemerides = solo_get_ephemerides(header, constants = cal_pack.constants) ephemeris = solo_get_ephemeris(header, cal_pack) foreach element, ephemerides do fxaddpar, primary_header, element.name, element.value, element.comment, before = 'DATATYPE' foreach element, ephemeris do fxaddpar, primary_header, element.name, element.value, element.comment, before = 'DATATYPE' fxaddpar, primary_header, 'HISTORY', 'WCS and solar ephemerides:' fxaddpar, primary_header, 'HISTORY', 'WCS and solar ephemeris:' fxaddpar, primary_header, 'HISTORY', ' SKD version = ' + kernel_version fxaddpar, primary_header, 'HISTORY', ' SKD version = ' + kernel_version ; remove redundant and misleading keywords ; remove redundant and misleading keywords Loading Loading @@ -469,6 +476,8 @@ pro metis_l1_prep fxaddpar, quality_matrix_header, 'EXTNAME', 'Quality matrix', 'Extension name' fxaddpar, quality_matrix_header, 'EXTNAME', 'Quality matrix', 'Extension name' fits_add_checksum, quality_matrix_header, quality_matrix fits_add_checksum, quality_matrix_header, quality_matrix mwrfits, quality_matrix, out_file_name, quality_matrix_header, /no_comment, /silent mwrfits, quality_matrix, out_file_name, quality_matrix_header, /no_comment, /silent journal, 'Quality-matrix extension correctly added.' endif endif ; build the telemetry extension ; build the telemetry extension Loading @@ -481,7 +490,7 @@ pro metis_l1_prep hk_bin_table = make_bin_table(hk_table) hk_bin_table = make_bin_table(hk_table) mwrfits, hk_bin_table, out_file_name, hk_extension_header, /no_comment, /silent mwrfits, hk_bin_table, out_file_name, hk_extension_header, /no_comment, /silent journal, ' HK binary-table extension correctly added' journal, 'HK binary-table extension correctly added.' ; unload the spice kernels ; unload the spice kernels Loading @@ -500,16 +509,11 @@ pro metis_l1_prep json_write, output, 'output/contents.json' json_write, output, 'output/contents.json' journal, 'Output saved.' journal, 'Output saved' ;close the log ;close the log journal, 'Exiting without errors.' journal, 'Exiting without errors.' journal journal exit, status = 0 exit, status = 0 error_handling: journal, 'Errors occurred while processing.' journal exit, status = 1 end end