diff --git a/stix/VERSION.txt b/stix/VERSION.txt index 992ac75e..b0c2058e 100644 --- a/stix/VERSION.txt +++ b/stix/VERSION.txt @@ -1 +1 @@ -v0.5.1 +v0.5.2 diff --git a/stix/idl/demo/stx_imaging_demo.pro b/stix/idl/demo/stx_imaging_demo.pro index 316b8b64..c708815f 100644 --- a/stix/idl/demo/stx_imaging_demo.pro +++ b/stix/idl/demo/stx_imaging_demo.pro @@ -17,7 +17,7 @@ ; 02-september-2021, Massa P., first release ; 23-august-2022, Massa P., made compatible with the up-to-date imaging sofwtare ; 11-september-2023 - ECMD (Graz), allow user to specify output directory -; +; 11-january-2024 - Massa P., use 'stx_get_science_fits_file' and 'stx_get_ephemeris_file' to download fits files ; ;- @@ -26,28 +26,13 @@ ; Folder in which the files downloaded for this demonstration are stored default, out_dir, concat_dir( getenv('STX_DEMO_DATA'),'imaging', /d) -; URL of the STIX data center -website_url = 'https://datacenter.stix.i4ds.net/download/fits/bsd/' - ; UID of the science fits file to be dowloaded from the website uid_sci_file = "1178428688" -; Download the science fits file (if not already stored in out_dir) -sock_copy, website_url + uid_sci_file, out_name, status = status, out_dir = out_dir, $ - local_file=path_sci_file, clobber=0 +path_sci_file = stx_get_science_fits_file(uid_sci_file, out_dir=out_dir) -; UID of the background fits file to be dowloaded from the website +; UID of the background fits file to be dowloaded from the website uid_bkg_file = "1178082832" -; Download the background fits file (if not already stored in out_dir) -sock_copy, website_url + uid_bkg_file, out_name, status = status, out_dir = out_dir, $ - local_file=path_bkg_file, clobber=0 - -; URL of the server containing the L2 auxiliary fits files -website_url = 'http://dataarchive.stix.i4ds.net/fits/L2/' -; Filename of the auxiliary L2 fits file to be downloaded -file_name = '2020/06/07/AUX/solo_L2_stix-aux-ephemeris_20200607_V01.fits' -; Download the L2 auxiliary fits file (if not already stored in out_dir) -sock_copy, website_url + file_name, out_name, status = status, out_dir = out_dir, $ - local_file=aux_fits_file, clobber=0 +path_bkg_file = stx_get_science_fits_file(uid_bkg_file, out_dir=out_dir) stop @@ -60,6 +45,12 @@ energy_range = [6,10] stop +;********************************* DOWNLOAD L2 EPHEMERIS FITS FILE *********************************** + +; This file is used for creating a structure with auxiliary data to use for image reconstruction +; (see next section) +aux_fits_file = stx_get_ephemeris_file(time_range[0], time_range[1], out_dir=out_dir) + ;;******************************** CONSTRUCT AUXILIARY DATA STRUCTURE ******************************** ; Create a structure containing auxiliary data to use for image reconstruction diff --git a/stix/idl/io/stx_read_pixel_data_fits_file.pro b/stix/idl/io/stx_read_pixel_data_fits_file.pro index 2a767d0e..43bbb812 100644 --- a/stix/idl/io/stx_read_pixel_data_fits_file.pro +++ b/stix/idl/io/stx_read_pixel_data_fits_file.pro @@ -252,7 +252,6 @@ pro stx_read_pixel_data_fits_file, fits_path, time_shift, alpha = alpha, primary pixel_masks:data.pixel_masks,$ detector_masks:data.detector_masks,$ energy_bin_mask: energy_bin_mask,$ - num_pixel_sets:data.num_pixel_sets,$ - num_energy_groups:data.num_energy_groups } + num_pixel_sets:data.num_pixel_sets} end diff --git a/stix/idl/processing/spectrogram/stx_check_config_files.pro b/stix/idl/processing/spectrogram/stx_check_config_files.pro index c4dd9bd9..2eaebb3c 100644 --- a/stix/idl/processing/spectrogram/stx_check_config_files.pro +++ b/stix/idl/processing/spectrogram/stx_check_config_files.pro @@ -137,6 +137,7 @@ end ; ; :history: ; 31-Aug-2023 - ECMD (Graz), initial release +; 22-Jan-2024 - Use Dominic Zarro's __define in place of out of box IDL idlneturl ; ;- pro stx_check_config_files, directory, verbose = verbose @@ -151,7 +152,7 @@ pro stx_check_config_files, directory, verbose = verbose version_file = concat_dir(directory, 'stix_conf_version.txt') find_version_file = loc_file(version_file) - ourl = obj_new('IDLnetURL') + ourl = obj_new('IDLnetURL2') ; S.L.Freeland - use Dominic's IDLnetURL2[__define].pro in place of IDL intrinsic callback_data = ptr_new({loc:''}) ourl->setproperty, url_scheme='http' ourl->setproperty, url_host='dataarchive.stix.i4ds.net' @@ -174,4 +175,4 @@ pro stx_check_config_files, directory, verbose = verbose endif endelse -end \ No newline at end of file +end diff --git a/stix/idl/processing/spectrogram/stx_convert_pixel_data.pro b/stix/idl/processing/spectrogram/stx_convert_pixel_data.pro index 3e1ef535..a93c6b56 100644 --- a/stix/idl/processing/spectrogram/stx_convert_pixel_data.pro +++ b/stix/idl/processing/spectrogram/stx_convert_pixel_data.pro @@ -97,7 +97,7 @@ pro stx_convert_pixel_data, fits_path_data = fits_path_data, fits_path_bk = fit time_shift = time_shift, energy_shift = energy_shift, distance = distance, $ aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ det_ind = det_ind, pix_ind = pix_ind, $ - shift_duration = shift_duration, no_attenuation = no_attenuation, sys_uncert = sys_uncert, $ + elut_correction = elut_correction, shift_duration = shift_duration, no_attenuation = no_attenuation, sys_uncert = sys_uncert, $ generate_fits = generate_fits, specfile = specfile, srmfile = srmfile,$ background_data = background_data, plot = plot, ospex_obj = ospex_obj @@ -112,7 +112,8 @@ pro stx_convert_pixel_data, fits_path_data = fits_path_data, fits_path_bk = fit default, shift_duration, 0 default, plot, 1 default, det_ind, 'top24' - + default, elut_correction, 1 + if data_type(det_ind) eq 7 then det_ind = stx_label2det_ind(det_ind) if data_type(pix_ind) eq 7 then pix_ind = stx_label2pix_ind(pix_ind) @@ -188,44 +189,55 @@ pro stx_convert_pixel_data, fits_path_data = fits_path_data, fits_path_bk = fit endif - stx_read_elut, ekev_actual = ekev_actual, elut_filename = elut_filename - - ave_edge = mean(reform(ekev_actual[energy_edges_used-1, pixels_used, detectors_used, 0 ],n_energy_edges, n_pixels, n_detectors), dim= 2) - ave_edge = mean(reform(ave_edge,n_energy_edges, n_detectors), dim= 2) - - - edge_products, ave_edge, width = ewidth - - eff_ewidth = (e_axis.width)/ewidth - - counts_in = reform(counts_in,[dim_counts[0:2], n_times]) spec_in = total(reform(counts_in[*,pixels_used,detectors_used,*],[32,n_pixels,n_detectors,n_times]),2) spec_in = reform(spec_in,[dim_counts[0],n_detectors, n_times]) - counts_spec = spec_in[energy_bins,*, *] * reform(reproduce(eff_ewidth, n_detectors*n_times),n_energies, n_detectors, n_times) + counts_spec = spec_in[energy_bins,*, *] counts_spec = reform(counts_spec,[n_energies, n_detectors, n_times]) - counts_err = reform(data_str.counts_err,[dim_counts[0:2], n_times]) counts_err = sqrt(total(reform(counts_err[*,pixels_used,detectors_used,*]^2.,[32,n_pixels,n_detectors,n_times]),2)) counts_err = reform(counts_err,[dim_counts[0],n_detectors, n_times]) - counts_err = counts_err[energy_bins,*, *] * reform(reproduce(eff_ewidth, n_detectors*n_times),n_energies, n_detectors, n_times) - + counts_err = counts_err[energy_bins,*, *] + counts_err = reform(counts_err,[n_energies, n_detectors, n_times]) triggers = transpose(reform(data_str.triggers,[16, n_times])) triggers_err = transpose(reform(data_str.triggers_err,[16, n_times])) - rcr = data_str.rcr + + if keyword_set(elut_correction) then begin + + + stx_read_elut, ekev_actual = ekev_actual, elut_filename = elut_filename + + ave_edge = mean(reform(ekev_actual[energy_edges_used-1, pixels_used, detectors_used, 0 ],n_energy_edges, n_pixels, n_detectors), dim= 2) + ave_edge = mean(reform(ave_edge,n_energy_edges, n_detectors), dim= 2) + + edge_products, ave_edge, width = ewidth + + eff_ewidth = (e_axis.width)/ewidth + + + counts_spec = counts_spec * reform(reproduce(eff_ewidth, n_detectors*n_times),n_energies, n_detectors, n_times) + + counts_spec = reform(counts_spec,[n_energies, n_detectors, n_times]) + + + counts_err = counts_err * reform(reproduce(eff_ewidth, n_detectors*n_times),n_energies, n_detectors, n_times) + + counts_err = reform(counts_err,[n_energies, n_detectors, n_times]) + + endif ;insert the information from the telemetry file into the expected stx_fsw_sd_spectrogram structure spectrogram = { $ @@ -295,7 +307,7 @@ pro stx_convert_pixel_data, fits_path_data = fits_path_data, fits_path_bk = fit stx_convert_science_data2ospex, spectrogram = spectrogram, specpar=specpar, time_shift = time_shift, $ data_level = data_level, data_dims = data_dims, fits_path_bk = fits_path_bk, distance = distance, fits_path_data = fits_path_data,$ aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ - eff_ewidth = eff_ewidth, sys_uncert = sys_uncert, plot = plot, background_data = background_data, $ + eff_ewidth = eff_ewidth, sys_uncert = sys_uncert, plot = plot, background_data = background_data, elut_correction = elut_correction, $ fits_info_params = fits_info_params, ospex_obj = ospex_obj end diff --git a/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro b/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro index 6c0e2e9c..e66909f8 100644 --- a/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro +++ b/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro @@ -85,7 +85,7 @@ ;- pro stx_convert_science_data2ospex, spectrogram = spectrogram, specpar = specpar, time_shift = time_shift, data_level = data_level, data_dims = data_dims, fits_path_bk = fits_path_bk,$ distance = distance, fits_path_data = fits_path_data, fits_info_params = fits_info_params, aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ - eff_ewidth = eff_ewidth, sys_uncert = sys_uncert, xspec = xspec, background_data = background_data, plot = plot, generate_fits = generate_fits, pickfile = pickfile, ospex_obj = ospex_obj + eff_ewidth = eff_ewidth, sys_uncert = sys_uncert, xspec = xspec, elut_correction = elut_correction, background_data = background_data, plot = plot, generate_fits = generate_fits, pickfile = pickfile, ospex_obj = ospex_obj default, plot, 0 @@ -163,18 +163,25 @@ pro stx_convert_science_data2ospex, spectrogram = spectrogram, specpar = specpar energy_bins = spectrogram.energy_axis.low_fsw_idx - corrected_counts_bk = corrected_counts_bk[energy_bins,*] * reproduce(eff_ewidth, n_times) + corrected_counts_bk = corrected_counts_bk[energy_bins,*] + if keyword_set(elut_correction) then begin + corrected_counts_bk = corrected_counts_bk * reproduce(eff_ewidth, n_times) + endif + corrected_counts_bk = reform(corrected_counts_bk,[n_elements(energy_bins), n_times]) - spec_in_bk = total(reform(spec_in_bk,[dim_counts_bk[0], n_detectors_bk, ntimes_bk ]),2) spec_in_bk = (total(reform(spec_in_bk, dim_counts_bk[0], ntimes_bk),2)/total(data_str_bk.timedel))#(spectrogram.time_axis.duration) spec_in_bk = reform(spec_in_bk,dim_counts_bk[0], n_times) - spec_in_bk = spec_in_bk[energy_bins,*] * reproduce(eff_ewidth, n_times) + spec_in_bk = spec_in_bk[energy_bins,*] + + if keyword_set(elut_correction) then begin + spec_in_bk = spec_in_bk * reproduce(eff_ewidth, n_times) + endif spec_in_bk = reform(spec_in_bk,[n_elements(energy_bins), n_times]) @@ -185,10 +192,13 @@ pro stx_convert_science_data2ospex, spectrogram = spectrogram, specpar = specpar error_bk = reform(error_bk, dim_counts_bk[0], n_times) - error_bk = error_bk[energy_bins,*] * reproduce(eff_ewidth, n_times) + error_bk = error_bk[energy_bins,*] - error_bk = reform(error_bk,[n_elements(energy_bins), n_times]) + if keyword_set(elut_correction) then begin + error_bk = error_bk * reproduce(eff_ewidth, n_times) + endif + error_bk = reform(error_bk,[n_elements(energy_bins), n_times]) spec_in_corr = corrected_counts - corrected_counts_bk diff --git a/stix/idl/processing/spectrogram/stx_convert_spectrogram.pro b/stix/idl/processing/spectrogram/stx_convert_spectrogram.pro index 2b616d47..985a94e6 100644 --- a/stix/idl/processing/spectrogram/stx_convert_spectrogram.pro +++ b/stix/idl/processing/spectrogram/stx_convert_spectrogram.pro @@ -90,7 +90,7 @@ pro stx_convert_spectrogram, fits_path_data = fits_path_data, fits_path_bk = fi aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ time_shift = time_shift, energy_shift = energy_shift, distance = distance, $ replace_doubles = replace_doubles, keep_short_bins = keep_short_bins, apply_time_shift = apply_time_shift,$ - shift_duration = shift_duration, no_attenuation = no_attenuation, sys_uncert = sys_uncert, $ + elut_correction = elut_correction, shift_duration = shift_duration, no_attenuation = no_attenuation, sys_uncert = sys_uncert, $ generate_fits = generate_fits, specfile = specfile, srmfile = srmfile,$ background_data = background_data, plot = plot, ospex_obj = ospex_obj @@ -103,7 +103,8 @@ pro stx_convert_spectrogram, fits_path_data = fits_path_data, fits_path_bk = fi default, plot, 1 - + default, elut_correction, 1 + stx_read_spectrogram_fits_file, fits_path_data, time_shift, primary_header = primary_header, data_str = data_str, data_header = data_header, control_str = control_str, $ control_header= control_header, energy_str = energy_str, energy_header = energy_header, t_axis = t_axis, energy_shift = energy_shift, e_axis = e_axis , use_discriminators = 0,$ replace_doubles = replace_doubles, keep_short_bins = keep_short_bins, shift_duration = shift_duration @@ -141,25 +142,16 @@ pro stx_convert_spectrogram, fits_path_data = fits_path_data, fits_path_bk = fi detector_mask_used[detectors_used] = 1 n_detectors = total(detector_mask_used) - stx_read_elut, ekev_actual = ekev_actual, elut_filename = elut_filename - - ave_edge = mean(reform(ekev_actual[energy_edges_used-1, pixels_used, detectors_used, 0 ], n_energy_edges, n_pixels, n_detectors), dim = 2) - ave_edge = mean(reform(ave_edge,n_energy_edges, n_detectors), dim = 2) - - - edge_products, ave_edge, width = ewidth - - eff_ewidth = (e_axis.width)/ewidth counts_in = reform(counts_in,[dim_counts[0], n_times]) spec_in = counts_in - counts_spec = spec_in[energy_bins, *] * reproduce(eff_ewidth, n_times) + counts_spec = spec_in[energy_bins, *] counts_spec = reform(counts_spec,[n_energies, n_times]) - counts_err = data_str.counts_err[energy_bins,*] * reproduce(eff_ewidth, n_times) + counts_err = data_str.counts_err[energy_bins,*] counts_err = reform(counts_err,[n_energies, n_times]) @@ -169,6 +161,29 @@ pro stx_convert_spectrogram, fits_path_data = fits_path_data, fits_path_bk = fi rcr = data_str.rcr + +if keyword_set(elut_correction) then begin + stx_read_elut, ekev_actual = ekev_actual, elut_filename = elut_filename + + ave_edge = mean(reform(ekev_actual[energy_edges_used-1, pixels_used, detectors_used, 0 ], n_energy_edges, n_pixels, n_detectors), dim = 2) + ave_edge = mean(reform(ave_edge,n_energy_edges, n_detectors), dim = 2) + + edge_products, ave_edge, width = ewidth + + eff_ewidth = (e_axis.width)/ewidth + + counts_spec = counts_spec * reproduce(eff_ewidth, n_times) + + counts_spec = reform(counts_spec,[n_energies, n_times]) + + counts_err = counts_err * reproduce(eff_ewidth, n_times) + + counts_err = reform(counts_err,[n_energies, n_times]) +endif + + + + ;insert the information from the telemetry file into the expected stx_fsw_sd_spectrogram structure spectrogram = { $ type : "stx_fsw_sd_spectrogram", $ @@ -233,7 +248,7 @@ pro stx_convert_spectrogram, fits_path_data = fits_path_data, fits_path_bk = fi specpar = { sp_atten_state : {time:ut_rcr[index], state:state}, flare_xyoffset : fltarr(2), use_flare_xyoffset:0 } stx_convert_science_data2ospex, spectrogram = spectrogram, specpar = specpar, time_shift = time_shift, data_level = data_level, data_dims = data_dims, fits_path_bk = fits_path_bk, $ - distance = distance, fits_path_data = fits_path_data, eff_ewidth = eff_ewidth, fits_info_params = fits_info_params, sys_uncert = sys_uncert, $ + distance = distance, fits_path_data = fits_path_data, elut_correction = elut_correction, eff_ewidth = eff_ewidth, fits_info_params = fits_info_params, sys_uncert = sys_uncert, $ aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ background_data = background_data, plot = plot, generate_fits = generate_fits, ospex_obj = ospex_obj diff --git a/stix/idl/processing/spectrogram/stx_science_data_lightcurve.pro b/stix/idl/processing/spectrogram/stx_science_data_lightcurve.pro index 1bc1a2a2..c640348c 100644 --- a/stix/idl/processing/spectrogram/stx_science_data_lightcurve.pro +++ b/stix/idl/processing/spectrogram/stx_science_data_lightcurve.pro @@ -81,13 +81,14 @@ ;- function stx_science_data_lightcurve, fits_path, energy_ranges = edges_in, time_min = time_min, $ fits_path_bk = fits_path_bk, plot_obj = plot_obj, time_shift = time_shift, rate = rate, shift_duration = shift_duration, $ - det_ind = det_ind, pix_ind = pix_ind, sys_uncert = sys_uncert, time_range = time_range, _extra= _extra + det_ind = det_ind, pix_ind = pix_ind, elut_correction = elut_correction, sys_uncert = sys_uncert, time_range = time_range, _extra= _extra default, time_min, 20 default, edges_in, [[4.,10.],[10,15],[15,25]] default, spex_units, 'flux' - + default, elut_correction, 0 + ; If /rate is set, return the rate units if keyword_set(rate) then spex_units = 'rate' @@ -114,10 +115,10 @@ function stx_science_data_lightcurve, fits_path, energy_ranges = edges_in, time if strpos(orig_filename, 'cpd') gt -1 or strpos(orig_filename, 'xray-l1') gt -1 then begin stx_convert_pixel_data, fits_path_data = fits_path[this_file], fits_path_bk = fits_path_bk, distance = distance, time_shift = time_shift, ospex_obj = ospex_obj, $ - det_ind = det_ind, pix_ind = pix_ind, sys_uncert = sys_uncert, plot = 0, _extra= _extra + det_ind = det_ind, pix_ind = pix_ind, sys_uncert = sys_uncert, elut_correction = elut_correction, plot = 0, _extra= _extra endif else if strpos(orig_filename, 'spec') gt -1 or strpos(orig_filename, 'spectrogram') gt -1 then begin stx_convert_spectrogram, fits_path_data = fits_path[this_file], fits_path_bk = fits_path_bk, distance = distance, time_shift = time_shift, ospex_obj = ospex_obj, $ - sys_uncert = sys_uncert, plot = 0, _extra= _extra + sys_uncert = sys_uncert, elut_correction = elut_correction, plot = 0, _extra= _extra if keyword_set(det_ind) or keyword_set(pix_ind) then message, 'ERROR: Detector and pixel selection not possible with spectrogram files.' endif else begin message, 'ERROR: the FILENAME field in the primary header should contain either cpd, xray-l1 or spec' diff --git a/stix/setup/IDL_STARTUP b/stix/setup/IDL_STARTUP new file mode 100644 index 00000000..754716d6 --- /dev/null +++ b/stix/setup/IDL_STARTUP @@ -0,0 +1,4 @@ +; STIX idl startup +;---------------------------------------------- + +stx_check_config_files