A.C.I.D -- An Improved LSD Technique for Accurate Line Profile Retrieval

Stellar activity and planetary effects induce radial velocity (RV) offsets and cause temporal distortions in the shape of the stellar line profile. Hence, accurately probing the stellar line profile offers a wealth of information on both the star itself and any orbiting planets. Typically, Cross-Correlation Functions (CCFs) are used as a proxy for the stellar line profile. The shape of CCFs, however, can be distorted by line blending and aliasing limiting the stellar and planetary physics that can be probed from them. Least-squares deconvolution (LSD) offers an alternative that directly fits the mean line profile of the spectrum to produce a high-precision profile. In this paper, we introduce our novel method ACID (Accurate Continuum fItting and Deconvolution) that builds on LSD techniques by simultaneously fitting the spectral continuum and line profile as well as performing LSD in effective optical depth. Tests on model data revealed ACID can accurately identify and correct the spectral continuum to retrieve an injected line profile. ACID was also applied to archival HARPS data obtained during the transit of HD189733b. The application of the Reloaded Rossiter-McLaughlin technique to both ACID profiles and HARPS CCFs shows ACID residual profiles improved the out-of-line RMS by over 5% compared to CCFs. Furthermore, ACID profiles are shown to exhibit a Voigt profile shape that better describes the expected profile shape of the stellar line profile. This improved representation shows that ACID better preserves the stellar and planetary physics encoded in the stellar line profile shape for slow rotating stars.


INTRODUCTION
Stellar line profiles offer a wealth of planetary and stellar information that can be obtained from spectroscopic data.For example, stellar radial velocities (RVs), measured from velocity shifts of stellar line profiles, are used in the detection of exoplanets and, when combined with photometric observations, to extract bulk planetary properties (e.g. de Leon et al. 2023;Jackson et al. 2023).
RV measurements can also be used to detect the anomalous radial velocity shifts that occur when a planet transits in front of a rotating star, known as the classical Rossiter-McLaughlin (RM) effect.This can probe the orbital alignment of an exoplanet system (Rossiter 1924;McLaughlin 1924) and allows us to differentiate between planetary migration models as more 'violent' migration mechanisms such as the Kozai-Lidov mechanism (Kozai 1962;Lidov 1962), third body interactions (Fabrycky & Tremaine 2007;Goldreich & Sari 2003) and planet-planet scattering are expected to produce systems with misaligned or inclined orbits.The classical RM effect has been routinely used for a range of different systems (e.g.Esposito et al. 2014;Grouffal et al. 2022) and hence improved our understanding of planetary formation and evolution.Precise RV measurements induced by planetary effects such as classical RM are generally limited to very stable instruments such as the High Accuracy Radial-velocity Planet Searcher (HARPS).Line-profile tomography measures the temporal change in the shape of line profile induced by the RM effect (Collier Cameron et al. 2010).As a planet transits in front of a star the planet ★ E-mail: ldolan05@qub.ac.uk casts a 'Doppler shadow', manifesting as an identifiable bump in the line profile.Modelling this bump throughout a transit allows the RM effect to be measured regardless of the stability of the instrument.In the case of stable instruments, this technique can better constrain planetary and stellar parameters as both the RV shift and distortion in the shape of the line profile can be measured.
As well as obtaining planetary parameters the stellar line profile can also contribute to our understanding of stellar activity.Cool starspots distort the line profile as the spot passes across the visible stellar surface.In this case, the cooler and therefore dimmer spot on the stellar surface manifests as a bump in the line profile, similar to that which occurs during a planet's transit (Vogt & Penrod 1983).Modelling this distortion can provide information on spot coverage on the star as well as the brightness and temperature of the spot (Vogt et al. 1997).Measuring the temporal evolution of the bump provides an estimate for the stellar rotational velocity and even the rate of differential rotation in the case of multiple spots that stretch across different stellar latitudes (Strassmeier & Bopp 1992;Oláh et al. 2003).Other manifestations of stellar magnetic activity, such as bright plage regions, also impact the line profiles and stellar activity can affect the width and asymmetry of different lines in different ways (Thompson et al. 2017).These activity-induced line profile shape variations currently pose a major challenge to the detection and characterisation of exoplanets, especially as the field progresses to detect Earth-analog planets.Indeed, incorrect treatment of stellar activity has led to false planetary detections and so it is vital to better understand stellar activity's role in the distortion of the line profile (and to be able to account for it) in the context of the discovery and characterisation of exoplanets (Rauer et al. 2014;Simpson et al. 2022).
Many of these astrophysical studies mentioned rely on detecting sub-m/s radial velocity variations and equivalently small changes to the stellar line profile shape.Hence, obtaining accurate and precise measurements of stellar line profiles and associated information is vital in correctly detecting and interpreting these subtle effects.To achieve this, often the information from many thousand line profiles must be combined to boost the effective signal-to-noise (S/N).The quality and accuracy of these methods will be highly dependent on the technique used.For example, Cross-Correlation Functions (CCFs) are commonly used as proxy stellar line profiles and to extract stellar line profile information.A CCF is generally constructed by cross-correlating a stellar spectrum with a model spectrum and thus measures the similarity between them.Alternatively, as with HARPS, the CCFs are constructed by cross-correlating with a line mask, outlining the wavelength regions containing the expected stellar lines (Perryman 2018).The final profile is equivalent to the sum of all the lines, taken directly from the spectrum and identified by the mask.In this case, overlapping or neighbouring lines are not accounted for and can introduce spurious effects visible in the continuum of the CCF and impact the shape of the CCF itself.Furthermore, when cross-correlating with a model, the associated uncertainties may be inaccurate as they are not fully propagated through the CCF analysis itself.For HARPS CCFs constructed using DRS (Data Reduction Software) pipeline 3.5 uncertainties are not provided.Uncertainties are therefore estimated from the standard deviation of the flux in the continuum of the CCFs and hence do not arise directly from the data.This is not the case for subsequent DRS releases, which do provide uncertainties propagated from the data.
Least-squares deconvolution (LSD) offers an alternative technique that deconvolves the entire spectrum to produce a single meanweighted line profile representative of the stellar line profile.LSD directly fits the spectrum and hence produces realistic profiles and profile errors (Donati et al. 1997).This direct-fit also minimises the contribution of neighbouring and overlapping lines to the final LSD profile.
In this paper, we introduce ACID (Accurate Continuum fItting and Deconvolution)1 , a novel technique combining LSD and Markov-Chain Monte-Carlo (MCMC) methods to extract high precision stellar line profiles from high-resolution spectra.The LSD technique and the issues associated with it are introduced in Section 2. In Section 3, we outline the main improvements ACID has over traditional LSD.The implementation of ACID and a demonstration of its capabilities on simulated data are also presented in Section 3. In Section 4, ACID is used to extract high-precision line profiles from HARPS data for the planet HD189733 and reproduce the Reloaded RM analysis done by Cegla et al. (2016).Our conclusions are presented in Section 5.

LEAST-SQUARES DECONVOLUTION (LSD)
Least-squares deconvolution (LSD) was first introduced by Donati et al. (1997) to extract high S/N 'mean' line profiles from high resolution échelle spectra.Since then it has been successfully used to investigate stellar magnetic fields (e.g.Marsden et al. 2014;Ramírez Vélez 2020;Rainer et al. 2016;Shahbaz & Watson 2007) as well as extract high resolution RV measurements (e.g.Barnes et al. 2012;Lienhard et al. 2022).
A stellar spectrum can be modelled by the convolution of a line list, containing the central wavelength and relative absorption depth of each unbroadened spectral line for the normalised spectrum, and a line profile.LSD essentially reverses this process by deconvolving a stellar spectrum, using a given line list, and using the least-squares statistic to obtain a best-fit stellar line profile for that spectrum.In this process the assumption is made that all stellar lines can be modelled by one 'mean' line profile and for each line, the 'mean' profile is scaled depending on the relative strength of the absorption lines.For the case of overlapping lines, LSD assumes their relative strengths add linearly and deconvolves the overlapping lines accordingly (Kochukhov et al. 2010).The LSD technique and its underlying assumptions are summarised in the following sections.

LSD Technique
In this section we outline the LSD technique as outlined in Collier Cameron (2001) based on the technique introduced by Donati et al. (1997).LSD requires the input of a stellar line list that contains the wavelengths and predicted stellar line depths for a specific wavelength range.These can be obtained from Vienna Atomic Line Database (VALD) (Pakhomov et al. 2019;Ryabchikova et al. 2015;Kupka et al. 2000Kupka et al. , 1999;;Ryabchikova et al. 1997).
A major advantage of LSD is that it takes into account how individual absorption lines blend together to form a feature in the spectrum.Consider a spectrum where  represents the spectral pixel position, and a line list containing lines at wavelengths,   .For a given spectral wavelength,   , a contribution is calculated for each absorption line in the line list.This contribution is dependent on the depth of the absorption line,   , and the weight given to that absorption line for a given wavelength pixel in the spectrum, Δ.A triangular interpolation function is used to spread the weighting of a line over two pixels if the wavelength of the line,   , does not exactly match the central wavelength of a pixel,   .This weight, Δ, can be defined such that: where   represents the velocity pixel in the LSD profile and Δ, is the velocity pixel size.This weight is convolved with the tabulated line depth,   , to calculate the final contribution of the absorption line at position , to the wavelength pixel at position , and is stored in the matrix    such that: The matrix    is therefore independent of spectral flux under the assumption that the spectral continuum has been removed and the observed spectrum is therefore normalised.In this case,    depends only on the spectral wavelengths and predicted stellar lines.The deconvolved least-squares profile,   , can then be obtained from the normalised observed spectrum,   , by minimising: The solution for the least-squares profile and the uncertainties, , can be written in matrix form considering  as the diagonal matrix containing 1   and , the matrix containing (  − 1).Here, the superscript  denotes the transpose of a matrix.
It is important to note that the observed spectrum must be continuum normalised before LSD can be performed.This is because the line depths given in the line list are normalised, but it is also necessary to remove any structure present in the continuum that could affect the shape of the deconvolved line profile.This application of LSD relies on a number of assumptions that, if ignored, can affect how the resulting LSD profiles are interpreted.We now discuss some of the issues with the conventional application of LSD and outline how we can circumvent some of these.

Linear Addition of Overlapping Lines
A core assumption of traditional LSD is that the relative strength of overlapping lines adds linearly.As LSD is carried out in flux, this leads to the assumption that overlapping intensities add linearly and contribute to LSD's potential to greatly overestimate the depth of stellar lines, specifically in the case of strong blends, i.e. very deep lines or regions with many overlapping lines.This is acknowledged in Donati et al. (1997) and they state that they ensure that the sum of normalised depths never exceeds 1.However, they do not provide any further detail or outline reproducible steps on how this can be done using traditional LSD.Furthermore, this effect comes from an underlying assumption in traditional LSD that affects how LSD treats overlapping lines.Therefore, arbitrarily correcting the line depths to avoid this scenario would still result in discrepancies between the LSD forward model and observed data.Fig. 1 shows examples of model spectra based on LSD profiles derived by either performing LSD in flux or in effective optical depth.In this case, LSD was applied to sample data (outlined further in Sections 3.1.1and 4) and the resulting profile was used to create a normalised forward model spectrum,   , via: The    used is constructed using a line list extracted from VALD using the 'extract stellar' query with a detection threshold, microturbulence, effective temperature and log  * of 0.001, 1 km s −1 , 5022 K (Casagrande et al. 2011) and4.56 (Boyajian et al. 2015), respectively.These parameters were chosen to best match the parameters of HD189733 (which we later used to test our method in Section 4).VALD returns a line list with the closest input parameters for effective temperature,     and log  * to those provided.In this case, a line list for     = 5000 K and log  * = 4.5 was returned.It can be seen that when LSD is performed in flux the depths of deep absorption features are generally overestimated.For example, the strong blend at ∼ 5475.4Å leads to a prediction of a much deeper feature with a nonphysical normalised depth of ∼ 2.5.
This issue with the traditional approach to LSD was investigated in detail by Kochukhov et al. (2010).In the case of blending two identical Fe I lines together it was found that as the profile depth of the lines increased so did the discrepancy between the linearly added profiles.They concluded that the assumptions of line profile self-similarity and the linear addition of blends break down for lines deeper than 20% of the continuum intensity.Kochukhov et al. (2010) attempted to remedy this by invoking a multi-line LSD technique.This assumes that the stellar spectrum consists of  different mean line profiles and hence can assign different profiles (and profile depths) to weak and strong lines.This promises to address the issue of over-estimated line depths (Kochukhov et al. 2010).However, the S/N of a resulting LSD profile is dependent on the number of lines used to construct that profile and hence producing separate profiles for shallow and deep lines would therefore spread the S/N gain across the profiles.An alternative method is therefore preferable that can resolve this issue while maximising the S/N when applied to observational data.

Stellar Continuum Correction
Another assumption of LSD is that the spectrum must be normalised before LSD is applied.This therefore assumes that the stellar continuum has been fully removed with the consequence that an inaccurate continuum correction can cause distortions in the resulting LSD profiles.Typically, the continuum is found and corrected by fitting the top of the observed spectrum, i.e. the pseudo continuum, and dividing the spectrum by this fit.This technique, however, can be very sensitive to noise as well as spectral regions containing a high density of weak absorption lines.High noise levels can, for example, effectively raise the pseudo-continuum as the top of the noise is fit, which lies above the real continuum level.In the case of regions containing a high density of absorption lines, this results in very little to no wavelength range free of absorption features.Within this range, the overlapping lines blend together and act to lower the pseudo-continuum.This lowering/raising of the pseudo-continuum can therefore result in contamination from the continuum remaining in the spectrum.
Simulated data was used to investigate the extent of an inaccurate continuum correction on the resulting LSD profile.A model normalised spectrum was created through the convolution of a line list with an injected profile.The model spectrum was constructed on a wavelength grid of pixel size 0.01 Å across a wavelength range equivalent to a single order in a HARPS spectrum (4575-4626 Å).The stellar line list used was the same as outlined in Section 2.2.1.A Gaussian of normalised depth of 0.4 and a FWHM ∼ 6.6 km s −1 was used as the injected profile.The forward model from the injected profile and line data was multiplied by a third-order polynomial to act as the model continuum.The exact polynomial used here is irrelevant as it serves to demonstrate how residual continuum left in a spectrum can impact the resultant LSD profiles.LSD was performed on the continuum-corrected model data and the resulting profiles were compared to the injected profile.The same line list was used in the creation of the model data as was used for the application of LSD ensuring that any effect observed is solely from the continuum correction applied.The model data was continuum corrected by dividing the spectrum by a selected continuum fit.
Fig. 2 shows the results for the case where the continuum of the normalised profile is vertically offset by 0.1, for a positive and negative case.Our results show that when the correct continuum is used, i.e.LSD is applied to a perfectly normalised spectrum, a noiseless profile is returned that matches the injected profile.This is expected as LSD is the exact reversal of the convolution used to create the model data.However, correcting with a slightly offset continuum fit was found to change the depth and shape of the resulting profile as well as induce spurious noise that is visible in the profile's con- tinuum.As mentioned, the normalised depth of the injected profile was set to 0.4.When the true continuum correction was used the normalised profile depth was retrieved to within 1 × 10 −10 accuracy and the resulting profile contained very little noise with an out-ofline RMS of 0.0001 in normalised flux.In the case of a continuum correction exhibiting a ±0.1 offset from the true continuum position, the normalised profile depths are seen to change with the measured depths being 0.392 ± 0.002 and 0.408 ± 0.002 for a positive and negative offset, respectively.These depths were measured by a Gaussian fit to the final profiles where the uncertainties given account for the effect of the increased noise in these profiles.The out-of-line RMS also increases for a positive and negative offset to 0.004 and 0.005, respectively.No noise was added to the model data and so an incorrect continuum correction can be seen to increase the out-of-line RMS by a factor of 40-50 times that seen from a correct continuum correction.This highlights how important a correct continuum fit is to the reliability of the final LSD profile.

ACID
Our novel technique: ACID aims to remedy these issues and returns accurate line profiles from high-resolution spectra.ACID builds on current LSD techniques by performing LSD in effective optical depth (outlined in Section 3.1.1)and simultaneously fitting the continuum and the mean line profile of each spectrum (outlined in Section 3.1.2).ACID requires the input of the spectral data (including wavelength, flux, errors and average S/N of each spectrum) as well as a theoretical line list.Currently, ACID accepts line lists in the short-and longform format provided by VALD.VALD provides a spectral line list based on the stellar parameters given by the user such as the stellar temperature, log , microturbulence velocity, chemical composition (including metallicity), the minimum detection threshold (i.e.minimum line depth of lines included in the line list) and a specified wavelength range.

LSD in Effective Optical Depth
ACID addresses the overestimation of the depths of overlapping lines that have been previously shown with traditional LSD.This issue arises from working in flux as the assumption that overlapping lines add linearly breaks down when dealing with overlapping intensities for deep or very dense regions of absorption lines.ACID solves this problem by working in effective optical depth where the assumption of linear addition still holds.For this reason, all LSD processes in ACID, including convolution, are performed in effective optical depth, .This can be calculated for a spectral wavelength pixel, , from the normalised flux,   by: The positive line depths in flux,   (), as provided from VALD, must also be converted into effective optical depth such that: After these conversions, LSD can be applied with the same steps described in Section 2.1 to produce a mean line profile, , in effective optical depth.The resulting profiles and any forward models used are also converted back into flux to produce the final ACID profiles and for comparisons to the observed spectrum.
To test this process, LSD was performed in both flux and effective optical depth on an example spectrum from observations of HD189733 covering a wavelength range of 5431.7 − 5494.1 Å (further details on data given in Section 4.1) and the resulting forward model spectra were compared.The stellar line list used was the same as outlined in Section 2.2.1 with the minimum detection threshold set to 0.001 in normalised flux depth.The same line list and hence number of lines were used for both LSD applied in flux and effective optical depth, amounting to 2310 lines over the wavelength range considered.The forward models produced indicate a better fit to the data when LSD is performed in effective optical depth as significantly fewer overestimated lines are present.Fig. 1 shows an example of a small wavelength range so that the behaviour of individual lines can be observed.It can be seen for the strong blend located at ∼ 5477 Å, which produces a non-physical depth of ∼ 2.5 when LSD is applied in flux, has a depth in better agreement with the data when LSD is performed in effective optical depth.
We have demonstrated that performing LSD in effective optical depth produces more realistic line depths in the case where there are overlapping lines.However, we acknowledge that other types of line blending that were correctly treated in traditional LSD, such as that induced from rotational broadening, will not be treated correctly under this approach.In this work we are interested in slow rotating stars where this approximation holds, however, in the case of rapid rotating stars where rotational broadening would dominate this approximation would break down and this approach would no longer be applicable.
It can also be noticed that, despite better agreement with strongly blended lines when LSD is performed in effective optical depth, there are still discrepancies in the line depths present in the data compared to the forward model.These discrepancies could arise from either inaccuracies in the stellar line list used to construct the    matrix or from the remaining assumptions in the LSD model.To further investigate this we applied a similar test to a detailed synthetic spectrum constructed using PySME (Wehrhahn et al. 2023;Valenti & Piskunov 1996;Piskunov & Valenti 2017).PySME produces realistic stellar spectra using radiative transfer calculations from input stellar parameters and a VALD stellar line list.The synthetic spectrum was constructed on the wavelength grid of the HARPS order covering the wavelength region 4506.8− 4558.4Å .This region was chosen as it was seen to contain an obvious discrepancy at ∼ 4552Å between the LSD forward model and the observed data.As before, we used VALD to obtain a line list based on the stellar properties that are closest to those of HD189733, although it should be noted that PySME only takes the line positions from this and not the line depths.To keep the stellar inputs consistent with those used to construct the line list the microturbulence, effective temperature and log  * were set to 1 km s −1 , 5000 K and 4.5, respectively.The macroturbulence and  sin  * were set to 2 km s −1 and 3.3 km s −1 , respectively, and the MARCS stellar models were used (Gustafsson et al. 2008) for the stated parameters.LSD was then performed on this synthetic spectrum in both effective optical depth and flux and the respective forward models can be seen in Fig. 3.
It can be seen that, compared to LSD performed in flux, LSD in effective optical depth produces a better fit to the synthetic spectrum.While the greatest improvement is seen in the case of very deep absorption lines we also note that for the case of shallower absorption lines LSD in effective optical depth still produces smaller residuals than traditional LSD.This further proves that LSD in effective optical depth outperforms traditional LSD for slow-rotating stars.As was observed with the application to observational data, discrepancies can be seen between the LSD forward model and the synthetic spectrum.It can also be seen that the depths of many of the absorption features produced from the synthetic spectrum do not match those seen in the observational data (Fig. 3), with larger discrepancies being observed between the synthetic spectrum and observational data than is seen between the observational data and the LSD forward models, despite the same stellar parameters being used.SME does not take an estimate for the line depths from the provided VALD line list but instead takes the line positions from the provided line list.The relative line Figure 3. PySME was used to construct a synthetic spectrum (plotted in the top panel).LSD was then performed on this synthetic spectrum in both flux and effective optical depth.The two forward models for LSD performed in flux and effective optical depth are also plotted.For reference, the observational data (from Figure 1) is plotted in the top panel as well as the line depths provided by VALD that was used for the application of LSD.We highlight the lines located at ∼ 4537 Å and ∼ 4551 Å visible in the observational data that are not predicted in either the LSD models or synthetic spectrum.
depths are then calculated from these along with the input stellar parameters using the radiative transfer equations.For this reason, we cannot state if the discrepancies observed between the synthetic spectrum and both LSD forward models arise from inaccurate line depths in the VALD line list or differences in the radiative transfer and LSD models.We can, however, observe that there are clear inaccuracies in the line data that appear in both the LSD forward models and the synthetic model from PySME.Examples include the lines located at ∼ 4537 Å and ∼ 4551 Å visible in the observational data that are not predicted in either the LSD models or synthetic spectrum (Fig. 3).While this shows evidence that inaccurate line data is contributing to the discrepancies between the observational data and the LSD forward models we cannot confidently state that this is the sole contributor as it could be a combination of this and the underlying assumptions in LSD.Despite this, we have shown that ACID does improve on traditional LSD for both the application to observational data and a synthetic spectrum by performing LSD in effective optical depth.

