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

line_list argument not used in function #46

Open
hematthi opened this issue May 21, 2022 · 2 comments
Open

line_list argument not used in function #46

hematthi opened this issue May 21, 2022 · 2 comments
Labels
invalid This doesn't seem right

Comments

@hematthi
Copy link
Collaborator

function make_λ_list_for_bad_columns(line_list::DataFrame, harps_data::DT ) where {
T1<:Real, A1<:AbstractArray{T1}, T2<:Real, A2<:AbstractArray{T2}, T3<:Real, A3<:AbstractArray{T3},
IT<:HARPS.AnyHARPS, ST<:Spectra2DBasic{T1,T2,T3,A1,A2,A3,IT}, DT<:AbstractArray{ST,1} }
order_list = 1:size(first(harps_data).λ,2)
df_bad_col_λs = DataFrame(:order=>Int[], :lambda_lo=>Float64[], :lambda_hi=>Float64[])
for order in order_list
λ_extrema = NaNMath.extrema(first(harps_data).λ[:,order])
if isnan(first(λ_extrema)) || isnan(last(λ_extrema)) continue end
for bcr in bad_col_ranges(HARPS2D(), order)
pixlo = first(bcr)
pixhi = pixlo + 1
if pixhi > size(first(harps_data).λ,1)
pixhi -= 1
pixlo -= 1
end
doppler_factors = map(obsid-> haskey(harps_data[obsid].metadata,:doppler_factor) ? harps_data[obsid].metadata[:doppler_factor] : 1 , 1:length(harps_data))
Δλ_pixel = (first(harps_data).λ[pixhi,order] - first(harps_data).λ[pixlo,order]) * doppler_factors[1]
(λ_lo, λ_hi) = mapreduce(obsid->extrema(harps_data[obsid].λ[bcr,order]) .* doppler_factors[obsid],
(a,b) -> (min(a[1],b[1]), max(a[2],b[2])), 1:length(harps_data) )
λ_lo -= Δλ_pixel/2
λ_hi += Δλ_pixel/2
push!(df_bad_col_λs, Dict(:order=>order, :lambda_lo=>λ_lo, :lambda_hi=>λ_hi) )
end
end
return df_bad_col_λs
end

@hematthi
Copy link
Collaborator Author

Same for harps-n:

function make_λ_list_for_bad_columns(line_list::DataFrame, harpsn_data::DT ) where {
T1<:Real, A1<:AbstractArray{T1}, T2<:Real, A2<:AbstractArray{T2}, T3<:Real, A3<:AbstractArray{T3},
IT<:HARPSN.AnyHARPSN, ST<:Spectra2DBasic{T1,T2,T3,A1,A2,A3,IT}, DT<:AbstractArray{ST,1} }
order_list = 1:size(first(harpsn_data).λ,2)
df_bad_col_λs = DataFrame(:order=>Int[], :lambda_lo=>Float64[], :lambda_hi=>Float64[])
for order in order_list
λ_extrema = NaNMath.extrema(first(harpsn_data).λ[:,order])
if isnan(first(λ_extrema)) || isnan(last(λ_extrema)) continue end
for bcr in bad_col_ranges(HARPSN2D(), order)
pixlo = first(bcr)
pixhi = pixlo + 1
if pixhi > size(first(harpsn_data).λ,1)
pixhi -= 1
pixlo -= 1
end
doppler_factors = map(obsid-> haskey(harpsn_data[obsid].metadata,:doppler_factor) ? harpsn_data[obsid].metadata[:doppler_factor] : 1 , 1:length(harpsn_data))
Δλ_pixel = (first(harpsn_data).λ[pixhi,order] - first(harpsn_data).λ[pixlo,order]) * doppler_factors[1]
(λ_lo, λ_hi) = mapreduce(obsid->extrema(harpsn_data[obsid].λ[bcr,order]) .* doppler_factors[obsid],
(a,b) -> (min(a[1],b[1]), max(a[2],b[2])), 1:length(harpsn_data) )
λ_lo -= Δλ_pixel/2
λ_hi += Δλ_pixel/2
push!(df_bad_col_λs, Dict(:order=>order, :lambda_lo=>λ_lo, :lambda_hi=>λ_hi) )
end
end
return df_bad_col_λs
end

@hematthi hematthi added the invalid This doesn't seem right label May 23, 2022
@hematthi
Copy link
Collaborator Author

Same for neid:

function make_λ_list_for_bad_columns(line_list::DataFrame, neid_data::DT ) where {
T1<:Real, A1<:AbstractArray{T1}, T2<:Real, A2<:AbstractArray{T2}, T3<:Real, A3<:AbstractArray{T3},
IT<:NEID.AnyNEID, ST<:Spectra2DBasic{T1,T2,T3,A1,A2,A3,IT}, DT<:AbstractArray{ST,1} }
order_list = 1:size(first(neid_data).λ,2)
df_bad_col_λs = DataFrame(:order=>Int[], :lambda_lo=>Float64[], :lambda_hi=>Float64[])
for order in order_list
λ_extrema = NaNMath.extrema(first(neid_data).λ[:,order])
if isnan(first(λ_extrema)) || isnan(last(λ_extrema)) continue end
for bcr in bad_col_ranges(NEID2D(), order)
pixlo = first(bcr)
pixhi = pixlo + 1
if pixhi > size(first(neid_data).λ,1)
pixhi -= 1
pixlo -= 1
end
doppler_factors = map(obsid-> haskey(neid_data[obsid].metadata,:doppler_factor) ? neid_data[obsid].metadata[:doppler_factor] : 1 , 1:length(neid_data))
Δλ_pixel = (first(neid_data).λ[pixhi,order] - first(neid_data).λ[pixlo,order]) * doppler_factors[1]
(λ_lo, λ_hi) = mapreduce(obsid->extrema(neid_data[obsid].λ[bcr,order]) .* doppler_factors[obsid],
(a,b) -> (min(a[1],b[1]), max(a[2],b[2])), 1:length(neid_data) )
λ_lo -= Δλ_pixel/2
λ_hi += Δλ_pixel/2
push!(df_bad_col_λs, Dict(:order=>order, :lambda_lo=>λ_lo, :lambda_hi=>λ_hi) )
end
end
return df_bad_col_λs
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant