From 920e80ca95ae6fecf72991604a86771e53281775 Mon Sep 17 00:00:00 2001 From: Ewan Dickson <35922612+grazwegian@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:29:12 +0200 Subject: [PATCH 1/3] update elut index --- stix/dbase/detector/elut_index.csv | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) mode change 100644 => 100755 stix/dbase/detector/elut_index.csv diff --git a/stix/dbase/detector/elut_index.csv b/stix/dbase/detector/elut_index.csv old mode 100644 new mode 100755 index 6dc7bf31..90b2ae43 --- a/stix/dbase/detector/elut_index.csv +++ b/stix/dbase/detector/elut_index.csv @@ -1,10 +1,13 @@ -index, start_date, end_date, elut_file -0, 2020-02-14T00:00:00, 2021-01-01T00:00:00, elut_table_20200519.csv -1, 2021-01-01T00:00:00, 2021-05-25T14:55:49, elut_table_20201204.csv -2, 2021-05-25T14:55:49, 2021-12-09T00:00:00, elut_table_20210625.csv -3, 2021-12-09T00:00:00, 2022-06-01T00:00:00, elut_table_20211209.csv -4, 2022-06-01T00:00:00, 2022-09-18T00:00:00, elut_table_20220601.csv -5, 2022-09-18T00:00:00, 2023-01-19T17:02:40, elut_table_20220918.csv -6, 2023-01-19T17:02:40, 2023-01-30T00:04:35, elut_table_20221214.csv -7, 2023-01-30T00:04:35, 2023-02-02T16:06:12, elut_table_20221220.csv -8, 2023-02-02T16:06:12, none, elut_table_20221214.csv +index, start_date, end_date, elut_file +0, 2020-02-14T00:00:00, 2021-01-01T00:00:00, elut_table_20200519.csv +1, 2021-01-01T00:00:00, 2021-05-25T14:55:49, elut_table_20201204.csv +2, 2021-05-25T14:55:49, 2021-12-09T00:00:00, elut_table_20210625.csv +3, 2021-12-09T00:00:00, 2022-06-01T00:00:00, elut_table_20211209.csv +4, 2022-06-01T00:00:00, 2022-09-18T00:00:00, elut_table_20220601.csv +5, 2022-09-18T00:00:00, 2023-01-19T17:02:40, elut_table_20220918.csv +6, 2023-01-19T17:02:40, 2023-01-30T00:04:35, elut_table_20221214.csv +7, 2023-01-30T00:04:35, 2023-02-02T16:06:12, elut_table_20221220.csv +8, 2023-02-02T16:06:12, 2023-06-19T00:04:35, elut_table_20221214.csv +9, 2023-06-19T00:04:35, 2023-07-03T00:04:52, elut_table_20230606.csv +10, 2023-07-03T00:04:52, 2023-07-31T00:05:58, elut_table_20230612.csv +11, 2023-07-31T00:05:58, none, elut_table_20230710.csv \ No newline at end of file From 93cbd70264a1ce7dd2370e7c97e3e525218ee8d6 Mon Sep 17 00:00:00 2001 From: Ewan Dickson <35922612+grazwegian@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:52:38 +0100 Subject: [PATCH 2/3] Automatic formatting --- .../stx_convert_science_data2ospex.pro | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro b/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro index e66909f8..e9584b65 100644 --- a/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro +++ b/stix/idl/processing/spectrogram/stx_convert_science_data2ospex.pro @@ -22,7 +22,7 @@ ; specpar : in, type="float", ; spectrum control and information parameters for OSPEX ; -; time_shift : in, type="float", +; time_shift : in, type="float", ; Applied light travel time correction ; ; data_level : in, type="int", default="1.0" @@ -37,14 +37,14 @@ ; distance : in, optional, type="float", default taken from FITS header ; The distance between Solar Orbiter and the Sun centre in Astronomical Units needed to correct flux. ; -; flare_location_hpc : in, type=" 2 element float array", +; flare_location_hpc : in, type=" 2 element float array", ; the location of the flare (X,Y) in Helioprojective Cartesian coordinates as seen from Solar Orbiter [arcsec] -; If no location is passed in the on-axis approximation is used to calculate the grid response. In this case +; If no location is passed in the on-axis approximation is used to calculate the grid response. In this case ; a value [Nan, Nan] is passed to the output files. ; ; aux_fits_file : in, required if flare_location_hpc is passed in, type="string" ; the path of the auxiliary ephemeris FITS file to be read." -; +; ; eff_ewidth : in, type="float arr" ; an output float value ; @@ -85,17 +85,17 @@ ;- 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, elut_correction = elut_correction, 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 - time_range = atime(stx_time2any([spectrogram.time_axis.time_start[0], spectrogram.time_axis.time_end[-1]])) - - if n_elements(flare_location_hpc) eq 2 and n_elements(aux_fits_file) eq 0 then aux_fits_file = stx_get_ephemeris_file( time_range[0], time_range[1]) + time_range = atime(stx_time2any([spectrogram.time_axis.time_start[0], spectrogram.time_axis.time_end[-1]])) + + if n_elements(flare_location_hpc) eq 2 and n_elements(aux_fits_file) eq 0 then aux_fits_file = stx_get_ephemeris_file( time_range[0], time_range[1]) - - if n_elements(flare_location_stx) eq 0 then flare_location_stx = stx_location4spectroscopy( flare_location_hpc = flare_location_hpc, aux_fits_file = aux_fits_file, time_range = time_range) - specpar.flare_xyoffset = flare_location_stx + + if n_elements(flare_location_stx) eq 0 then flare_location_stx = stx_location4spectroscopy( flare_location_hpc = flare_location_hpc, aux_fits_file = aux_fits_file, time_range = time_range) + specpar.flare_xyoffset = flare_location_stx ;if distance is not set use the average value from the fits header stx_get_header_corrections, fits_path_data, distance = header_distance @@ -163,12 +163,12 @@ 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,*] + 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) @@ -177,10 +177,10 @@ pro stx_convert_science_data2ospex, spectrogram = spectrogram, specpar = specpar spec_in_bk = reform(spec_in_bk,dim_counts_bk[0], n_times) - spec_in_bk = spec_in_bk[energy_bins,*] + 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) + 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]) @@ -192,10 +192,10 @@ 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,*] + error_bk = error_bk[energy_bins,*] if keyword_set(elut_correction) then begin - error_bk = error_bk * reproduce(eff_ewidth, n_times) + error_bk = error_bk * reproduce(eff_ewidth, n_times) endif error_bk = reform(error_bk,[n_elements(energy_bins), n_times]) From 6e30fd14b8225e30fedb1a0c6f961f725ffa2893 Mon Sep 17 00:00:00 2001 From: Ewan Dickson <35922612+grazwegian@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:45:35 +0200 Subject: [PATCH 3/3] First commit of scripts to split grid factor into opaque and transparent components. --- stix/idl/io/stx_fits_info_params.pro | 3 ++- .../processing/drm/stx_build_pixel_drm.pro | 9 ++++--- .../stx_fsw_sd_spectrogram2ospex.pro | 18 +++++++++---- .../spectrogram/stx_write_ospex_fits.pro | 26 +++++++++---------- .../subcollimator/stx_grid_transmission.pro | 18 +++++-------- 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/stix/idl/io/stx_fits_info_params.pro b/stix/idl/io/stx_fits_info_params.pro index 303c242d..b4aa936b 100644 --- a/stix/idl/io/stx_fits_info_params.pro +++ b/stix/idl/io/stx_fits_info_params.pro @@ -82,6 +82,7 @@ function stx_fits_info_params, fits_path_data = fits_path_data, data_level = dat default, elut_file, '' default, fits_background_file, '' default, detused, '' + default, grid_factor, '' ;if distance is not set use the average value from the fits header stx_get_header_corrections, fits_path_data, distance = header_distance @@ -107,7 +108,7 @@ function stx_fits_info_params, fits_path_data = fits_path_data, data_level = dat stx_fits_info = {uid:uid, fits_data_file:fits_data_file, data_level:data_level, $ - distance:distance, time_shift:time_shift, grid_factor:list(), $ + distance:distance, time_shift:time_shift, grid_factor:grid_factor, $ background_subtracted:background_subtracted, fits_background_file:fits_background_file, $ generate_fits:generate_fits, specfile:specfile, srmfile:srmfile, elut_file:elut_file, detused:detused} diff --git a/stix/idl/processing/drm/stx_build_pixel_drm.pro b/stix/idl/processing/drm/stx_build_pixel_drm.pro index e5b47c90..9795dfa7 100755 --- a/stix/idl/processing/drm/stx_build_pixel_drm.pro +++ b/stix/idl/processing/drm/stx_build_pixel_drm.pro @@ -55,7 +55,8 @@ ; ; ;- -function stx_build_pixel_drm, ct_energy_edges, pixel_mask, ph_energy_edges = ph_energy_edges,rcr = rcr, grid_factor= grid_factor,dist_factor= dist_factor, _extra = _extra +function stx_build_pixel_drm, ct_energy_edges, pixel_mask, ph_energy_edges = ph_energy_edges, rcr = rcr, $ + grid_factor = grid_factor, grid_transparency_correction = grid_transparency_correction, dist_factor = dist_factor, _extra = _extra default, pixel_mask , intarr(12,32) + 1 ; default pixel mask is all pixels from all detectors default, grid_factor, 1./4. @@ -93,16 +94,16 @@ function stx_build_pixel_drm, ct_energy_edges, pixel_mask, ph_energy_edges = ph_ scale_factor = total_area/drm.area ;scale the relevant parameters - drm.area *= scale_factor*rcr_factor*dist_factor + drm.area *= scale_factor*rcr_factor*dist_factor*grid_factor det_mask = total(pixel_mask,1) <1 smatrix = drm.smatrix transmission = stx_transmission(drm.emean, det_mask, attenuator = attenuator) dim_drm = size(/dim, smatrix) > 1 -if n_elements(grid_factor) eq n_elements(ph_in) then grid_factor=10^(interpol(alog10(grid_factor),alog10(ph_in),alog10(drm.emean))) + if n_elements(grid_transparency_correction) eq n_elements(ph_in) then grid_transparency_correction=10^(interpol(alog10(grid_transparency_correction),alog10(ph_in),alog10(drm.emean))) - transmission = transmission*grid_factor + transmission = transmission*grid_transparency_correction smatrix = smatrix * rebin( transpose(transmission), dim_drm) diff --git a/stix/idl/processing/spectrogram/stx_fsw_sd_spectrogram2ospex.pro b/stix/idl/processing/spectrogram/stx_fsw_sd_spectrogram2ospex.pro index 2ef0eb7e..ead03097 100755 --- a/stix/idl/processing/spectrogram/stx_fsw_sd_spectrogram2ospex.pro +++ b/stix/idl/processing/spectrogram/stx_fsw_sd_spectrogram2ospex.pro @@ -76,22 +76,29 @@ function stx_fsw_sd_spectrogram2ospex, spectrogram, specpar = specpar, time_shif if (keyword_set(gtrans32) and n_elements(flare_location_stx) ne 0) then begin grid_factors_proc = stx_subc_transmission(flare_location_stx, ph_in, /flux, silent = silent) + grid_factors_opaque = stx_subc_transmission(flare_location_stx, ph_in, /flux, silent = silent, /simple_transm) nph = n_elements(ph_in) ngrids = n_elements(grids_used) - ;05-Oct-2022 - ECMD until fine grid tranmission is ready replace the ;grids not in TOP24 with the on-axis tabulated values idx_nontop24 = stx_label2det_ind('bkg+cfl+fine') grid_factors_proc[*,idx_nontop24] = transpose(rebin(grid_factors_file[idx_nontop24],n_elements(idx_nontop24),nph)) - grid_factor = average(reform(rebin(grid_factors_proc[*,grids_used], nph, ngrids), nph, ngrids),2) + grid_factor_transparent = average(reform(rebin(grid_factors_proc[*,grids_used], nph, ngrids), nph, ngrids),2) + + grid_factors_opaque[*,idx_nontop24] = transpose(rebin(grid_factors_file[idx_nontop24],n_elements(idx_nontop24),nph)) + grid_factor_opaque = average(reform(rebin(grid_factors_opaque[*,grids_used], nph, ngrids), nph, ngrids),2) + + grid_transparency_correction = f_div(grid_factor_transparent,grid_factor_opaque) + grid_factor = (grid_factor_opaque)[0] endif else begin print, 'Using nominal (on axis) grid transmission' grid_factor = average(grid_factors_file[grids_used]) specpar.flare_xyoffset = [0.,0.] + grid_transparency_correction = 1. endelse if max(grid_factor) eq 0 then begin @@ -101,6 +108,7 @@ function stx_fsw_sd_spectrogram2ospex, spectrogram, specpar = specpar, time_shif readcol, grid_transmission_file, bk_grid_factors, format = 'f', skip = 2, silent = silent grid_factor = average(bk_grid_factors[pixels_used]) + grid_transparency_correction = 1. endif else begin message, 'Warning: Grid Factor is 0 - transmission for CFL and BKG detectors is not implemented',/info @@ -109,7 +117,7 @@ function stx_fsw_sd_spectrogram2ospex, spectrogram, specpar = specpar, time_shif endif ;make the srm for the appropriate pixel mask and energy edges - srm = stx_build_pixel_drm(ct_edges, pixel_mask, ph_energy_edges = ph_edges, grid_factor = grid_factor, dist_factor = dist_factor,$ + srm = stx_build_pixel_drm(ct_edges, pixel_mask, ph_energy_edges = ph_edges, grid_factor = grid_factor, grid_transparency_correction = grid_transparency_correction, dist_factor = dist_factor,$ xspec = xspec, _extra = _extra) rcr_states = specpar.sp_atten_state.state @@ -122,7 +130,7 @@ function stx_fsw_sd_spectrogram2ospex, spectrogram, specpar = specpar, time_shif ;make the srm for the appropriate pixel mask and energy edges rcr = rcr_states[i] - srm = stx_build_pixel_drm(ct_edges, pixel_mask, rcr = rcr, ph_energy_edges = ph_edges, grid_factor = grid_factor,$ + srm = stx_build_pixel_drm(ct_edges, pixel_mask, rcr = rcr, ph_energy_edges = ph_edges, grid_factor = grid_factor, grid_transparency_correction = grid_transparency_correction, $ dist_factor = dist_factor, xspec = xspec, _extra = _extra) srm_atten[i].srm = srm.smatrix srm_atten[i].rcr = rcr @@ -150,7 +158,7 @@ function stx_fsw_sd_spectrogram2ospex, spectrogram, specpar = specpar, time_shif specfilename = fits_info_params.specfile srmfilename = fits_info_params.srmfile - fits_info_params.grid_factor.add, grid_factor + fits_info_params.grid_factor = grid_factor fits_info_params.detused = detector_label + ', Pixels: ' + pixel_label if keyword_set(xspec) then begin diff --git a/stix/idl/processing/spectrogram/stx_write_ospex_fits.pro b/stix/idl/processing/spectrogram/stx_write_ospex_fits.pro index af4182ff..21aa1a41 100755 --- a/stix/idl/processing/spectrogram/stx_write_ospex_fits.pro +++ b/stix/idl/processing/spectrogram/stx_write_ospex_fits.pro @@ -159,23 +159,23 @@ pro stx_write_ospex_fits, $ stx_gsw_version, version = version, /silent - fxaddpar, primary_header, 'PARENT', fits_info_params.fits_data_file, "Parent Observation Data File", before='AUTHOR' - fxaddpar, primary_header, 'DATA_LEVEL', stx_data_level2label(fits_info_params.data_level), "Observation Data Compression Level", before='AUTHOR' + fxaddpar, primary_header, 'PARENT', fits_info_params.fits_data_file, 'Parent Observation Data File', before='AUTHOR' + fxaddpar, primary_header, 'DATA_LEVEL', stx_data_level2label(fits_info_params.data_level), 'Observation Data Compression Level', before='AUTHOR' fxaddpar, primary_header, 'HISTORY', 'STIX GSW Version '+version[0]+ ' was used to process this data' - fxaddpar, specheader, 'REQUEST_ID', fits_info_params.uid, "Unique Request ID for the Observation", before='AUTHOR' - fxaddpar, specheader, 'SUN_DISTANCE', fits_info_params.distance, "Distance in AU to Sun", before='AUTHOR' - fxaddpar, specheader, 'GRID_FACTOR', ((fits_info_params.grid_factor.toarray())[0]), "Total Grid Transmission Factor", before='AUTHOR' - fxaddpar, specheader, 'ELUT_FILENAME', fits_info_params.elut_file, "Filename of ELUT", before='AUTHOR' - fxaddpar, specheader, 'DETUSED', fits_info_params.detused, "Label for detectors used", before='AUTHOR' - fxaddpar, specheader, 'DETNAM', fits_info_params.detused, "Label for detectors used", before='AUTHOR' + fxaddpar, specheader, 'REQUEST_ID', fits_info_params.uid, 'Unique Request ID for the Observation', before='AUTHOR' + fxaddpar, specheader, 'SUN_DISTANCE', fits_info_params.distance, 'Distance in AU to Sun', before='AUTHOR' + fxaddpar, specheader, 'GRID_FACTOR', fits_info_params.grid_factor, 'Total Opaque Grid Transmission Factor', before='AUTHOR' + fxaddpar, specheader, 'ELUT_FILENAME', fits_info_params.elut_file, 'Filename of ELUT', before='AUTHOR' + fxaddpar, specheader, 'DETUSED', fits_info_params.detused, 'Label for detectors used', before='AUTHOR' + fxaddpar, specheader, 'DETNAM', fits_info_params.detused, 'Label for detectors used', before='AUTHOR' fxaddpar, specheader, 'SUMFLAG', 1, "Detectors are summed", before='AUTHOR' - fxaddpar, srmheader, 'SUN_DISTANCE', fits_info_params.distance, "Distance in AU to Sun", before='AUTHOR' - fxaddpar, srmheader, 'GRID_FACTOR', ((fits_info_params.grid_factor.toarray())[0]), "Total Grid Transmission Factor used", before='AUTHOR' - fxaddpar, srmheader, 'DETUSED', fits_info_params.detused, "Label for detectors used", before='AUTHOR' - fxaddpar, srmheader, 'DETNAM', fits_info_params.detused, "Label for detectors used", before='AUTHOR' - fxaddpar, srmheader, 'SUMFLAG', 1, "Detectors are summed", before='AUTHOR' + fxaddpar, srmheader, 'SUN_DISTANCE', fits_info_params.distance, 'Distance in AU to Sun', before='AUTHOR' + fxaddpar, srmheader, 'GRID_FACTOR', fits_info_params.grid_factor, 'Total Opaque Grid Transmission Factor', before='AUTHOR' + fxaddpar, srmheader, 'DETUSED', fits_info_params.detused, 'Label for detectors used', before='AUTHOR' + fxaddpar, srmheader, 'DETNAM', fits_info_params.detused, 'Label for detectors used', before='AUTHOR' + fxaddpar, srmheader, 'SUMFLAG', 1, 'Detectors are summed', before='AUTHOR' ;make the spectrum file diff --git a/stix/idl/processing/subcollimator/stx_grid_transmission.pro b/stix/idl/processing/subcollimator/stx_grid_transmission.pro index 30d3ecf4..c367ae54 100644 --- a/stix/idl/processing/subcollimator/stx_grid_transmission.pro +++ b/stix/idl/processing/subcollimator/stx_grid_transmission.pro @@ -56,16 +56,16 @@ function stx_grid_transmission, x_flare, y_flare, grid_orient, grid_pitch, grid_ default, flux, 1 + ;; Distance of the flare on the axis perpendicular to the grid orientation + flare_dist = abs(x_flare * cos(grid_orient * !dtor) + y_flare * sin(grid_orient * !dtor)) + + ;; Internal shadowing + shadow_width = grid_thick * tan(flare_dist / 3600. * !dtor) + if ~keyword_set(simple_transm) then begin bridge_factor = 1.0 - f_div(bridge_width,bridge_pitch) - ;; Distance of the flare on the axis perpendicular to the grid orientation - flare_dist = abs(x_flare * cos(grid_orient * !dtor) + y_flare * sin(grid_orient * !dtor)) - - ;; Internal shadowing - shadow_width = grid_thick * tan(flare_dist / 3600. * !dtor) - nenergies = n_elements(linear_attenuation) slat_optical_depth = grid_thick * linear_attenuation @@ -91,12 +91,6 @@ function stx_grid_transmission, x_flare, y_flare, grid_orient, grid_pitch, grid_ return, transmission/2. endif else begin - - ;; Distance of the flare on the axis perpendicular to the grid orientation - flare_dist = abs(x_flare * cos(grid_orient * !dtor) + y_flare * sin(grid_orient * !dtor)) - - ;; Internal shadowing - shadow_width = grid_thick * tan(flare_dist / 3600. * !dtor) return, (grid_slit - shadow_width) / grid_pitch