Telluric Removal ================ This section describes how to configure and run the telluric removal module in ``GUIBRUSHR``. The goal is to remove the Earth's atmospheric contamination from the HR spectra, isolating the planetary signal for subsequent cross-correlation and retrieval analyses. The procedure relies on a masking step followed by Principal Component Analysis (PCA; Pearson 1901, Hotelling 1933), which has become one of the standard techniques for telluric removal in HR exoplanet spectroscopy (de Kok et al. 2013, Brogi et al. 2012, Giacobbe et al. 2021). A detailed mathematical description of each step is provided in the reference paper; here, we focus on the practical setup within the graphical interface. Interface Overview ------------------ The telluric removal panel is shown in the figure below. The interface is organized into four horizontal rows of parameters, plus a bottom row with the execution button. We describe each group below. .. figure:: ../figures/tutorial/telluric_removal_gui.png :width: 100% :align: center Screenshot of the ``GUIBRUSHR`` telluric removal panel configured for the WASP-77Ab IGRINS dataset. General Settings (First Row) ---------------------------- The first row defines the observation context: * **Target**: select the target from the database (here, ``wasp77Ab``). * **Rad. Transf. Mode**: the radiative transfer mode. Select ``Emission`` for dayside observations, or ``Transmission`` for transit observations. * **HR Instrument**: the high-resolution spectrograph used (here, ``igrins``). * **Nights**: the list of available observing nights. Select the night to process; in this tutorial, the pre-eclipse observation ``20201214``. * **Night sin/syn**: if checked, the selected night is treated as a synthetic (simulated) observation rather than a real one. Telluric Method and Order Selection (Second Row) ------------------------------------------------- The second row controls which spectral orders to process and the telluric removal algorithm: * **Order Selection**: write the name of the pickle file containing the orders selection made before. In this case we provide the *full* file, containing all the IGRINS orders. * **Subtraction of the average spectrum**: when checked, the mean spectrum across all phases is subtracted from each individual spectrum before applying PCA. This optional normalization step can help remove quasi-stationary stellar features. For this tutorial, the checkbox is enabled. * **Tell rm method**: the algorithm used for telluric removal. The default and recommended option is ``PCA_Scikit_Learn``. Other methods may be available or implemented in future versions. * **Use last component selection**: if checked, the software reuses the number of PCA components determined from a previous run, rather than recomputing them. Leave unchecked for a fresh analysis. * **Save plot**: if checked, diagnostic plots for each order are saved to disk. Useful for inspection, but can be left unchecked to speed up the process. * **Smooth size**: the kernel size (in pixels) used for smoothing operations during the masking procedure. The default value of ``100`` is appropriate for most cases. Masking Parameters (Third Row) ------------------------------- The third row sets the thresholds for the three-step masking procedure that identifies and excludes spectral channels dominated by telluric absorption or low instrumental sensitivity before applying PCA: * **Mask night**: 0 means no masking, 1 means masking. The amount of 0/1 separated by commas depends on the number of nights selected. * **Threshold mean spectrum**: the normalized flux threshold below which spectral channels are considered to have insufficient instrumental sensitivity and are excluded. A value of ``0.3`` means that channels with less than 30% of the peak flux are masked. * **Cutoff telluric**: the continuum-normalized flux threshold used to identify channels with significant telluric or stellar absorption. A value of ``0.8`` excludes channels where the flux drops below 80% of the continuum level. * **Sigma Coefficient**: controls the phase-variability mask. Spectral channels whose standard deviation across orbital phases exceeds this factor times the median standard deviation are flagged as telluric-contaminated. A value of ``1.5`` is used here. * **Do not fit continuum**: if checked, the blaze function correction step (continuum fitting via skewed Gaussian) is skipped. Leave unchecked for standard echelle spectrograph data such as IGRINS. The combination of these three masks ensures that only spectral channels with adequate sensitivity and minimal contamination are retained for the PCA step. PCA Configuration (Fourth Row) ------------------------------- The fourth row configures the PCA decomposition itself: * **Fixed Component**: the number of PCA components to remove from each spectral order. These leading components capture the dominant telluric and stellar variability. A value of ``4`` is adopted for this tutorial. * **Tangent components method**: an alternative approach to determine the optimal number of components automatically for each order, based on a tangent-line criterion applied to the explained variance curve. When unchecked, the fixed number specified above is used uniformly across all orders. * **Tangent threshold**: the threshold parameter for the tangent method (only relevant if the tangent method is enabled). Default is ``0.1``. * **N. components substitute**: when the tangent method is active, if it fails to determine a valid number of components for a given order or the amount is smaller than this threshold, this fallback value is used instead. Default is ``4``. * **Standardize PCA**: if checked, the data matrix is standardized (zero mean and unit variance per feature) before PCA decomposition. Leave unchecked for standard usage. * **PCA mode**: selects the orientation of the PCA decomposition. The ``spatial`` mode (default) performs PCA along the spectral (wavelength) direction, treating each orbital phase as an observation. Running the Telluric Removal ----------------------------- Once all parameters are configured as described above, click the **TELLURIC REMOVAL** button to start the process. The software will iterate through all selected spectral orders, applying the masking procedure followed by PCA decomposition. Progress is reported in the terminal. Upon completion, the PCA reconstruction matrix and the cleaned spectra are stored as FITS files in the target folder structure for use in subsequent CCF and retrieval analyses. Finding the optimal combination of masking thresholds and number of PCA components may require some experimentation. Removing too few components leaves telluric residuals, while removing too many risks suppressing the planetary signal. Users are encouraged to inspect the diagnostic plots (by enabling **Save plot**) and iterate on the parameters if needed.