# Calculate RVs from CCF

## Functions

`EchelleCCFs.RVFromCCF.calc_ccf_sample_covar`

— Method`calc_ccf_sample_covar( ccfs, ccf_vars)`

Estimate sample covariance for set of CCFs

`EchelleCCFs.RVFromCCF.calc_ccf_sample_covar_reduced_rank`

— Method`calc_ccf_sample_covar_reduced_rank( ccfs, ccf_vars ; kmax)`

Calculate a reduced rank approximation to the sample covariance matrix for the CCF

`EchelleCCFs.RVFromCCF.est_covar_for_obs`

— Method`est_covar_for_obs(covar_reduced_rank, diag_model, diag_norm)`

Returns estimate of the CCF covariance based using `covar_reduced_rank + diag_norm * diag_model`

`diag_model`

is typically not diagonal, but rather terms near the diagonal

`EchelleCCFs.RVFromCCF.measure_rv_from_ccf`

— Function``measure_rv_from_ccf(vels, ccf, [ccf_var]; alg )``

Return estimated RV based on the CCF using specified algorithm object. Inputs:

`vels`

: Array of velocites where CCF was evaluated.`ccf`

: Array of values of CCF

Optional Arguements:

`alg`

: Functor specifying how to measure the RV and it's uncertainty from the CCF. Options include:

MeasureRvFromCCFGaussian (default), MeasureRvFromCCFQuadratic, MeasureRvFromCCFCentroid, and MeasureRvFromMinCCF.

`EchelleCCFs.RVFromCCF.measure_rvs_from_ccf`

— Function`measure_rvs_from_ccf(vels, ccf, [ccf_var]; alg )`

At each time, return the estimated radial velocities based on the CCFs using the specified algorithm. Inputs:

`vels`

: Array of velocites where CCF was evaluated.`ccf`

: Array of values of CCF

Optional Arguements:

`alg`

: Functor specifying how to measure the RV and its uncertainty from the CCF. Options include:

MeasureRvFromCCFGaussian (default), MeasureRvFromCCFQuadratic, MeasureRvFromCCFCentroid, and MeasureRvFromMinCCF.

## Types

`EchelleCCFs.RVFromCCF.AbstractMeasureRvFromCCF`

— TypeAbstract type for functors to estimate the radial velocity from a CCF and its velocity grid.

`EchelleCCFs.RVFromCCF.AbstractMeasureRvFromCCF`

— MethodEstimate RV based on centroid velocity of the CCF. Inputs:

- vels: Array of velocites where CCF was evaluated.
- ccf: Array of values of CCF

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFCentroid`

— TypeFunctor to estimate RV based on the centroid of the CCF. Inputs:

`vels`

: Array of velocites where CCF was evaluated.`ccf`

: Array of values of CCF`ccf_var`

: Array of variances of CCF

Warning: Not well tested yet

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFCentroid`

— MethodConstruct functor to estimate RV based on the CCF. Optional Arguments:

`frac_of_width_to_fit`

: (0.5)`measure_width_at_frac_depth`

: (0.5)

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFGaussian`

— TypeFunctor to estimate RV based on fitting a Gaussian quadratic near minimum of the CCF.

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFGaussian`

— MethodConstruct functor to estimate RV based on the CCF. Optional Arguments:

`frac_of_width_to_fit`

: (0.5)`measure_width_at_frac_depth`

: (0.5)`init_guess_ccf_σ`

`: (2000m/s)

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFQuadratic`

— TypeFunctor to estimate RV based on fitting quadratic near minimum of CCF. TODO: Revist the logic here and see if need to perform transformation first.

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFQuadratic`

— MethodConstruct functor to estimate RV based on the CCF. Optional Arguments:

`frac_of_width_to_fit`

: (0.5)`measure_width_at_frac_depth`

: (0.5)

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFTemplate`

— TypeFunctor to estimate RV based on fitting a template and its derivative near minimum of the CCF.

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFTemplate`

— MethodConstruct functor to estimate RV based on the CCF. TODO: Implement correctly. Not yet working/tested. Optional Arguments:

`v_grid`

: list of velocities where template is evaluated`template`

: template ccf evaluated at v_grid`frac_of_width_to_fit`

: (0.5)`measure_width_at_frac_depth`

: (0.5)

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFTemplateNonDiagCovar`

— TypeFunctor to estimate RV based on fitting a template and its derivative near minimum of the CCF.

`EchelleCCFs.RVFromCCF.MeasureRvFromCCFTemplateNonDiagCovar`

— MethodConstruct functor to estimate RV based on the CCF. TODO: Implement correctly. Not yet working/tested. Optional Arguments:

`v_grid`

: list of velocities where template is evaluated`template`

: template ccf evaluated at v_grid`frac_of_width_to_fit`

: (0.5)`measure_width_at_frac_depth`

: (0.5)

`EchelleCCFs.RVFromCCF.MeasureRvFromMinCCF`

— TypeFunctor to estimate RV based on velocity at minimum of CCF. Warning: Since a discrete grid of velocities are evaluated, this should only be used in limited situations (e.g., an initial guess).

## Internals

`EchelleCCFs.RVFromCCF.compute_mean_off_diag`

— Method`compute_mean_off_diag(matrix, offset)`

Compute mean value of entries with given offset from the diagonal. Note: offset may be positive or negative

`EchelleCCFs.RVFromCCF.est_full_width`

— Method`est_full_width(vels, ccf; measure_width_at_frac_depth = 0.5 )`

Return rough estimate of a ccf (or line) full width at the specified fractional depth (i.e., fraction of total depth). This is based on the velocities of the first/last pixel to have a value less than the target value, with no interpolation. Assumes vels is sorted. Depth is measured assuming to the maximum value of ccf represents the continuum. Could be improved for noisy data and segments with a steep slope due to the blaze or neighboring lines. Inputs:

`vels`

: Array of velocites where CCF was evaluated.`ccf`

: Array of values of CCF

Optional Arguements:

`measure_width_at_frac_depth`

: What fractional CCF depth should be used for defining the width (0.5)

`EchelleCCFs.RVFromCCF.find_idx_at_and_around_minimum`

— Method`find_idx_at_and_around_minimum(vels, ccf; frac_of_width, measure_width_at_frac_depth )`

Return the a pair with the index of the lowest value of ccf and a range of pixels surrounding it. The range is based on finding the pixels with velocities nearest to the Assumes vels is sorted. Inputs:

`vels`

: Array of velocites where CCF was evaluated.`ccf`

: Array of values of CCF

Optional Arguements:

`frac_of_width_to_fit`

: How large of a range of velocities should be included in the fit (0.5)`measure_width_at_frac_depth`

: What fractional CCF depth should be used for defining the width (0.5)