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 for functions #30

Open
hematthi opened this issue May 19, 2022 · 0 comments
Open

add documentation for functions #30

hematthi opened this issue May 19, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@hematthi
Copy link
Collaborator

function calc_complement_index_ranges(idx_all::AR1, idx_bad::AA1 ) where { AR1 <: AbstractRange, AR2 <: AbstractRange, AA1 <: AbstractArray{AR2} }
function is_in_any_range(x::eltype(AR1), r::eltype(AA1) )
any(map(b->b.start<=x<=b.stop, idx_bad))
end
is_not_in_any_range(x::eltype(AR1), r::eltype(AA1) ) = !is_in_any_range(x,r)
idx_out = Array{typeof(idx_all),1}()
start = 0
stop = 0
while stop < last(idx_all)
start = findnext(x->is_not_in_any_range(x,idx_bad), idx_all,stop+1)
if start == nothing
break
end
stop = findnext(x->is_in_any_range(x,idx_bad), idx_all, start)
if stop == nothing
stop = length(idx_all)
else
stop -= 1
end
push!(idx_out,idx_all[start]:idx_all[stop])
end
return idx_out
end
function make_bad_pixel_list_into_ranges(x::V) where { T<:Integer, V<:AbstractVector{T} }
if length(x) == 0
return []
elseif length(x) == 1
return [x[1]:x[1]]
else
tmp = findall(x[2:end].-x[1:end-1].!=1)
pix_start = vcat( x[1], x[tmp.+1] )
pix_stop = vcat( x[tmp], x[length(x)] )
return map(p->p[1]:p[2], zip(pix_start,pix_stop) )
end
end

Also double check if intended to decrease stop in the while loop as in the line below?

@hematthi hematthi added documentation Improvements or additions to documentation help wanted Extra attention is needed labels May 23, 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 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant