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

add documentation and warnings for default values (address TODO) #78

Open
hematthi opened this issue Jun 1, 2022 · 2 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@hematthi
Copy link
Collaborator

hematthi commented Jun 1, 2022

function make_ccf_fits_header(metadata::AbstractDict; line_list_filename::Union{Nothing,String} = "unknown",
v::Union{Nothing,Float64} = nothing, e_v::Union{Nothing,Float64} = nothing,
blue_ord::Union{Nothing,Int64} = 118, red_ord::Union{Nothing,Int64} = 89, # TODO: WARNING: Hardwired
mask_shape::Union{Nothing,String} = "tophat", barycor::Union{Nothing,String} = "chromatic", # TODO: WARNING: Hardwired
ccord::Union{Nothing,Bool} = false, blazenorm::Union{Nothing,Bool} = false, contnorm::Union{Nothing,Bool} = true,
div_tell::Union{Nothing,Bool} = false, rawnorm::Union{Nothing,Bool} = nothing, plate_scale::Union{Nothing,Float64} = nothing,
)
# TODO: WARNING: several parameters, e.g., BLUE_ORD, RED_ORD, WINDOW, BARYCOR, PLATESCL, given default value above instead of defaulting to outputing nothing

rawnorm argument is also not used in this function

@hematthi hematthi added the documentation Improvements or additions to documentation label Jun 1, 2022
@hematthi
Copy link
Collaborator Author

hematthi commented Jun 1, 2022

Also add documentation for:

function write_ccf_fits(filename::String, v_grid::AbstractArray{T1,1}, ccf_total::AbstractArray{T2,1}, ccf_total_var::AbstractArray{T3,1};
orders::AbstractArray{T4,1}=zeros(Int64,0), ccf_orders::AbstractArray{T5,2}=zeros(T2,0,0), ccf_orders_var::AbstractArray{T6,2}=zeros(T3,0,0),
fits_hdr::FITSHeader,
#total_vel::Union{Nothing,Real} = nothing, sigma_total_vel::Union{Nothing,Real} = nothing,
order_vels::Union{Nothing,AbstractArray{T7,1}} = nothing, sigma_order_vels::Union{Nothing,AbstractArray{T8,1}} = nothing ) where {
T1<:Real, T2<:Real, T3<:Real, T4<:Real, T5<:Real, T6<:Real, T7<:Real, T8<:Real }
f = FITS(filename, "w")
#if isnothing(total_vel) || isnothing(sigma_total_vel)
write(f,UInt8[],header=fits_hdr,name="metadata")
#else
# write(f,UInt8[],header=fits_hdr,name="metadata",v=total_vel,e_V=sigma_total_vel)
#end
t2 = OrderedDict("V_grid"=>collect(v_grid),"ccf"=>ccf_total,"e_ccf"=>sqrt.(ccf_total_var) )
write(f,collect(keys(t2)),collect(values(t2)),name="ccf_total")
if length(orders) > 0 && length(ccf_orders) > 0 && length(ccf_orders_var) > 0
if isnothing(order_vels) || isnothing(sigma_order_vels)
t3 = OrderedDict("orders"=>convert.(Int64,orders),"ccfs"=>ccf_orders,"errs"=>sqrt.(ccf_orders_var) )
else
t3 = OrderedDict("orders"=>convert.(Int64,orders),"ccfs"=>ccf_orders,"errs"=>sqrt.(ccf_orders_var),
"v" => order_vels,"e_v" => sigma_order_vels)
end
write(f,collect(keys(t3)),collect(values(t3)),name="ccf_order")
end
close(f)
end

and clean up unused types

@hematthi
Copy link
Collaborator Author

hematthi commented Jun 1, 2022

And for:

function write_each_ccf_fits(metadata::AbstractArray{Dict{Symbol,Any},1}, v_grid::AbstractArray{T1,1}, ccf_total::AbstractArray{T2,2}, ccf_total_var::AbstractArray{T3,2};
orders::AbstractArray{T4,1}=zeros(Int64,0), ccf_orders::AbstractArray{T5,3}=zeros(T2,0,0,size(ccf_total,2)), ccf_orders_var::AbstractArray{T6,3}=zeros(T3,0,0,size(ccf_total,2)),
fits_hdr::FITSHeader, line_list_filename::Union{Nothing,String} = "unknown", # )
total_vel::Union{Nothing,AbstractArray{T7,1}} = nothing, sigma_total_vel::Union{Nothing,AbstractArray{T7,1}} = nothing,
order_vels::Union{Nothing,AbstractArray{T8,2}} = nothing, sigma_order_vels::Union{Nothing,AbstractArray{T8,2}} = nothing ) where {
T1<:Real, T2<:Real, T3<:Real, T4<:Real, T5<:Real, T6<:Real, T7<:Real, T8<:Real }
@assert length(metadata) == size(ccf_total,2) == size(ccf_total_var,2)
num_files = length(metadata)
for i in 1:num_files
fits_fn = last(splitpath(metadata[i][:Filename]))
ccf_fn = replace(fits_fn, ".fits" => "_ccf.fits")
if isnothing(total_vel) || isnothing(sigma_total_vel)
fits_hdr = make_ccf_fits_header(metadata[i], line_list_filename=line_list_filename)
else
fits_hdr = make_ccf_fits_header(metadata[i],v=total_vel[i],e_v=sigma_total_vel[i], line_list_filename=line_list_filename)
end
if isnothing(order_vels) || isnothing(sigma_order_vels)
write_ccf_fits(ccf_fn, v_grid, ccf_total[:,i], ccf_total_var[:,i],
orders=orders, ccf_orders=ccf_orders[:,:,i], ccf_orders_var=ccf_orders_var[:,:,i],
fits_hdr=fits_hdr)
else
@assert size(order_vels) == size(sigma_order_vels)
@assert size(order_vels,1) == num_files
@assert size(order_vels,2) == length(orders)
write_ccf_fits(ccf_fn, v_grid, ccf_total[:,i], ccf_total_var[:,i],
orders=orders, ccf_orders=ccf_orders[:,:,i], ccf_orders_var=ccf_orders_var[:,:,i],
fits_hdr=fits_hdr,
order_vels=order_vels[i,:], sigma_order_vels=sigma_order_vels[i,:] )
end
# break # WARNING: Aborts after one file for testing purposes
end
end

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