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 support for matching IDs to RME's reef list position index #9

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ReefModEngine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export

# Convenience/utility methods
export
reef_ids, deployment_area, set_outplant_deployment!
reef_ids, deployment_area, set_outplant_deployment!,
match_id, match_ids

# IO
export
Expand Down
43 changes: 42 additions & 1 deletion src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,45 @@ function reef_ids()::Vector{String}
end

return reef_id_list
end
end

"""
match_id(id::String)::Int64
match_ids(ids::Vector{String})::Vector{Int64}

Find matching index position for the given ID(s) according to ReefMod Engine's reef list.

# Note

ReefMod Engine's reef list is in all upper case. The provided IDs are converted to
upper case to ensure a match.

# Examples

```julia
julia> reef_ids()
# 3806-element Vector{String}:
# "10-330"
# "10-331"
# ⋮
# "23-048"
# "23-049"

julia> match_id("10-330")
# 1

julia> match_id("23-049")
# 3806

julia> match_ids(["23-048", "10-331"])
# 3805
# 2
```
"""
function match_id(id::String)::Int64
rme_ids = reef_ids()
return findfirst(==(uppercase(id)), rme_ids)
end
function match_ids(ids::Vector{String})::Vector{Int64}
return match_id.(ids)
end
Loading