# RvSpectML Internals

As a heads up, these functions and types are more likely to change going forward than functions and types that are exported.

## Functions

### General purpose

`Base.append!`

— MethodAppend second chunk list to the first.

`Base.getindex`

— MethodProvide direct access to data, an AbstractArray of ChunkOfSpectrum's via [] operator

`Base.getindex`

— MethodAllow direct access to data, an AbstractArray of ChunkOfSpectrum's via [] operator

`Base.setindex!`

— MethodProvide direct access to data, an AbstractArray of ChunkOfSpectrum's via [] operator

`Base.setindex!`

— MethodAllow direct access to data, an AbstractArray of ChunkOfSpectrum's via [] operator

`RvSpectMLBase.allequal`

— MethodReturn true if all elements of array are equal to each other.

`RvSpectMLBase.calc_line_bisector_at_abs_depth`

— Methodcalc*line*bisector*at*abs*depth(λ, flux; abs*depth ) Returns the line average of wavelengths (units of λ) at specified absolute line depth. Assumes continuum is the maximum flux provided.

`RvSpectMLBase.calc_line_bisector_at_frac_depth`

— Methodcalc*line*bisector*at*frac*depth(λ, flux; frac*depth, line*min*window*fraction ) Returns the line average of wavelengths (units of λ) at specified fractional line depth. Assumes continuum is the maximum flux provided. Assumes the line's minimum flux occurs within line*min*window*fraction, a central fraction of the total λ window. Returns NaN if target flux cannot be found on either side of the line

`RvSpectMLBase.calc_line_width`

— Methodcalc*line*width(λ, flux; frac*depth, line*min*window*fraction ) Returns the line width (units of λ) for specified fractional line depth (default of 0.5). Assumes continuum is the maximum flux provided. Assumes the line's minimum flux occurs within line*min*window_fraction, a central fraction of the total λ window. Returns NaN if target flux cannot be found on either side of the line

`RvSpectMLBase.calc_snr`

— Function`calc_snr(flux, var)`

`calc_snr(spectrum, pixels, order_idx)`

Calculate total SNR in (region of) spectra.

`RvSpectMLBase.check_if_line_match`

— Method`check_if_line_match ( λ, list ; threshold )`

Return true if list contains a wavelength differing from λ by no more than threshold (in units of Δλ/λ)

`RvSpectMLBase.find_cols_to_fit`

— MethodReturn a range of columns indices with wavelengths between line*lo and line*hi

`RvSpectMLBase.find_cols_to_fit`

— MethodReturn a range of columns indices with wavelengths within Δ of line_center

`RvSpectMLBase.find_which_line_fits_in_line_list`

— Methodfind*which*line*fits*in*line*list( fit*list, line*list; threshold ) Return list of Bools indicatin which line(s) from fit*list match a line in line*list to within threshold (in units of Δλ/λ) Warning: Untested

`RvSpectMLBase.findargminmax`

— Method`findargminmax(a)`

Return (argmin, min, argmax, max) Adapapted from https://github.com/JuliaLang/julia/blob/697e782ab86bfcdd7fd15550241fe162c51d9f98/base/array.jl#L2191

`RvSpectMLBase.instrument`

— MethodGet instrument used for chunk*list*timeseries.

`RvSpectMLBase.interp_linear`

— Method`interp_linear(;x1,x2,y1,y2,xpred) Return result of simple linear interpolant at xpred. Does not test that xpred is between x1 and x2.

`RvSpectMLBase.is_in_wavelength_range_list`

— Method`is_in_wavelength_range_list(λ_lo, λ_hi; list )`

Return true if there is overlap between (λ*lo, λ*hi) and lambda*lo and lambda*hi for any row in list

**TODO: test**

`RvSpectMLBase.is_in_wavelength_range_list`

— Method`is_in_wavelength_range_list(λ; order, list )`

Return true if λ is between lambda*lo and lambda*hi for any row in list

`RvSpectMLBase.is_in_wavelength_range_list_any_order`

— Method`is_in_wavelength_range_list_any_order(λ; list )`

Return true if λ is between lambda*lo and lambda*hi for any row in list

`RvSpectMLBase.make_spectral_time_series_common_wavelengths_with_selected_times`

— Methodmake*spectral*time*series*common*wavelengths*with*selected*times( input, time*idx ) Returns a SpectralTimeSeriesCommonWavelengths, retaining only those times and spectra specified by time*idx.

`RvSpectMLBase.metadata`

— MethodGet metadata[:key] of ith observation in chunk*list*timeseries.

`RvSpectMLBase.multiple_append!`

— MethodA generalized version of the built in append!() function By Christian Gilbertson?

**TODO: Ask Christian what the purpose of this is relative to std append**

`RvSpectMLBase.predict_intrinsic_stellar_line_width`

— MethodEstimate line width based on stellar Teff (K) and optionally v_rot (m/s). Output in m/s.

`RvSpectMLBase.searchsortednearest`

— Function`searchsortednearest(a<:AbstractVector, x::Real; assume_sorted = false )`

`searchsortednearest(a<:AbstractVector, x<:AbstractVector; assume_sorted = false )`

Find the index of vector a where the value of a is closest to x. All vectors are assumed to already be sorted. To turn off assertions, set assume_sorted to true.

Credit: traktofon @ https://discourse.julialang.org/t/findnearest-function/4143/4 Vector Vector version by Christian Gilbertson? issorted assertion and optional assume_sorted added by Eric Ford

`RvSpectMLBase.time`

— MethodGet time of ith observation in chunk*list*timeseries.

### Interpolation

```
Modules = [RvSpectMLBase.LinearInterpolation ]
Public = false
Order = [ :function]
```

### Instrument specific

`RvSpectMLBase.TheoreticalInstrument.calc_λ`

— Method`calc_λs(inst)`

Compute the wavelength for one pixel of a theoretical 1d instrument

`RvSpectMLBase.TheoreticalInstrument.calc_λs`

— Function`calc_λs`

Generate an array of n wavelengths uniformly spaced in log(lambda)

`RvSpectMLBase.TheoreticalInstrument.calc_λs`

— Method`calc_λs(λ_min, λ_max, n)`

Generate an array of n wavelengths uniformly spaced in log(lambda) from λ*min to λ*max.

`RvSpectMLBase.TheoreticalInstrument.calc_λs`

— Method`calc_λs(inst)`

Generate an array of wavelengths based on a theoretical instrument's properties

`RvSpectMLBase.TheoreticalInstrument.calc_λs`

— Method`calc_λs(inst)`

Generate an array of wavelengths based on a theoretical instrument's properties

`RvSpectMLBase.TheoreticalInstrument.demo_generate_spectrum_line`

— Method`demo_generate_spectrum_line( inst )`

Generate spectrum with one line for testing purposes.

### Other

## Types

### General purpose

### Interpolation

```
Modules = [RvSpectMLBase.LinearInterpolation ]
Public = false
Order = [:type ]
```