Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve documentation to describe different versions (e.g. ccf_vars) and all arguments #61

Open
hematthi opened this issue May 27, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@hematthi
Copy link
Collaborator

""" calc_normalized_ccfs( ccfs )
Normalizes each spectrum by fitting a line to the region outside the center
"""
function fit_ccf_normalizations( v_grid::A1, ccfs::A2; v_mid::Real, dv_min::Real = RvSpectMLBase.max_bc, dv_max::Real = Inf ) where {T1<:Real, A1<:AbstractArray{T1,1}, T2<:Real, A2<:AbstractArray{T2,2} }
@assert zero(dv_min) < dv_min < Inf
@assert dv_min < dv_max
idx = findall( x->dv_min < abs(x-v_mid) < dv_max , v_grid )
@assert length(idx) >= 2
map(col-> mean(ccfs[idx,col] ), 1:size(ccfs,2) )
end
function calc_normalized_ccfs( v_grid::A1, ccfs::A2; v_mid::Real, dv_min::Real = RvSpectMLBase.max_bc, dv_max::Real = Inf ) where {T1<:Real, A1<:AbstractArray{T1,1}, T2<:Real, A2<:AbstractArray{T2,2} }
norms = fit_ccf_normalizations(v_grid,ccfs,v_mid=v_mid,dv_min=dv_min, dv_max=dv_max)
ccfs_out = copy(ccfs)
for i in 1:size(ccfs,2)
ccfs_out[:,i] ./= norms[i]
end
return ccfs_out
end
function calc_normalized_ccfs( v_grid::A1, ccfs::A2, ccf_vars::A3; v_mid::Real, dv_min::Real = RvSpectMLBase.max_bc, dv_max::Real = Inf ) where {T1<:Real, A1<:AbstractArray{T1,1}, T2<:Real, A2<:AbstractArray{T2,2}, T3<:Real, A3<:AbstractArray{T3,2} }
norms = fit_ccf_normalizations(v_grid,ccfs,v_mid=v_mid,dv_min=dv_min, dv_max=dv_max)
ccfs_out = copy(ccfs)
ccf_vars_out = copy(ccf_vars)
for i in 1:size(ccfs,2)
ccfs_out[:,i] ./= norms[i]
ccf_vars_out[:,i] ./= norms[i]^2
end
return (ccfs=ccfs_out, ccf_vars=ccf_vars_out)
end
""" calc_normalized_ccfs( ccfs )
Normalizes each spectrum by its maximum value.
"""
function calc_normalized_ccfs( ccfs::A2 ) where {T2<:Real, A2<:AbstractArray{T2,2} }
return ccfs ./maximum(ccfs,dims=1)
end
function calc_normalized_ccfs( ccfs::A2, ccf_vars::A3 ) where { T2<:Real, A2<:AbstractArray{T2,2}, T3<:Real, A3<:AbstractArray{T3,2} }
max_ccfs = maximum(ccfs,dims=1)
ccfs_norm = ccfs ./ max_ccfs
ccf_vars_norm = ccf_vars ./ max_ccfs
return (ccfs=ccfs_norm, ccf_vars=ccf_vars_norm)
end

Also fit_ccf_normalizations should have its own docstring

@hematthi hematthi added the documentation Improvements or additions to documentation label May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant