Level 3 Procedure - ITA-Solar/solo-spice-ql GitHub Wiki
-
Level 3 FITS file creation procedure
- Public wikipage
- Overview of procedure
- Step 1: Preparing data cube
- Step 2: Find lines of interest
- Step 3: Generating fit components
- Step 4: Create an ANA structure
- Step 5: Fitting parameters to data (optional)
- Step 6: Calling XCFIT_BLOCK (optional)
- Step 7: Create FITS headers
- Step 8: Write FITS file
- Step 9: Move file to correct place
Table of contents generated with markdown-toc
This page gives a more detailed overview on how a SPICE level 3 FITS file is created.
I created a few wikipages about level 3 FITS files. They are all linked from this start page:
Description of a level 3 SPICE FITS file
The whole procedure of creating a level 3 file is in the function SPICE_DATA::create_l3_file. Here is a simplified snippet of the code:
spice_object->create_l3_file, window_index, approximated_slit=approximated_slit, no_fitting=no_fitting, no_widget=no_widget
for iwindow=0,N_ELEMENTS(window_index)-1 do begin
ana = self->mk_analysis(window_index[iwindow], no_masking=no_masking, approximated_slit=approximated_slit, $
position=position, velocity=velocity, /init_all_cubes, no_line_list=no_line_list, $
version=version_add, proc_find_line=proc_find_line)
if ~keyword_set(no_fitting) then begin
spice_cfit_block, analysis=ana, /quiet, /double, x_face=~keyword_set(no_widget), smart=1
endif
if ~keyword_set(no_widget) && ~keyword_set(no_xcfit_block) then begin
SPICE_XCFIT_BLOCK, ana=ana, origin=origin, scale=scale, phys_scale = [0,1,1], group_leader=group_leader
endif
ana2fits, ANA, FILEPATH_OUT=file, $
N_WINDOWS=N_ELEMENTS(window_index), WINNO=iwindow, $
DATA_ID=DATA_ID, TYPE_XDIM1='WAVE', $
EXT_DATA_PATH=filename_l2, $
IS_EXTENSION=IS_EXTENSION, LEVEL='L3', VERSION=number_version_l3, CREATOR=CREATOR, $
PROC_STEPS=PROC_STEPS, PROJ_KEYWORDS=PROJ_KEYWORDS, $
PROGENITOR_DATA=original_data, HEADER_INPUT_DATA=self->get_header(window_index[iwindow]), $
SAVE_XDIM1=SAVE_XDIM1, NO_SAVE_DATA=NO_SAVE_DATA, PRINT_HEADERS=PRINT_HEADERS, $
SAVE_NOT=SAVE_NOT, $
headers_results=headers_results, headers_data=headers_data
endfor
spice_ingest, file, destination=destination, file_moved=file_moved, files_found=files_found, /force
The first thing to do before creating level 3 files, is to prepare the data cube, so that cfit_block can read it. This mainly means transposing the data cube so that lambda is in the first dimension. SPICE_DATA::transform_data_for_ana does this transformation.
Finding lines of interest in the spectra can be done in two different ways. Either using a predefined line list or estimating lines by searching for peaks in the spectra.
The line list is defined in SPICE_LINE_LIST. The line list has been taken from
A. Fludra et al., A&A 656, A38 (2021)
https://doi.org/10.1051/0004-6361/202141221
Table 1, except where stated differently
However, this predefined line list is not recommended, and thus not the default method. Due to instrument temperature variations, the wavelength scale changes significantly during the Solar Orbiter orbit, and this variation is not accounted for in L2 files. The wavelength shift is so large that using the line list when fitting fails in many cases.
The second method, which is the default for now, is estimating peaks in the spectra and use those peaks as lines of interests. This estimation is done in the function SPICE_GT_PEAKS.
The function GENERATE_ADEF defines a gauss curve for each peak found in the previous step. The initial values for the parameters 'intensity' and 'width' are estimated. The function then returns a structure with the fit components as well as background component. Each fit component is created by the function SPICE_MK_COMP_POLY and MK_COMP_POLY, respectively.
We use the fit components and the transformed data cube to create an ANA(lysis) structure. This is done by the function MK_ANALYSIS.
-> Steps 1 to 4 are done in the function SPICE_DATA::mk_analysis.
The fitting process itself is done in the procedure SPICE_CFIT_BLOCK. This can take quite a long time, this step can therefore be skipped for debugging purposes.
The ANA structure is then used to call SPICE_XCFIT_BLOCK, where the user can inspect and edit the fit components. This step can be skipped.
The FITS headers are created in spice_ana2fitshdr
Most interesting is the first header, where all general information about the ANA and all fit components and parameters are stored as keywords.
Extension 0 - Results (Fit components and parameters)
All data cubes and their headers are then saved into a FITS file. At the end, there will be up to 6 extensions per window in the FITS file. In most cases there will be only 2 extensions, the results extension and the data extension, but the latter without the data, only the header and a link to an external extension which contains the level 2 data.
-> Steps 7 and 8 are done in the function ANA2FITS.
SPICE_INGEST is called to move the file into the $SPICE_DATA/user/level3 directory. The pipeline will save the file into the directory $SPICE_DATA/level3.