Simultaneous Continuum Fit
As well as working in effective optical depth ACID also improves upon traditional LSD by simultaneously fitting the line profile and the stellar continuum.Section 2.2.2 highlighted that an incorrect continuum correction directly affects the shape of the profile that LSD produces and results in additional noise.The simultaneous fit of the continuum and LSD profile provides a better constraint on the continuum as the noise in the stellar line profile will be minimised when the continuum fit has converged correctly.This simultaneous fit works by comparing the forward model directly to the data.For a given profile, , a model spectrum (including the continuum),   , can be constructed by the multiplication of the forward model spectrum,   , and the model continuum fit (modelled by an   ℎ order polynomial) such that: where  is a scaling factor and   are the polynomial coefficients describing the shape of the continuum.Since ACID performs LSD in effective optical depth, the forward model spectrum is first converted from effective optical depth into flux before the continuum fit is added.The resulting model spectrum can then be directly fit to the data to obtain both a best-fit line profile and continuum fit.This is done using MCMC methods and will be further discussed in the following sections.

Combining Spectral Frames
The spectral continua, including any telluric and systematic effects, are expected to be consistent over an observation night.This allows a master continuum fit to be applied to a high S/N combined spectrum.ACID fits the continuum for all frames on an order-by-order basis, applying the same correction to each individual frame.The frames are first adjusted to sit on the same continuum level by dividing each spectral frame by a reference frame (taken as the highest S/N frame for that observation night).A 4 th -order polynomial is fit to this ratio, after removing outliers, and used to adjust each spectrum.These adjusted spectra are retained and will be corrected by the final continuum fit for a given order (outlined later in this section).
A combined spectrum is constructed using a weighted mean of the adjusted frames with weights that are calculated based on the average S/N of each spectrum.A S/N for the combined spectrum is also calculated using a weighted mean.Not only does fitting the continuum to a combined spectrum obtain a more accurate fit due to the higher S/N but it also maintains consistency between the frames and ensures that the profile depth remains consistent.If only one spectral frame was available for each observation night, i.e. for the case where there are many singular observations scattered over different observation nights, then the continuum fit would still need to be applied on a night-by-night basis.The combined spectrum is then taken as the single frame for the night.The following steps are applied in the same way with only a single LSD profile being produced.

Masking
It is necessary to exclude regions of the stellar spectrum that could affect the mean stellar line profile such as those affected by strong telluric contamination and very wide absorption lines that diverge from the shape of the majority of stellar lines.To remedy this, three stages of masking are performed on the combined spectrum.Masking is kept consistent between the frames for a given observation night to ensure any frame-dependent line profile distortion is from an astrophysical source.In the first two masking stages problematic areas are identified by calculating residuals between the combined spectrum and a forward model spectrum constructed from the initial continuum fit and LSD line profile.An initial continuum fit is found using a window function that isolates the pseudo-continuum of the spectrum by fitting a polynomial using a window function.The window function isolates the maximum flux in 100-pixel bins, which acts as the pseudo-continuum.The bin size can be adjusted by the user, however, the default size of 100 pixels was seen to cover multiple lines in the spectra for HD189733.This ensured that the maximum flux value came from a pseudo-continuum value instead of the central part of an absorption feature.The polynomial is then fit to this pseudo-continuum.LSD is then performed on the initial continuum corrected spectrum and the returned profile is taken as the initial profile.
The first masking stage removes regions affected by strong telluric contamination and known broad lines that are expected to deviate from the average line shape.Although many of these lines will be masked as a result of additional steps outlined later, as an extra precaution wavelength regions known to contain these lines are manually masked out first to ensure they do not affect the final profiles.By default, the regions covering 6280 − 6350 Å and 6800 − 7900 Å are masked as these include strong telluric regions such as the oxygen A and B bands.The user can then specify other wide lines to be masked such as the Balmer lines, Calcium H and K lines and Sodium doublet.In the case of user-specified lines ∼ 3.5 Å is masked out on either side of the line.
In the second stage, broad absorption lines that diverge from the average profile shape are removed.In this stage, areas with more than 20 consecutive pixels in which the spectrum and forward model deviate by more than 25% of the spectral flux value are masked.This removes large regions that deviate from the forward model and absorption features that could affect the mean line profile including very wide absorption lines (such as the Balmer lines, Ca H and K lines and the Na doublet) and extremely dense regions of lines.
The third stage of masking is applied to remove individual lines that vary greatly from the predicted depths.This is done by masking pixels where the residuals between the spectrum and the forward model deviate more than  from the median of the residuals, where  denotes the standard deviation and n is an integer number ( = 1 being the default).This step is necessary as discrepancies in line depths can affect the continuum fit when using the MCMC method.For example, if many lines were deeper in the data compared to what is predicted by the line list then this will act to artificially pull the continuum fit down to compensate.This stage of masking is only applied during the MCMC continuum fit to the combined spectrum and is removed before the final run of LSD (Section 3.2.4) to obtain the final ACID profiles.At all stages, the number of consecutive pixels, residual deviation percentage,  cut-off and telluric regions can be tailored by the user.

MCMC Approach for Continuum Fitting
After masking has been applied the combined spectrum is used to find the continuum fit using an MCMC approach.The python package emcee (Foreman-Mackey et al. 2013) is used to simultaneously fit the mean line profile, continuum scaling factor and polynomial coefficients by comparing the model spectrum (equation 9) directly to the combined observed spectrum.The continuum scaling factor, polynomial coefficients and every single point in the mean (LSD) line profile are set as free parameters.This ensures that the depth, shape and continuum level of the mean line profile are not biased in any way.
Throughout this work, a 3 rd -order polynomial was used for the continuum fit as this allowed the continuum to be well constrained for our data sets without the added computation time associated with higher orders.The order of polynomial to be applied can also be adjusted by the user.The initial continuum coefficients (continuum scaling factor and polynomial coefficients) are taken from a fit performed using a window function that takes the maximum point from every unmasked 10 pixels from the combined spectrum.The input profile comes from an initial run of LSD on the continuum-corrected spectrum (corrected using the input continuum coefficients).The resulting    matrix (containing the line data) from this is saved as a global array.This saves computation time as the    matrix does not need to be recalculated during each iteration of the MCMC fit.
In general, the minimum detection threshold applied to the line list (i.e. the minimum depth of absorption line that would be considered) was also found to affect the continuum fit of the spectrum.Specifically, for the case when the minimum detection threshold is set higher than the noise level present in the spectrum the resulting continuum fit is higher than expected resulting in a downward offset in the resulting LSD profile.This occurs as very small absorption lines that are detectable (i.e. have a line depth deeper than the noise level) in the data are removed from the line list and treated as part of the continuum.The obvious way to remedy this is to set the minimum detection threshold to 0, thereby not excluding any lines.This, however, is very computationally intensive and can introduce noise as many undetectable lines are contributing to the final profile.To remedy this a balance must be struck between including necessary lines and removing those that only add to the computational load.In ACID, the minimum detection threshold is based on the average S/N of the spectrum such that our detection threshold is equal to 1 3(/ ) .This ensures that all detectable lines are included in the line list while still minimising the computational load.VALD generally provides the stellar line depth to 3 significant figures which, in the case of high-resolution spectra, would lead to the calculated detection threshold to be smaller than the accuracy provided by VALD.In this case, we are limited by the line list, which could lead to very weak lines being excluded.

