CCF Demonstration
Use Espresso G2 mask:
Central λ to plot
v Shift CCF Mask:
CCF v range:
Parameters
begin
scale_factor = 1.0; # To make things easier to see
end;
begin
c = 3e8 # m/s Speed of light
σ_sol = 7.2e3 # m/s
Δv = scale_factor*600 # m/s Pixel spacing
σ_logλ = scale_factor * σ_sol / c # dimensionless width of spectral lines
end;
begin
mask_Δlogλ = mask_width_factor * Δv/c # width of CCF entries
δv = Δv/2 # m/s Spacing of CCF evaluations
end;
Calculations
begin
λ_min = λ_central - Δλ_plt/2
λ_max = λ_central + Δλ_plt/2
end;
λ = exp.(range(log(λ_min),log(λ_max),step=Δv/c));
if use_espresso
mask_λs = espresso_mask_λ[mask_mask]
mask_depths = espresso_mask_depth[mask_mask]
else
regen_spectrum
mask_λs = sort(rand(Uniform(λ_min,λ_max),num_lines))
mask_depths = rand(Uniform(0,1),num_lines)
end;
mask_mask = map(λ->λ_min<=λ<=λ_max,espresso_mask_λ);
flux = calc_spectrum(λ,mask_λs,mask_depths,σ_logλ);
begin
mask_plt = calc_mask(λ,mask_λs,mask_depths,mask_Δlogλ,v_plt);
ccf_at_v_plt = sum(mask_plt.*flux);
end
7.120441309102656
v_grid = range(-v_lim,stop=v_lim, step=δv);
ccf = calc_ccf(v_grid, λ, flux, mask_λs,mask_depths,mask_Δlogλ);
Functions
function mask_entry(λ::AbstractVector, λc::Real, depth::Real, Δlogλ::Real)
ifelse.(abs.(λ.-λc) .<= Δlogλ * λc, depth, zero(depth))
end
mask_entry (generic function with 1 method)
function line(λ::AbstractVector, λc::Real, depth::Real, σ::Real)
1.0 .- depth .* exp.(-0.5/σ^2 .* (λ.-λc).^2 )
end
line (generic function with 1 method)
function calc_mask(λ::AbstractVector, λcs::AbstractVector, depths::AbstractVector, sigma_logλ::Real, v::Real)
@assert length(λcs) == length(depths)
n = length(λcs)
c::Float64
mapreduce(i->mask_entry(λ,λcs[i]*(1+v/c),depths[i],mask_Δlogλ),.+,1:n, init=zeros(length(λ)))
end
calc_mask (generic function with 1 method)
function calc_spectrum(λ::AbstractVector, λcs::AbstractVector, depths::AbstractVector, sigma_logλ::Real)
@assert length(λcs) == length(depths)
n = length(λcs)
mapreduce(i->line(λ,λcs[i],depths[i],λcs[i]*sigma_logλ),.*,1:n,init=ones(length(λ)))
end
calc_spectrum (generic function with 1 method)
function calc_ccf(v_grid, λ, flux, mask_λs,mask_depths,sigma_logλ)
map(v-> sum(flux.*calc_mask(λ,mask_λs,mask_depths,sigma_logλ,v)),
v_grid)
end
calc_ccf (generic function with 1 method)
Setup
begin
using Distributions
using Plots, LaTeXStrings
using PlutoUI, PlutoTeachingTools
end
TableOfContents()
begin
mask_fn = "G2.espresso.mas"
if !(filesize(mask_fn)>0)
download("https://raw.githubusercontent.com/RvSpectML/EchelleCCFs.jl/main/data/masks/G2.espresso.mas", mask_fn)
end
end;
begin
local tmp = stack(l->parse.(Float64,split(l," ")), readlines(mask_fn))'
espresso_mask_λ = tmp[:,1]
espresso_mask_depth = tmp[:,2]
end;
Built with Julia 1.11.1 and
Distributions 0.25.112LaTeXStrings 1.3.1
Plots 1.40.8
PlutoTeachingTools 0.2.15
PlutoUI 0.7.60
To run this notebook locally, download this file and open it with Pluto.jl.