Index
StellarSpectraObservationFitting.Adam
StellarSpectraObservationFitting.AdamState
StellarSpectraObservationFitting.AdamSubWorkspace
StellarSpectraObservationFitting.BaseLinearModel
StellarSpectraObservationFitting.FrozenTelWorkspace
StellarSpectraObservationFitting.FullLinearModel
StellarSpectraObservationFitting.GenericData
StellarSpectraObservationFitting.GenericDatum
StellarSpectraObservationFitting.LSFData
StellarSpectraObservationFitting.ModelWorkspace
StellarSpectraObservationFitting.OptimSubWorkspace
StellarSpectraObservationFitting.OptimTelStarWorkspace
StellarSpectraObservationFitting.OptimTotalWorkspace
StellarSpectraObservationFitting.OrderModel
StellarSpectraObservationFitting.OrderModelDPCA
StellarSpectraObservationFitting.OrderModelWobble
StellarSpectraObservationFitting.Output
StellarSpectraObservationFitting.OutputDPCA
StellarSpectraObservationFitting.OutputWobble
StellarSpectraObservationFitting.StellarInterpolationHelper
StellarSpectraObservationFitting.Submodel
StellarSpectraObservationFitting.TemplateModel
StellarSpectraObservationFitting.TotalWorkspace
ExpectationMaximizationPCA.EMPCA!
ParameterHandling.flatten
ParameterHandling.flatten
StellarSpectraObservationFitting.AdamState!
StellarSpectraObservationFitting.DEMPCA!
StellarSpectraObservationFitting.D_to_rv
StellarSpectraObservationFitting.L1
StellarSpectraObservationFitting.L2
StellarSpectraObservationFitting.L∞
StellarSpectraObservationFitting.Output!
StellarSpectraObservationFitting._OSW_optimize!
StellarSpectraObservationFitting._eval_lm
StellarSpectraObservationFitting._eval_lm_vec
StellarSpectraObservationFitting._eval_regularization
StellarSpectraObservationFitting._loss_recalc_rv_basis
StellarSpectraObservationFitting._lower_inds!
StellarSpectraObservationFitting._shift_log_λ_model
StellarSpectraObservationFitting._spectra_interp_gp!
StellarSpectraObservationFitting._trapzx2
StellarSpectraObservationFitting._vander
StellarSpectraObservationFitting.affected_pixels
StellarSpectraObservationFitting.affected_pixels!
StellarSpectraObservationFitting.aic
StellarSpectraObservationFitting.aicc
StellarSpectraObservationFitting.bad_pixel_flagger
StellarSpectraObservationFitting.banded_inds
StellarSpectraObservationFitting.bic
StellarSpectraObservationFitting.bounds_generator
StellarSpectraObservationFitting.bounds_generator!
StellarSpectraObservationFitting.build_gp
StellarSpectraObservationFitting.calculate_initial_model
StellarSpectraObservationFitting.calculate_initial_model
StellarSpectraObservationFitting.check_converged
StellarSpectraObservationFitting.check_for_valid_regularization
StellarSpectraObservationFitting.choose_reg_and_ℓ
StellarSpectraObservationFitting.clip_vector!
StellarSpectraObservationFitting.continuum_normalize!
StellarSpectraObservationFitting.copy_dict!
StellarSpectraObservationFitting.copy_reg!
StellarSpectraObservationFitting.create_λ_template
StellarSpectraObservationFitting.doppler_component
StellarSpectraObservationFitting.doppler_component_AD
StellarSpectraObservationFitting.downsize
StellarSpectraObservationFitting.downsize_view
StellarSpectraObservationFitting.est_∇
StellarSpectraObservationFitting.estimate_σ_bootstrap
StellarSpectraObservationFitting.estimate_σ_bootstrap
StellarSpectraObservationFitting.estimate_σ_bootstrap_helper!
StellarSpectraObservationFitting.estimate_σ_bootstrap_reducer
StellarSpectraObservationFitting.estimate_σ_curvature
StellarSpectraObservationFitting.estimate_σ_curvature
StellarSpectraObservationFitting.estimate_σ_curvature_helper
StellarSpectraObservationFitting.estimate_σ_curvature_helper_finalizer!
StellarSpectraObservationFitting.eval_regularization
StellarSpectraObservationFitting.fill_OrderModel!
StellarSpectraObservationFitting.fill_StarModel!
StellarSpectraObservationFitting.fill_TelModel!
StellarSpectraObservationFitting.finalize_scores!
StellarSpectraObservationFitting.finalize_scores!
StellarSpectraObservationFitting.finalize_scores_setup
StellarSpectraObservationFitting.find_modes
StellarSpectraObservationFitting.first_iterate!
StellarSpectraObservationFitting.fit_continuum
StellarSpectraObservationFitting.fit_regularization!
StellarSpectraObservationFitting.fit_regularization!
StellarSpectraObservationFitting.fit_regularization!
StellarSpectraObservationFitting.fit_regularization_helper!
StellarSpectraObservationFitting.flat_normalize!
StellarSpectraObservationFitting.flatten_ranges
StellarSpectraObservationFitting.flip_feature_vectors!
StellarSpectraObservationFitting.fwhm_2_σ
StellarSpectraObservationFitting.general_lst_sq
StellarSpectraObservationFitting.general_lst_sq_f
StellarSpectraObservationFitting.get_marginal_GP
StellarSpectraObservationFitting.get_mean_GP
StellarSpectraObservationFitting.gp_Δℓ
StellarSpectraObservationFitting.gp_Δℓ_coefficients
StellarSpectraObservationFitting.gp_Δℓ_helper_K
StellarSpectraObservationFitting.gp_Δℓ_helper_γ
StellarSpectraObservationFitting.gp_ℓ
StellarSpectraObservationFitting.gp_ℓ_nabla
StellarSpectraObservationFitting.gp_ℓ_precalc
StellarSpectraObservationFitting.improve_initial_model!
StellarSpectraObservationFitting.improve_model!
StellarSpectraObservationFitting.improve_model!
StellarSpectraObservationFitting.insert_and_dedup!
StellarSpectraObservationFitting.int2ind
StellarSpectraObservationFitting.intra_night_std
StellarSpectraObservationFitting.iterate!
StellarSpectraObservationFitting.log_lm
StellarSpectraObservationFitting.loss_func
StellarSpectraObservationFitting.loss_funcs_frozen_tel
StellarSpectraObservationFitting.loss_funcs_telstar
StellarSpectraObservationFitting.loss_funcs_total
StellarSpectraObservationFitting.make_template
StellarSpectraObservationFitting.make_template
StellarSpectraObservationFitting.mask!
StellarSpectraObservationFitting.mask_bad_edges!
StellarSpectraObservationFitting.mask_bad_pixel!
StellarSpectraObservationFitting.mask_high_pixels!
StellarSpectraObservationFitting.mask_infinite_pixels!
StellarSpectraObservationFitting.mask_isolated_pixels!
StellarSpectraObservationFitting.mask_low_pixels!
StellarSpectraObservationFitting.mask_stellar_feature!
StellarSpectraObservationFitting.mask_stellar_pixel!
StellarSpectraObservationFitting.mask_telluric_feature!
StellarSpectraObservationFitting.model_prior
StellarSpectraObservationFitting.model_s_prior
StellarSpectraObservationFitting.multiple_append!
StellarSpectraObservationFitting.no_tellurics
StellarSpectraObservationFitting.observation_night_inds
StellarSpectraObservationFitting.opt_funcs
StellarSpectraObservationFitting.ordinary_lst_sq
StellarSpectraObservationFitting.ordinary_lst_sq_f
StellarSpectraObservationFitting.outlier_mask
StellarSpectraObservationFitting.oversamp_interp
StellarSpectraObservationFitting.oversamp_interp_helper
StellarSpectraObservationFitting.parse_args
StellarSpectraObservationFitting.process!
StellarSpectraObservationFitting.process!
StellarSpectraObservationFitting.project_doppler_comp
StellarSpectraObservationFitting.project_doppler_comp!
StellarSpectraObservationFitting.ratio_clarifier_string
StellarSpectraObservationFitting.recalc_total!
StellarSpectraObservationFitting.remove_lm_score_means!
StellarSpectraObservationFitting.reset_regularization!
StellarSpectraObservationFitting.rm_GP_regularization!
StellarSpectraObservationFitting.rm_dict!
StellarSpectraObservationFitting.rm_dict!
StellarSpectraObservationFitting.rm_regularization!
StellarSpectraObservationFitting.rv_model
StellarSpectraObservationFitting.rv_to_D
StellarSpectraObservationFitting.rvs
StellarSpectraObservationFitting.scale_α_helper!
StellarSpectraObservationFitting.searchsortednearest
StellarSpectraObservationFitting.self_cor
StellarSpectraObservationFitting.shared_attention
StellarSpectraObservationFitting.simple_derivative
StellarSpectraObservationFitting.simple_derivative_AD
StellarSpectraObservationFitting.snap
StellarSpectraObservationFitting.spectra_interp
StellarSpectraObservationFitting.spectra_interp
StellarSpectraObservationFitting.speed_up_iterate!
StellarSpectraObservationFitting.star_model
StellarSpectraObservationFitting.star_prior
StellarSpectraObservationFitting.tel_model
StellarSpectraObservationFitting.tel_prior
StellarSpectraObservationFitting.total_length
StellarSpectraObservationFitting.total_model
StellarSpectraObservationFitting.train_OrderModel!
StellarSpectraObservationFitting.train_OrderModel!
StellarSpectraObservationFitting.train_OrderModel!
StellarSpectraObservationFitting.train_SubModel!
StellarSpectraObservationFitting.train_rvs_optim!
StellarSpectraObservationFitting.trapz_small
StellarSpectraObservationFitting.trapz_small
StellarSpectraObservationFitting.undersamp_interp_helper
StellarSpectraObservationFitting.update!
StellarSpectraObservationFitting.update_interpolation_locations!
StellarSpectraObservationFitting.vector_zero
StellarSpectraObservationFitting.wavenumber_to_Å
StellarSpectraObservationFitting.weighted_mean
StellarSpectraObservationFitting.zero_regularization
StellarSpectraObservationFitting.Å_to_wavenumber
StellarSpectraObservationFitting.Δℓ_precalc
StellarSpectraObservationFitting.ℓ
StellarSpectraObservationFitting.ℓ_prereqs
StellarSpectraObservationFitting.Adam
— TypeAdam
Holds information used for Adaptive Moment Estimation optimization
StellarSpectraObservationFitting.AdamState
— TypeAdamState
Holds diagonstic information on the current state of an ADAM opmitization
StellarSpectraObservationFitting.AdamSubWorkspace
— TypeAdamSubWorkspace
Holds a set of model parameters and the ADAM optimizer and functions used to optimize them
StellarSpectraObservationFitting.BaseLinearModel
— TypeBaseLinearModel
A (log) linear model without a mean (either Ms or exp(Ms)). Used for DPCA models
StellarSpectraObservationFitting.FrozenTelWorkspace
— TypeFrozenTelWorkspace
A workspace to optimize all of the parameters in a SSOF model (except for the tellruc template and features) and data it is to be optimized on
StellarSpectraObservationFitting.FullLinearModel
— TypeFullLinearModel
A (log) linear model including a mean (either μ+Ms or μexp(M*s))
StellarSpectraObservationFitting.GenericDatum
— TypeGenericDatum
Holds a single preprocessed spectrum used to optimize SSOF models
StellarSpectraObservationFitting.ModelWorkspace
— MethodModelWorkspace(model, data)
Create a workspace for optimizing model
with data
Creates a FrozenTelWorkspace if the model has no telluric feature vectors and an empty telluric template
StellarSpectraObservationFitting.OptimSubWorkspace
— TypeOptimSubWorkspace
Holds a set of model parameters and the Optim optimizer and functions used to optimize them
StellarSpectraObservationFitting.OptimTelStarWorkspace
— TypeOptimTelStarWorkspace
A workspace to go back and forth optimizing the telluric and stellar parameters then the RVs in a SSOF model and data it is to be optimized on Uses methods in Optim
StellarSpectraObservationFitting.OptimTotalWorkspace
— TypeOptimTotalWorkspace
A workspace to optimize all of the parameters in a SSOF model and data it is to be optimized on Uses methods in Optim
StellarSpectraObservationFitting.OrderModel
— MethodOrderModel(d; kwargs...)
Constructor for the OrderModel
-type objects (SSOF model for a set of 1D spectra)
Optional arguments
instrument::String="None"
: The name of the instrument(s) the data was taken from. For bookkeepingorder::Int=0
: What order (if any) the data was taken from. For bookkeepingstar_str::String="None"
: The name of the star the data was taken from. For bookkeepingn_comp_tel::Int=5
: Amount of telluric feature vectorsn_comp_star::Int=5
: The maximum amount of stellar feature vectorsoversamp::Bool=true
: Whether or not to integrate the model or do linear interpolation (for the telluric model)dpca::Bool=false
: Whether to use Doppler-constrained PCA or variable interpolation location to determine the RVslog_λ_gp_star::Real=1/SOAP_gp_params.λ
: The log λ lengthscale of the stellar regularization GPlog_λ_gp_tel::Real=1/LSF_gp_params.λ
: The log λ lengthscale of the telluric regularization GPtel_log_λ::Union{Nothing,AbstractRange}=nothing
: The logstar_log_λ::Union{Nothing,AbstractRange}=nothing
: The log λ lengthscale of the telluric regularization GPkwargs...
: kwargs passed toSubmodel
constructors
StellarSpectraObservationFitting.OrderModelDPCA
— TypeOrderModelDPCA
SSOF model for a set of 1D spectra using Doppler-constrained PCA to measure the RVs (which are contained in the RV Submodel)
StellarSpectraObservationFitting.OrderModelWobble
— TypeOrderModelWobble
SSOF model for a set of 1D spectra using linear interpolation of the stellar model to measure the RVs
StellarSpectraObservationFitting.Output
— MethodOutput(om, d)
Calculates the current outputs for the models at the observed wavelengths
StellarSpectraObservationFitting.OutputDPCA
— TypeOutputDPCA
Holds the current outputs for the models at the observed wavelengths
StellarSpectraObservationFitting.OutputWobble
— TypeOutputWobble
Holds the current outputs for the models at the observed wavelengths
StellarSpectraObservationFitting.StellarInterpolationHelper
— TypeStellarInterpolationHelper
A linear interpolation holding information to interpolate the stellar model shifted by an RV to the data
StellarSpectraObservationFitting.Submodel
— TypeSubmodel
Holds information on the wavelengths, LTISDE representaiton for the GP reguarlization term, and linear model for a SSOF model component
StellarSpectraObservationFitting.TemplateModel
— TypeTemplateModel
A constant model (when there are no feature vectors)
StellarSpectraObservationFitting.TotalWorkspace
— TypeTotalWorkspace
A workspace to optimize all of the parameters in a SSOF model and data it is to be optimized on Uses our custom implementation of ADAM
ParameterHandling.flatten
— Methodflatten([eltype=Real], x::LinearModel)
Returns a "flattened" representation of x::LinearModel
as a vector of vectors and a function unflatten
that takes a vector of reals of the same length and returns a LinearModel object
ParameterHandling.flatten
— Methodflatten([eltype=Real], x::SubArray)
Returns a "flattened" representation of x::SubArray
as a vector and a function unflatten
that takes a vector of reals of the same length and returns an Array object
StellarSpectraObservationFitting.AdamState!
— MethodAdamState!(as, ℓ, Δ)
Update as
with the next iteration's loss and gradient
StellarSpectraObservationFitting.D_to_rv
— MethodD_to_rv(D)
Approximately converting a Doppler shift D ≡ log(λ1/λ0)
in log-wavelength space to an RV using (λ1-λ0)/λ0 = λ1/λ0 - 1 = e^D - 1 ≈ β = v / c
(with an extra negative sign from somewhere)
StellarSpectraObservationFitting.L1
— MethodL1 norm
StellarSpectraObservationFitting.L2
— MethodL2 norm
StellarSpectraObservationFitting.L∞
— MethodL∞ norm
StellarSpectraObservationFitting.Output!
— MethodOutput!(o, om, d)
Recalculates the current outputs for the models at the observed wavelengths
StellarSpectraObservationFitting._OSW_optimize!
— Method_OSW_optimize!(osw, options)
Optimize the model in osw
StellarSpectraObservationFitting._eval_lm
— Method_eval_lm(M, s, μ; log_lm=false)
Evaluate a LinearModel
StellarSpectraObservationFitting._eval_lm_vec
— Method_eval_lm_vec(om, v; log_lm=_log_lm_default)
Evaluate a vectorized version of a linear model in v
StellarSpectraObservationFitting._eval_regularization
— Method_eval_regularization(om, mws, training_inds, testing_inds; kwargs...)
Training om
on the training data, evaluating _loss()
on the testing data after optimizing the RVs and scores
StellarSpectraObservationFitting._loss_recalc_rv_basis
— Method_loss_recalc_rv_basis(o, om, d; kwargs...)
_loss()
but including an AD-compliant way to recalcuate the Doppler basic vector
StellarSpectraObservationFitting._lower_inds!
— Method_lower_inds!(lower_inds, lower_inds_adj, model_log_λ, rvs, log_λ_obs)
find the model_log_λ
indices (incl. RV shifts) that bracket each log_λ_obs
StellarSpectraObservationFitting._shift_log_λ_model
— Method_shift_log_λ_model(log_λ_obs_from, log_λ_obs_to, log_λ_model_from)
Getting model log λ in a different reference frame using the shifts in the different log_λ_obs
StellarSpectraObservationFitting._spectra_interp_gp!
— Method_spectra_interp_gp!(fluxes, log_λ, flux_obs, var_obs, log_λ_obs; gp_mean=0., gp_base=SOAP_gp, mask_flux=Array{Bool}(undef, length(flux_obs)), mask_var=Array{Bool}(undef, length(flux_obs)))
Use a GP to interpolate flux_obs
observed at log_λ_obs
onto log_λ
StellarSpectraObservationFitting.affected_pixels!
— Methodaffected_pixels!(affected1, affected2)
Store the indicies in both affected1
and affected2
in affected1
StellarSpectraObservationFitting.affected_pixels
— Methodaffected_pixels(bad)
Store the first indicies where bad
` is true
StellarSpectraObservationFitting.aic
— MethodAkaike information criterion
StellarSpectraObservationFitting.aicc
— MethodAkaike information criterion (corrected for small sample sizes)
StellarSpectraObservationFitting.bic
— MethodBayesian information criterion
StellarSpectraObservationFitting.build_gp
— Methodbuild_gp(params)
Builds a Matern 5/2 TemporalGPs GP
StellarSpectraObservationFitting.calculate_initial_model
— Methodcalculate_initial_model(data; kwargs...)
Find a SSOF model for a given dataset, data
. Defaults to returning the AIC-minimum model
Optional arguments
instrument::String="None"
: The name of the instrument(s) the data was taken from. For bookkeepingdesired_order::Int=0
: What order (if any) the data was taken from. For bookkeepingstar::String="None"
: The name of the star the data was taken from. For bookkeepingtimes::AbstractVector=1:size(data.flux, 2)
: The list of times (in days). Used to calculate intra-night RMSμ_min::Real=0
: Set the minimum flux value for the output ofmake_template()
μ_max::Real=Inf
: Set the maximum flux value for the output ofmake_template()
use_mean::Bool=true
: Whether to use the mean or median formake_template()
stop_early::Bool=false
: Whether to stop the model search the first time adding a component increases the AICremove_reciprocal_continuum::Bool=false
: Whether you should attempt to remove places where the telluric template and stellar template are opposing each other (i.e. where continuum goes up in one and down in the other)return_full_path::Bool=false
: Whether to return all of the searched models and metricsmax_n_tel::Int=5
: The maximum amount of telluric feature vectors to look formax_n_star::Int=5
: The maximum amount of stellar feature vectors to look foruse_all_comps::Bool=false
: Whether to use all feature vectors, regardless of AICcareful_first_step::Bool=true
: Whether to shrink the learning rates until the loss improves on the first iterationspeed_up::Bool=false
: Whether to inflate the learning rates until the loss is no longer improving throughout the optimizationlog_λ_gp_star::Real=1/SOAP_gp_params.λ
: The log λ lengthscale of the stellar regularization GPlog_λ_gp_tel::Real=1/LSF_gp_params.λ
: The log λ lengthscale of the telluric regularization GPkwargs...
: kwargs passed toOrderModel
constructor
StellarSpectraObservationFitting.check_converged
— Methodcheck_converged(as, f_reltol, g_reltol, g_L∞tol)
Check to see if the Adam optimization has coverged based on the change in loss or its gradient
StellarSpectraObservationFitting.check_for_valid_regularization
— Methodcheck_for_valid_regularization(reg)
Make sure all the keys in reg
are in SSOF.keylist
StellarSpectraObservationFitting.choose_reg_and_ℓ
— Methodchoose_reg_and_ℓ(reg_fields, om, reg_key, reg_hold, ℓs, j)
Set the reg_key
regularization for om
once the local minimum is found
StellarSpectraObservationFitting.copy_reg!
— Methodcopy_reg!(from, to)
Copy the regularizations from one OrderModel to another
StellarSpectraObservationFitting.create_λ_template
— Methodcreate_λ_template(log_λ_obs; upscale=1.)
Creating a uniform grid of log wavelengths for the SSOF models to be evaluated on
StellarSpectraObservationFitting.downsize
— Methoddownsize(lm, n_comp)
Create a smaller version of lm
that only copies some amount of the feature vectors
StellarSpectraObservationFitting.downsize_view
— Methoddownsize(lm, n_comp)
Create a smaller view of lm
that can only see some amount of the feature vectors
StellarSpectraObservationFitting.estimate_σ_bootstrap
— Methodestimate_σ_bootstrap(mws; n=50, return_holders=false, recalc_mean=false, multithread=nthreads() > 3, verbose=true)
Estimate the uncertainties (and potentially covariances) for the RVs and scores in mws
based on looking at the distribution of best-fit parameters after re-injecting photon noise. Slower than estimate_σ_curvature()
, but more reliable.
StellarSpectraObservationFitting.estimate_σ_bootstrap_helper!
— Methodestimate_σ_bootstrap_helper!(rv_holder, tel_holder, star_holder, i, mws, data_noise, n; verbose=true)
Refit the RVs and scores after re-injecting photon noise and store the results in rv_holder
, tel_holder
, and star_holder
StellarSpectraObservationFitting.estimate_σ_bootstrap_reducer
— Methodestimate_σ_bootstrap_reducer(shaper, holder, reducer)
Apply reducer
on the first axis of holder
and store the results in an array the shape of shaper
StellarSpectraObservationFitting.estimate_σ_curvature
— Methodestimate_σ_curvature(mws; kwargs...)
Estimate the uncertainties for the RVs and scores in mws
based on the local curvature of the loss function. Faster than estimate_σ_bootstrap()
, but less reliable from ignoring cross terms in the Hessian.
StellarSpectraObservationFitting.estimate_σ_curvature_helper
— Methodestimate_σ_curvature_helper(x, ℓ; n=7, use_gradient=false, multithread=nthreads() > 3, print_every=10, kwargs...)
Estimate the uncertainties for the best-fit parameters x
for ~Gaussian function ℓ
based on the local curvature
StellarSpectraObservationFitting.estimate_σ_curvature_helper_finalizer!
— Methodestimate_σ_curvature_helper_finalizer!(σs, _ℓs, x_test, i; use_gradient=false, param_str="", print_every=10, verbose=false, show_plots=false)
Calculate uncertanties (filling σs
) based on the _ℓs
calculated at x_test
StellarSpectraObservationFitting.eval_regularization
— Methodeval_regularization(reg_fields, reg_key, reg_val, mws, training_inds, testing_inds; kwargs...)
Setting regularizaiton values for a copy of mws.om
then training it on the training data and evaluating _loss()
on the testing data after optimizing the RVs and scores
StellarSpectraObservationFitting.fill_OrderModel!
— Methodfill_OrderModel!(om1, om2, inds_tel, inds_star)
Replace the models in om1
with those in om2
StellarSpectraObservationFitting.fill_StarModel!
— Methodfill_StarModel!(om, lm; inds=2:size(lm.M, 2))
Replace the stellar model in om
with lm
StellarSpectraObservationFitting.fill_TelModel!
— Methodfill_TelModel!(om, lm)
Replace the telluric model in om
with lm
StellarSpectraObservationFitting.finalize_scores!
— Methodfinalize_scores!(score_trainer, mws)
Run score_trainer
and update the output in mws
StellarSpectraObservationFitting.finalize_scores!
— Methodfinalize_scores!(mws; kwargs...)
Optimize the scores in mws
StellarSpectraObservationFitting.finalize_scores_setup
— Methodfinalize_scores_setup(mws; verbose=_verbose_def, f_tol=_f_reltol_def_s, g_tol=_g_L∞tol_def_s, careful_first_step=true, speed_up=false, kwargs...)
Create a function that optimizes the model scores with Optim
StellarSpectraObservationFitting.first_iterate!
— Methodfirst_iterate!(l, l0, θs, θ, ∇θ, opt; ind=[], verbose=false)
Perform an ADAM optimization step based on the contents of opt
on θ
and decreases the learning rate to ensure the loss actually decreases
StellarSpectraObservationFitting.fit_regularization!
— Methodfit_regularization!(mws, testing_inds; key_list=_key_list_fit, share_regs=false, kwargs...)
Fit all of the regularization values in key_list
for the model in mws
StellarSpectraObservationFitting.fit_regularization!
— Methodfit_regularization!(mws; verbose=true, testing_ratio=0.33, careful_first_step=true, speed_up=false, kwargs...)
Find the best fit model without regularization then fit all of the regularization values in key_list
for the model in mws
StellarSpectraObservationFitting.fit_regularization_helper!
— Methodfit_regularization_helper!(reg_fields, reg_key, before_ℓ, mws, training_inds, testing_inds, test_factor, reg_min, reg_max; start=10e3, cullable=Symbol[], robust_start=true, thres=8, kwargs...)
Setting reg_key
values in each Dict in mws.om.x (where x is each symbol in $reg_fields$) for a copy of mws.om
then training it on the training data and evaluating _loss()
on the testing data after optimizing the RVs and scores
StellarSpectraObservationFitting.flip_feature_vectors!
— Methodflip_feature_vectors!(lm)
Make each feature vector's median value negative
StellarSpectraObservationFitting.get_marginal_GP
— Methodget_marginal_GP(finite_GP, ys, xs)
Marginalizes a TemporalGPs GP on ys
and xs
StellarSpectraObservationFitting.get_mean_GP
— Methodget_mean_GP(finite_GP, ys, xs)
Gets the mean of the posterior of a TemporalGPs GP
StellarSpectraObservationFitting.gp_Δℓ
— Methodgp_Δℓ(y, A_k, Σ_k, H_k, P∞; kwargs...)
Calculate the gradient of gp_ℓ()
w.r.t. y
StellarSpectraObservationFitting.gp_Δℓ_coefficients
— Methodgp_Δℓ_coefficients(n, A_k, Σ_k; H_k=H_k, P∞=P∞, sparsity=0, kwargs...)
Precalculate coefficients that can be used to calculate gradient of gp_ℓ()
w.r.t. y
StellarSpectraObservationFitting.gp_Δℓ_helper_K
— Methodgp_Δℓ_helper_K(n, A_k, Σ_k, H_k, P∞; σ²_meas=_σ²_meas_def)
Precalculate all of the K
matrices for at each time
StellarSpectraObservationFitting.gp_Δℓ_helper_γ
— Methodgp_Δℓ_helper_γ(y, A_k, Σ_k, H_k, P∞; σ²_meas=_σ²_meas_def)
Precalculate all of the γ
values for at each time
StellarSpectraObservationFitting.gp_ℓ
— Methodgp_ℓ(y, A_k, Σ_k; σ²_meas=_σ²_meas_def, H_k=H_k, P∞=P∞)
Getting the posterior likelihood that y
is from a LTISDE described by A_k
and Σ_k
, equivalent to a GP
StellarSpectraObservationFitting.gp_ℓ_nabla
— Methodgp_ℓ_nabla(y, A_k, Σ_k; σ²_meas=_σ²_meas_def, H_k=H_k, P∞=P∞)
Getting the posterior likelihood that y
is from a LTISDE described by A_k
and Σ_k
, equivalent to a GP. Same as gp_ℓ()
but removing things that Nabla doesn't like
StellarSpectraObservationFitting.gp_ℓ_precalc
— Methodgp_ℓ_precalc(ℓ_coeff, x, A_k, Σ_k; kwargs...)
A version of gp_ℓ()
using the coefficients calculated by gp_Δℓ_coefficients()
StellarSpectraObservationFitting.improve_initial_model!
— Methodimprove_initial_model!(mws; careful_first_step=true, speed_up=false, kwargs...)
Train the model in mws
with an extra step to ensure we are at a local maximum for the scores and RVs Defaults to taking a careful first step
StellarSpectraObservationFitting.improve_model!
— Methodimprove_model!(mws; verbose=true, kwargs...)
Train the model in mws
with an extra step to ensure we are at a local maximum for the scores and RVs
StellarSpectraObservationFitting.insert_and_dedup!
— Method insert_and_dedup!(v, x)
Insert x
into sorted list v
without duplicates
StellarSpectraObservationFitting.intra_night_std
— Methodintra_night_std(rvs, times; thres=3, show_warn=true)
Calculates the intra-night std for rvs
time series observed at times
(in days)
StellarSpectraObservationFitting.iterate!
— Methoditerate!(θ, ∇θ, opt)
Perform an ADAM optimization step based on the contents of opt
on θ
StellarSpectraObservationFitting.log_lm
— MethodWhether a LinearModel is log linear
StellarSpectraObservationFitting.loss_func
— Methodloss_func(mws; include_priors=false)
Create a loss function for the model and data in mws
StellarSpectraObservationFitting.loss_funcs_frozen_tel
— Methodloss_funcs_frozen_tel(o, om, d)
Create loss functions for changing - the stellar templates, features, and scores and telluric scores - the telluric and stellar scores and RVs
Used to fit models with a set telluric model
StellarSpectraObservationFitting.loss_funcs_telstar
— Methodloss_funcs_telstar(o, om, d)
Create loss functions for changing - the telluric and stellar templates, features, and scores - the telluric and stellar scores - the RVs
Used to fit scores efficiently with L-BFGS
StellarSpectraObservationFitting.loss_funcs_total
— Methodloss_funcs_total(o, om, d)
Create loss functions for changing - the telluric and stellar templates, features, and scores - the telluric and stellar scores and RVs
Used to fit models with ADAM
StellarSpectraObservationFitting.mask!
— Methodmask!(var, bad_inds; using_weights=false)
Setting var
to reflect that the pixels at bad_inds
should be masked
StellarSpectraObservationFitting.mask_stellar_feature!
— Methodmask_stellar_feature!(var, log_λ_star, log_λ_low, log_λ_high; verbose=true, inverse=false, kwargs...)
Masking where log_λ_star
is between (or outside if inverse
=true) log_λ_low
and log_λ_high
StellarSpectraObservationFitting.mask_stellar_pixel!
— Methodmask_stellar_pixel!(var, log_λ_star, log_λ_star_bounds, i; padding=0, verbose=true, kwargs...)
Masking a pixel in the stellar frame to prevent different lines from coming in at different times
StellarSpectraObservationFitting.mask_telluric_feature!
— Methodmask_stellar_feature!(var, log_λ_obs, log_λ_star, log_λ_low, log_λ_high; verbose=true, include_bary_shifts=true, kwargs...)
Masking where log_λ_obs
is between log_λ_low
and log_λ_high
. Can also perform in the stellar frame to prevent different lines from coming in at different times with include_bary_shifts
StellarSpectraObservationFitting.model_prior
— Methodmodel_prior(lm, om, key)
Calulate the model prior on lm
with the regularization terms in om.reg_
* key
StellarSpectraObservationFitting.model_s_prior
— Methodmodel_s_prior(s, reg)
Add an L2 term to the scores if there are any regularization terms applied to the feature vectors
StellarSpectraObservationFitting.no_tellurics
— Methodno_tellurics(model)
Figure out whether a model
uses its telluric model
StellarSpectraObservationFitting.opt_funcs
— Methodopt_funcs(loss, pars)
Create an objective object for Optim from loss
that uses a flattened verison of pars
StellarSpectraObservationFitting.oversamp_interp_helper
— Methodoversamp_interp_helper(to_bounds, from_x)
Finding the coefficients to integrate the model between observed pixel bounds
StellarSpectraObservationFitting.ratio_clarifier_string
— Methodratio_clarifier_string(ratio)
Convert ratio
to a nice 3 digit-rounded string
StellarSpectraObservationFitting.recalc_total!
— Methodrecalc_total!(o, d)
Recalulates the current outputs for the total model at the observed wavelengths
StellarSpectraObservationFitting.remove_lm_score_means!
— Methodremove_lm_score_means!(lm; prop=0.)
Recenter the scores in lm
around 0
StellarSpectraObservationFitting.reset_regularization!
— Methodreset_regularization!(om)
Reset all of the keys in the regularization Dicts to the default values
StellarSpectraObservationFitting.rm_GP_regularization!
— Methodrm_GP_regularization!(om)
Remove all of the GP keys in the regularization Dicts
StellarSpectraObservationFitting.rm_dict!
— Methodrm_dict!(d, key_start)
Remove all keys starting with key_start
in a Dict
StellarSpectraObservationFitting.rm_dict!
— Methodrm_dict!(d)
Remove all keys in a Dict
StellarSpectraObservationFitting.rm_regularization!
— Methodrm_regularization!(om)
Remove all of the keys in the regularization Dicts
StellarSpectraObservationFitting.rv_model
— Methodrv_model(om; lm=om.rv.lm)
Gets RV model interpolated onto the observed wavelengths (used by OrderModelDPCA)
StellarSpectraObservationFitting.rv_to_D
— Methodrv_to_D(v)
Approximately converting an RV to a Doppler shift D ≡ log(λ1/λ0)
in log-wavelength space using (λ1-λ0)/λ0 = λ1/λ0 - 1 = e^D - 1 ≈ β = v / c
(with an extra negative sign from somewhere)
StellarSpectraObservationFitting.rvs
— Methodrvs(model)
Get RVs (in m/s) from an OrderModel The negative sign is only in the DPCA version because of how SSOF was originally coded
StellarSpectraObservationFitting.scale_α_helper!
— Methodscale_α_helper!(opt, α_ratio, θ, α, scale_α)
Optionally scale opt.α
based on the amplitudes in θ
StellarSpectraObservationFitting.shared_attention
— Methodshared_attention(M)
Ad-hoc regularization that punishes feature vectors with power in the same place
StellarSpectraObservationFitting.spectra_interp
— Methodspectra_interp(model_flux, rvs, sih)
Interpolate the stellar model to the data using the lower inds in sih
StellarSpectraObservationFitting.spectra_interp
— Methodspectra_interp(model, interp_helper)
Interpolates model
using the interoplation described by interp_helper
StellarSpectraObservationFitting.speed_up_iterate!
— Methodspeed_up_iterate!(l, θs, θ, ∇θ, opt; ind=[], verbose=false)
Perform an ADAM optimization step based on the contents of opt
on θ
and increases the learning rate to attempt to speed up the optimization
StellarSpectraObservationFitting.star_model
— Methodstar_model(om; lm=om.star.lm)
Gets stellar model interpolated onto the observed wavelengths
StellarSpectraObservationFitting.star_prior
— Methodstar_prior(om)
Calulate the stellar model prior on om.star.lm
with the regularization terms in om.star_tel
StellarSpectraObservationFitting.tel_model
— Methodtel_model(om; lm=om.tel.lm)
Gets telluric model interpolated onto the observed wavelengths
StellarSpectraObservationFitting.tel_prior
— Methodtel_prior(om)
Calulate the telluric model prior on om.tel.lm
with the regularization terms in om.reg_tel
StellarSpectraObservationFitting.total_length
— Methodtotal_length(mws)
Calculates the number of parameters of mws
StellarSpectraObservationFitting.total_model
— Methodtotal_model(tel, star)
Multiply the telluric and stellar models
StellarSpectraObservationFitting.train_OrderModel!
— Methodtrain_OrderModel!(mws; ignore_regularization=false, verbose=_verbose_def, shift_scores=true, μ_positive=true, tel_μ_lt1=false, rm_doppler=true, kwargs...)
Train the model in mws
with some optional modifications to the optimization (ignoreregularization, shiftscore, μpositive, telμlt1, rmdoppler)
StellarSpectraObservationFitting.train_OrderModel!
— Methodtrain_OrderModel!(ow::OptimTelStarWorkspace; verbose=_verbose_def, iter=_iter_def, f_tol=_f_reltol_def, g_tol=_g_L∞tol_def, train_telstar=true, ignore_regularization=false, μ_positive=false, careful_first_step=true, speed_up=false, kwargs...)
Train the model in ow
, training the telluric and stellar parameters, then the RVs
StellarSpectraObservationFitting.train_OrderModel!
— Methodtrain_OrderModel!(ow::OptimTelStarWorkspace; verbose=_verbose_def, iter=_iter_def, f_tol=_f_reltol_def, g_tol=_g_L∞tol_def, train_telstar=true, ignore_regularization=false, μ_positive=false, careful_first_step=true, speed_up=false, kwargs...)
Train the model in ow
, training the telluric and stellar parameters, then the RVs
StellarSpectraObservationFitting.train_SubModel!
— Methodtrain_SubModel!(aws; iter=_iter_def, f_reltol=_f_reltol_def, g_reltol=_g_reltol_def, g_L∞tol=_g_L∞tol_def, cb=(as::AdamState)->(), careful_first_step=true, speed_up=false, kwargs...)
Train the model parameters in aws
for up to iter
Adam iterations until it converges based on check_converged()
StellarSpectraObservationFitting.train_rvs_optim!
— Methodtrain_rvs_optim!(rv_ws, rv, optim_cb; g_tol=_g_L∞tol_def_s, f_tol=_f_reltol_def_s, iter=_iter_def, ignore_regularization=false, μ_positive=false, kwargs...)
Train the RVs from the rv_ws
with Optim
StellarSpectraObservationFitting.undersamp_interp_helper
— Methodundersamp_interp_helper(to_x, from_x)
Finding the coefficients to linear interpolate the model at observed pixel locations
StellarSpectraObservationFitting.update!
— Methodupdate!(aws; careful_first_step=true, speed_up=false)
Perform an ADAM optimization step for the model parameters in aws
StellarSpectraObservationFitting.update_interpolation_locations!
— Methodupdate_interpolation_locations!(om, d; use_mean=false)
Make sure the linear iterpolation locations for going from the stellar model to the data are correct as the RVs change
StellarSpectraObservationFitting.zero_regularization
— Methodzero_regularization(om; include_L1_factor=false)
Zero-out all of the keys in the regularization Dicts
StellarSpectraObservationFitting.Δℓ_precalc
— Methodgp_ℓ_precalc(ℓ_coeff, x, A_k, Σ_k; kwargs...)
Calculate the gradient of gp_ℓ_precalc()
w.r.t. y
StellarSpectraObservationFitting.ℓ
— MethodGaussian log-likelihood function
StellarSpectraObservationFitting.ℓ_prereqs
— Methodℓ_prereqs(vars)
Calculate some terms needed to calculate the log-likelihood