Obtaining the Final Profiles
After the best-fit continuum has been found the individual frames that were adjusted to sit at the same continuum level are used to obtain the final mean line profiles.Each frame is continuum-corrected using the output polynomial from the MCMC fit.The mask outlined in Section 3.2.2 is interpolated onto the wavelength grid for the given frame.LSD is performed on each masked and continuum-corrected spectrum to retrieve the final profile and associated errors.This final run of LSD ensures the associated errors arise from the data and not the quality of fit from the MCMC.The errors from the continuum fit are propagated onto the continuum corrected spectrum so that the final LSD errors account for the uncertainty in the continuum fit also.ACID allows the user to input the velocity grid for the final profiles.In our analysis, the velocity grid was chosen so that the resulting profile was centred on the grid.In all cases, the velocity pixel size was calculated based on the average wavelength separation in the spectrum (∼0.82 km s −1 for HARPS).ACID repeats the steps listed above for each order so that a profile is obtained for each order and frame combination.
A combined profile and the associated errors were then calculated for each frame using a weighted mean of the subsequent order profiles.The final profile was interpolated onto a velocity grid consistent across all frames, again with a constant velocity pixel size equal to that of the original velocity grids.This allowed for profile comparisons to be easily made between frames.

Application to Model Data
ACID was applied to a model spectrum constructed via equation 9.The injected profile was modelled as a simple Gaussian with a normalised depth of 0.4 and FWHM ∼ 6.6 km s −1 ).The model continuum was described by a 3 rd -order polynomial.The    matrix was constructed using line data obtained from VALD using the same stellar line list outlined in Section 2.2.1.Synthetic noise was added using a Gaussian distribution with a standard deviation of 0.01.This produced a similar noise level to that seen in HARPS data for HD189733 -outlined in Section 4.1.The error on the model spectrum was set to 0.01 for all pixels.
A comparison of the model spectrum and the best fit model from emcee can be seen in Fig. 4. ACID retrieves the 'true' continuum fit with the forward model of the continuum fit and profile providing good agreement with the spectrum.This results in the retrieval of the injected profile within the induced noise levels (shown in Fig. 5), demonstrating ACID's ability to find and correct the true continuum of the spectrum and return the true line profile to a high precision.

Data
This work used the observational data of HD189733 from the HARPS échelle spectrograph on the ESO 3.6 m telescope in La Silla, Chile.Four observation nights, obtained during the transit of HD189733b, were used: 2006 July 29/30, 2006 September 7/8, 2007 July 19/20 and 2007 August 28/29.These particular data sets have been studied extensively in the literature (Triaud et al. 2009;Collier Cameron et al. 2010;Wyttenbach et al. 2015;and Cegla et al. 2016).Full transits of HD189733b are covered in all of the observation nights except for the night during July 2006.Here, only a partial transit is observed due to poor weather conditions.In total, there are 111 frames, taken both in and out of transit.
Throughout this work the HARPS e2ds spectra produced from the DRS pipeline version 3.5 were used.These are 2-dimensional échelle order spectra.Before spectra were provided to ACID they were blaze corrected using the blaze files identified from the FITS header of the provided e2ds file.The spectra were also corrected to remove the Barycentric Earth Radial Velocity (BERV) from each frame using the BERV correction provided in the FITS header of the e2ds file.ACID is also compatible with the 1-dimensional combined spectra (s1d) from the DRS pipeline version 3.5 although, due to the oversampling of this onto a finer wavelength grid and the merging of the orders into one spectrum, we opted to use the e2ds spectra throughout.For the case of s1d spectra, ACID splits each spectral frame into smaller wavelength ranges corresponding to those of the e2ds orders.To avoid overlap regions being processed twice, the overlap region occurring at longer wavelengths is discarded for each wavelength range.ACID then applies the same method outlined for the e2ds spectra where these wavelength ranges act as the orders in the e2ds case.As the continuum is then fit to these smaller wavelength ranges, we avoid the need for high-order polynomials or a more complicated continuum model to describe the continuum of the entire s1d spectrum.
For comparison to the resulting ACID profiles, we use the corresponding CCFs provided from the HARPS pipeline.For these observations, the CCFs available on the archive are processed using different stellar masks for different nights.Namely, a K5 stellar mask was applied for observations taken in July and September 2006 and a G2 stellar mask was applied for July and August 2007.We requested for all 4 observation nights to be reprocessed using a K5 stellar mask which better matched the spectral type of HD189733 (K2).These reprocessed CCFs are used throughout this work.
For the observations taken on July 2007 a feature was observed in the resulting ACID profiles (further discussed in Appendix A).This was found to only appear in orders 40-42 and is not present for any other observation night nor in the corresponding CCF profiles.For this reason, orders 40-42 were excluded for July 2007 only.In the application of ACID to HD189733, we mask out lines at positions 3820.33, 3933.66, 3968.47, 4327.74, 4307.90, 4383.55, 4861.34, 5183.62, 5270.39, 5889.95, 5895.92Å,some of these regions being the Balmer lines, Calcium H and K lines and Sodium doublet lines.These are masked out in the first masking stage outlined in Section 3.2.2.

ACID Profiles
The application of ACID was done separately for each observation night to account for any night-to-night variations in the spectral continuum.The final ACID profiles and their comparative CCFs are presented for all frames and all observation nights in Fig. 6.The CCFs provided by HARPS are over-sampled by a factor of 4. This oversampling was present in DRS pipeline version 3.5 and was removed from subsequent pipelines due to associated issues such as red noise.We choose not to over-sample our ACID profiles to avoid masking the true S/N of the profiles and hence for easier comparison, every 4 th element in the CCFs has been plotted in Fig. 6.We also  adjusted the continua of the ACID profiles to match that of the CCFs by adding 1 to the profiles.
Error bars are included for the ACID profiles but are barely visible due to the small errors associated with the profiles.These errors are representative of the data as LSD carries out a direct fit to the data.Error bars are not included for CCFs as they are not provided by the HARPS pipeline used for these observations.As well as producing realistic and representative errors, ACID profiles are also seen to rival the signal-to-noise levels of the CCFs.
It may be noticed that the continuum of the ACID profiles generally sits lower than that of the CCFs.The explanation for this is two-fold.First, the continuum of the CCFs has been artificially improved by normalising the CCFs after their extraction from the spectrum.This normalisation is done by dividing the CCF by the mean continuum flux, hence the continuum would be brought to 1. Second, as mentioned in Section 2.1, very small absorption lines sitting below the noise level of the spectrum were excluded from the line list to save computational time.Despite these lines being undetectable, i.e. their profiles are entirely enveloped in the noise of the continuum, the collective effect of these lines can still cause the continuum of the profile to be suppressed.It is important to note that these lines (and their combined effect) lie in the noise of the spectral continuum and hence including them would not affect the continuum fit found by ACID.Consequently, although a similar offset is observed in the continuum of the profile this effect does not induce the same line distortions and increased noise levels associated with an incorrect continuum correction outlined in Section 2.2.2.
Furthermore, the CCFs and ACID profiles also exhibit distinctly different shapes, which we now discuss.Of particular note is the fact that the ACID profiles have depths that are considerably more consistent than those of the CCFs across all 4 observation nights.Indeed, the standard deviation of the normalised ACID profile depths was measured as 0.0003, while for the CCFs this was 0.0012 -four times greater.Variations in the profile depths can be caused by an incorrect continuum fit as this results in systematic errors in the resulting LSD profile continuum as well.The uniformity between the ACID profiles' continua and depths across all frames is supportive that ACID has correctly identified and removed the spectral continuum before LSD is applied.
The ACID profiles also exhibit broader wings that tail off gradually to form the profile's continuum.This is contrasted by the well-defined  transition between the profile and continuum that is seen for the CCFs.The shape of a stellar line profile is determined by the broadening effects that affect the light coming from the star.The absorption coefficient, a measure of how the stellar atmosphere absorbs light, is dominated by 3 main broadening processes: thermal, natural and pressure broadening.Thermal broadening arises from the movement of atoms due to their increased energy with higher temperatures and is expected to produce a Gaussian-shaped profile.Natural and pressure broadening are expected to produce a Lorentzian-shaped profile, possessing the characteristic broad wings as seen in the ACID profiles.In general, the absorption coefficient should therefore account for a combination of these broadening processes, this would result in a dispersion profile in the shape of the Voigt profile, which describes the convolution between a Lorentzian and Gaussian profile, possessing a Gaussian line core with Lorentzian wings.Although the absorption coefficient will influence the shape of the stellar line pro-file, other broadening effects such as rotational, macroturbulence and instrumental broadening also affect the observed line profile shape.Instrumental broadening occurs due to limitations in the resolution of the instrument and is usually approximated by a Gaussian.Rotational broadening occurs from the rotation of the star as the velocity along the line of sight varies for different surface regions.Macroturbulence broadening refers to the broadening that occurs from large-scale mass motions and the Doppler shifts they induce (Gray 2022).
In the case of optically thick lines, the line profile is expected to become broader and deeper as it originates from denser regions of the stellar atmosphere (Gray 2022) and since ACID works in effective optical depth this effect should be accounted for in the ACID profiles.HARPS CCFs are constructed using a weighted sum of the spectral lines using a binary mask.This means that, in the same way as the ACID profiles, the CCFs should be representative of all of these broadening effects previously mentioned.To investigate the shape of the HARPS CCFs compared to the ACID profiles model Lorentzian, Gaussian and Voigt profiles were fit to the average out-of-transit profile in each case.The best-fit model for the CCF and ACID profile can be seen in Fig. 7 as well as the average out-of-transit profile and CCF taken across all 4 observation nights.It can be seen that the ACID profiles are best fit by a Voigt model and the CCFs are best fit by a Gaussian model.The Voigt profile provides a better approximation to the expected shape of the line profile as it describes the shape of the line absorption coefficient.While the line absorption coefficient cannot be used as a direct comparison to the final shape of the line profile it would contribute to this.These combined suggest that ACID is producing more realistic line profiles than the CCFs.A possible explanation for this comes from how the CCFs are constructed.A HARPS CCF is constructed by cross-correlating the spectrum with a stellar mask.Lines that are not removed by the mask are then added together to form the final CCF.This process does not account for the blending of neighbouring lines and in the case of many shallow lines, these can blend together to form a pseudo continuum, sitting lower than the true continuum.This would also cause the wings of the deeper lines to be lost in this pseudo-continuum.This could explain the Gaussian shape of the CCF as it only represents the core of the line, rather than the entire profile.As ACID utilises LSD it accounts for the overlapping of neighbouring lines and is not subject to this effect, hence producing the Voigt shape seen for the ACID profiles.
Other stellar effects can also affect the profile shape.For example, granulation on the stellar surface, where rising (i.e.blue-shifted) regions of the star are hotter and so brighter than the down-flowing (red-shifted) cooler regions, produces an asymmetry in the stellar line profile.In this case, the blue side of the profile is brighter and the red side of the profile possesses a stronger 'tail' off to the continuum.The extent of this asymmetry is expected to vary between different stellar lines as they originate from different depth ranges in the stellar atmosphere and therefore sample different regions of the convective motions.We attempted to measure the asymmetry of the ACID profiles by fitting a skew-normal model (e.g Simola et al. 2019) that fits the line using a 'skewed' Gaussian profile and hence can quantify a line-profile's asymmetry.As can be seen in Fig. 7, the ACID profiles are not well described by a Gaussian model.Therefore, the addition of the skewness parameter in the 'skewed' Gaussian model prevented the model fit from converging and hence this test It should be noted, however, that the ACID profiles do exhibit some asymmetry in the errors produced.Fig. 8 shows the profile errors for all frames as a function of velocity.It can be seen that the errors increase in the centre of the profile as expected (due to the lower signal-to-noise in the line cores), but they also appear to be larger on the red wing of the profile relative to the blue wing.This asymmetry was not observed when ACID was applied to model data (which assumed symmetric line-profile shapes) and so is likely originating from the observed spectra.One possible explanation for this is that it arises from granulation, which will cause different lines to exhibit different levels of line-asymmetries (due to, for example, differences in line-depth formation), with the greatest line-by-line variation occurring in the red wing of the profile.This would lead to shape variations between lines that were predominantly larger in the red wings, hence leading to the larger uncertainties seen in this region of the ACID 'mean' line profiles.

RM Analysis
The resulting ACID profiles were used to measure the classical RM effect of HD189733b by measuring the RVs of the profiles.RVs were taken to be the mean of a Voigt and Gaussian fit to the ACID profiles and CCFs, respectively; these are shown in Fig. 9.The best-fit model was found using a least−squares Levenberg-Marquardt algorithm implemented by scipy's curvefit function.The errors on the mean are taken from the square root of the diagonal of the covariance matrix returned.The CCF errors were taken as the standard deviation in the CCF's continuum, while for the ACID profiles the corresponding profile errors were used.In both cases, areas of the  continuum that deviated from the model were excluded.For the CCFs this meant points lying outside of an absolute velocity of 5 km s −1 were excluded and for ACID profile points lying outside of an absolute velocity of 7 km s −1 were excluded.A circular orbit was assumed for HD189733b and hence the RV motion of the host star was found using the best-fit model of a phase-dependent sinusoid with semiamplitude, , plus a systemic radial velocity,  sys .This reflex motion was removed from the measured RVs.In general, the RVs measured from the ACID profiles (see Fig. 9) show a slightly increased scatter compared to those from the CCFs with an RMS of the out-of-transit RVs being 0.0015 km s −1 and 0.0011 km s −1 for the ACID profiles and CCFs, respectively.RV scatter can be induced in LSD profiles from a number of sources including unmasked telluric lines, overlapping neighbouring lines and insufficiencies in the model (e.g.missing or inaccurate lines in the line list).Most of these cases will have been accounted for in the masking stage of ACID, when known telluric regions and wavelength regions that greatly deviated from the model were removed (Section 3.2.2).It was seen in Section 3.1.1that although ACID produces a better fit to the data through applying LSD in effective optical depth discrepancies remained between the data and model (Fig. 1).This discrepancy is a possible source of the increased RMS seen in the RVs from ACID profiles compared to those from the CCFs.The RM curve was modelled using the method outlined in Boué et al. ( 2013) with quadratic limb darkening applied.Planetary and stellar inputs, except the projected spin-orbit angle, , were fixed to values obtained from the literature (outlined in Table 1).Uniform priors were applied to the profile depth and width based on the best-fit models and uncertainties outlined in Section 4.2.These corresponded to the Gaussian half-width and depth.The width of each of the priors was equal to the uncertainty on the best-fit value in each case.Observations taken in July 2006 covered a partial transit only as bad weather conditions were reported.Furthermore, Cegla et al. (2016) reported deviations in the local RVs measured from the residual profiles from July 2007.It was suggested that this deviation was caused by a possible decrease in stellar activity on this night compared to the other observation nights.We also saw this deviation in our residual profiles (discussed later in this section) and hence chose to exclude this observation night from the RM fit.Following this, the model was only applied to data from August 2007 and September 2006 and yields a  = 0.05 ± 0.43°and  = 0.13 ± 0.34°for the CCFs and ACID profiles, respectively.In both cases, the spin-orbit angle agrees within the uncertainties with previously reported values (−1.7 ± 0.8°to −0.35 ± 0.25°) (Cegla et al. 2016;Triaud et al. 2009;Collier Cameron et al. 2010).It can be noted that ACID produces a similar constraint on the spin-orbit angle despite the increased scatter in the RV measurements.This demonstrates ACID's ability to detect planetary effects in the RVs to the same precision as CCFs.
The RM effect of HD189733b was further investigated using the Reloaded RM (RRM) technique.This technique, introduced by Cegla et al. ( 2016), isolates the local stellar line profile occulted by the planet.An in-depth description of this technique is included in Cegla et al. (2016), however a brief summary will follow.The line profiles are first scaled according to a Mandel and Agol transit light curve with a quadratic limb darkening law (using the limb darkening coefficients outlined in Table 1).The RRM technique then relies on creating a master out-of-transit profile by combining all out-of-transit profiles using a weighted mean.A residual profile for a particular frame is then created by subtracting the line profile of that frame from the master out-of-transit profile.In this way, the RM signal is isolated and can be seen as a travelling 'bump' in the phase map of the residual profiles.This analysis applies the RRM technique to observations from September 2006, July 2007 and August 2007 as was done by Cegla et al. (2016).This is done on a night-by-night basis for both ACID profiles and CCFs to account for any small variations that could arise in the master out-of-transit profile between each night.
The CCFs used in our analysis are those produced from the same HARPS pipeline as Cegla et al. (2016).However, the HARPS CCFs available on the archive for these observation nights are processed using different stellar masks for different nights.Namely, a K5 stellar mask was applied for observations taken in September 2006 and a G2 stellar mask was applied for July and August 2007.We observed variations in the depths of the CCFs dependent on which mask was used.As this made it difficult to compare the CCFs and ACID profiles we requested the CCFs for all observation nights to be reprocessed using only the K5 stellar mask which provided a better match to the spectral type of HD189733 (K2).This ensured the depths of the CCFs were relatively constant across the observation nights.The residual profiles and CCFs for HD189733b are shown in the top panel of Fig. 10 with their corresponding phase maps shown in the bottom panel.The RRM signal can be seen as a travelling 'bump' visible in residual profiles and CCFs and a dark streak in the phase maps.The signal-to-noise of the CCFs compared to the ACID profiles is very similar, with the RMS of the out-of-transit residual profiles being 0.0012 and 0.0013 in normalised flux for ACID profiles and CCFs, respectively.
The RVs of the residual profiles, representing the local RV of the stellar surface blocked by the planet, were also measured using the mean of a Gaussian (for the CCFs) or Voigt (for the ACID profiles) fit to the in-transit residual profiles.To avoid the continuum of the residual ACID profiles and CCFs, which generally deviate from the models, points lying outside of an absolute velocity of 10 km s −1 were excluded.A larger velocity range was included for the residual profile fit compared to that for the full profiles to account for the larger RV shifts.As the HARPS CCF profiles do not contain errors the error was taken as the standard deviation in the CCF's continuum while for the ACID profiles, the corresponding profile errors were propagated through for the residual profiles.Fig. 11 shows the residual RVs for both the CCFs and ACID profiles.The RVs from ACID have a slightly larger scatter and error associated with them.Despite this, it can be seen that for both the CCFs and ACID profiles the local RV changes as the planet moves across the stellar disc.The first half of the planet's transit shows a blue-shifted stellar surface (moving towards the observer) with this switching to a red-shifted stellar surface (moving away from the observer) once the planet has crossed the centre of the stellar disc.This is the expected outcome as HD189733b resides in an aligned, prograde orbit around its star.Both CCFs and ACID profiles exhibit velocities of ∼3 km s −1 at the stellar limbs.This agrees with the results presented in Cegla et al. (2016) as well as the  sin  * values reported in the literature, which range from 2.9 − 3.5 km s −1 (see Cegla et al. 2016 and references therein).
The limbs also exhibit an increase in scatter in the RVs of both the ACID profiles and CCFs.This deviation in the RVs from the residual CCFs was also seen in Cegla et al. (2016) who attributed this to a possible decrease in magnetic stellar activity during this night.ACID was seen to match the local RVs obtained from the CCFs within the uncertainties and produced a similar RV scatter to that seen with the CCFs.ACID can therefore rival the residual profile RV precision obtained by CCFs while having the added benefit over CCFs as it produces profiles that better represent the expected stellar line profile shape (see Section 4.2).

CONCLUSIONS
This paper has successfully shown ACID to be a novel technique that produces high precision LSD line profiles from high-resolution spectra.ACID was seen to remedy LSD's prediction of nonphysical line depths and produce a forward model that better agreed with the data by performing LSD in effective optical depth.We saw a 40-50 times increase in the out-of-line RMS and an increased distortion of the line profile shape of the resulting LSD profile when an incorrect continuum fit is applied, highlighting the importance of an accurate continuum fit.ACID applies a combined fit of the mean line profile and the spectral continuum which, when applied to model data, was able to accurately retrieve the 'true' spectral continuum.We have shown that implementing this approach provides an accurate continuum correction and, in turn, minimises the noise and profile distortions that can be induced into the resulting profiles.
The application of ACID on HARPS data for HD189733b produced high S/N LSD profiles that exhibit a Voigt profile shape.This is a better approximation for the 'true' profile shape as it shows evidence for a combination of broadening effects.In the case of the CCFs, we observed a Gaussian shape, therefore not accounting for all broadening effects that can occur.ACID, therefore, better preserved the shape of the 'true' line profile and hence the encoded physics than the corresponding CCFs.While neither the ACID profiles nor the CCFs showed evidence of asymmetry in the shape of line profiles, an asymmetry was observed in the uncertainties of the ACID profiles.This could be indicative of line-by-line variability in the asymmetrical shape induced by stellar granulation.
Furthermore, ACID was shown to accurately produce the RM signal of HD189733b through both the classical RM technique and Reloaded RM.For the classical RM technique, we saw that ACID was able to match the RVs obtained from HARPS CCFs within the uncertainties.We did however observe a slightly increased scatter compared to that of the CCFs with an out-of-transit RV RMS of 0.0011 and 0.0015 km s −1 for the CCFs and ACID profiles, respectively.RV scatter in the LSD profiles can be induced by the discrepancies between the data and the model.We observed that although ACID reduces these discrepancies by performing LSD in effective optical depth, some remained as a result of inaccuracies in the line list and possibly remaining 'incorrect' assumptions in LSD.We would therefore expect the RV scatter to decrease when more accurate line data can be obtained.Additionally, the RV scatter could be further improved by also improving the model used to extract the RVs.For example, accounting for any asymmetry in the profile shape that could arise from stellar granulation on the star's surface would improve the accuracy of the measured RVs.While we did not observe evidence of asymmetry in the ACID profiles for HD189733, there was potential evidence of asymmetry found in the profile errors.Simola et al. (2019) has introduced a 'skewed' Gaussian profile that models this asymmetry.We saw that ACID profiles exhibit a Voigt profile shape and were not modelled well by a Gaussian profile.Hence a combination of this 'skewed' model with a Voigt profile shape would be required to better measure the RVs of the ACID profiles.
Best fit RM models applied to the CCFs and ACID profiles returned a spin-orbit angle of  = 0.05 ± 0.43°and  = 0.13 ± 0.34°f or the CCFs and ACID profiles, respectively.This showed that a 0.4 m s −1 increase in the out-of-transit RV RMS is small enough that it did not affect the precision to which ACID could retrieve the spin-orbit angle.The application of the Reloaded RM technique to both ACID profiles and HARPS CCFs shows ACID residual profiles improve the out-of-line RMS by over 5% compared to CCFs while maintaining the RV precision in the local RVs measured from the residual profiles.This further demonstrates that ACID can match the precision of the CCFs while providing a better representation of the line profile.This capability of delivering high S/N profiles that accurately represent the stellar line profile will contribute to our understanding of stellar and planetary physics by providing better insights into their effect on the stellar line profile.

Figure 1 .
Figure 1.The two forward models for LSD performed in flux and effective optical depth are plotted on top of the observed data in the top panel.One example of a deep absorption feature is highlighted.It can be seen for this feature that LSD performed in flux predicts a nonphysical normalised line depth of ∼ 2.5.This depth is greatly improved when LSD is performed in effective optical depth.For reference, the line depths provided by the VALD line list are also plotted.The residuals for each of these models are presented in the bottom panel.It can be seen that the line depths for deep, overlapping lines are in better agreement when LSD is performed in effective optical depth compared to LSD performed in flux.

Figure 2 .
Figure 2. The upper panel shows the model spectrum (created from the convolution of the injected profile and a stellar line list) with each of the applied continuum corrections (vertically offset by ±0.1).The middle panel shows the LSD profiles that result from the spectra corrected by each of the applied continuum corrections and the injected profile (dashed line).The residuals are shown in the bottom panel.

Figure 4 .
Figure 4.The model spectrum used to test ACID is shown in the top panel with the best fit forward model from MCMC plotted on top.The residuals are shown in the bottom panel with the -1, 0 and 1 limits indicated by dashed lines.It can be seen that ACID accurately returns the continuum fit and model line profile.

Figure 5 .
Figure 5.The top panel shows the resulting ACID profile obtained from the model data shown in Fig. 4. The injected profile used to construct the model spectrum is also plotted for comparison with the residuals shown in the bottom panel.

Figure 6 .
Figure 6.The CCF profiles (left) and final ACID line profiles (right) for HD189733b.The CCFs provided by HARPS were over-sampled by a factor of 4, for easier comparison, every 4 th element in the CCFs has been plotted.All frames over all 4 observation nights are plotted on top of each other.This shows uniformity in both CCF and ACID profiles between the observation nights.A vertical dashed blue line has been drawn through 0 km s −1 to help highlight the shape of the profiles.

Figure 7 .
Figure 7.The top panels show the average out-of-transit CCF (left) and ACID profile (right) for all nights are plotted as a solid black line.The best fit Voigt, Gaussian and Lorentzian profiles are plotted.It can be seen that the CCF exhibits a very Gaussian shape, while the ACID profile is best described by a Voigt profile.The residuals are shown in the bottom panel.

Figure 8 .
Figure 8.Average errors from ACID profiles across all nights.Error bars shown represent the standard deviation in the errors.

Figure 9 .
Figure 9.The top panel shows the radial velocities (RVs) as a function of phase for the CCFs and ACID profiles for HD189733b.The RVs were taken as the mean from a best-fit Gaussian and Voigt model for the CCFs and ACID profiles, respectively.Best-fit RM models are shown by dashed lines in each case.The residuals are shown in the bottom panel.

Figure 10 .
Figure10.The residual profiles, obtained via the Reloaded RM (RRM) method from HARPS CCFs (left -all processed using the same K5 mask) and ACID profiles (right) are shown in the top panel for each case.Their corresponding phase maps are shown in the bottom panel.The isolated RM signal can be seen as a travelling 'bump' in the residual profiles and as a dark streak travelling across the centre of the phase map.The CCFs are plotted using every 4th element to account for the oversampling from the HARPS pipeline.

Figure 11 .
Figure 11.Net velocity shifts of the in-transit residual profiles as a function of phase for the CCF residual profiles and ACID residual profiles.

Figure A1 .
Figure A1.The out-of-transit residual profiles for July 2007, obtained via the Reloaded RM (RRM) method from HARPS CCFs (left) and ACID profiles (right) are shown in the top panel for each case.Their corresponding phase maps are displayed in the bottom panel.A sharp decrease in flux (observed as a dark blue feature), surrounded by a flux increase (observed as a yellow feature) on either side can be seen at ∼ 3 km s −1 in the residual ACID profiles.This feature appears at a phase of ∼ 0.032 and is not present in the CCFs.

Figure A2 .
Figure A2.Measured RVs from ACID (including orders 40-42) and ACID (excluding orders 40-42) with the best fit RM model indicated by a dashed line in each case.

Table 1 .
Planetary and stellar parameters used for modelling the RM RV curve.The inputs for the model are: Gaussian half-width for ACID,   and CCFs,   ; normalised profile depth for ACID,   and CCFs,   ; stellar rotational velocity,  sin * ; planetary inclination,   ; effective planetary radius,   / * ; scaled semi-major axis, / * ; limb darkening coefficients, ( 1 ,  2 ) and the orbital period, .