Skip to content

Commit

Permalink
travel_times: Fix bug for empty pick names
Browse files Browse the repository at this point in the history
Also fix the link in the module docstring for Seis.jl.
  • Loading branch information
Andy Nowacki committed Jun 4, 2020
1 parent b172c77 commit 357cb96
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest.toml
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SeisTau"
uuid = "802e1830-4752-5daf-add9-2f2a4d2e763c"
authors = ["Andy Nowacki <a.nowacki@leeds.ac.uk>"]
version = "0.2.3"
version = "0.2.4"

[deps]
Geodesics = "6aaf26a4-c633-11e8-35ae-8904cb805353"
Expand Down
5 changes: 3 additions & 2 deletions src/SeisTau.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SeisTau
SeisTau integrates the [TauPy](https://github.com/anowacki/TauPy.jl) and
[Seis](ttps://github.com/anowacki/Seis.jl) packages, allowing one to easily
[Seis](https://github.com/anowacki/Seis.jl) packages, allowing one to easily
use seismic travel time predictions for 1D Earth models with `Seis.Trace`s,
`Seis.Event`s and `Seis.Station`s.
"""
Expand Down Expand Up @@ -107,7 +107,8 @@ end
Return the list of `TauPy.Phase`s associated with each travel time pick in `t`.
"""
travel_times(t::AbstractTrace; model::AbstractString="iasp91", sphere=false) =
[travel_time(t, name; model=model, sphere=sphere) for (_, name) in picks(t) if name[1] in ('p', 's', 'P', 'S')]
[travel_time(t, name; model=model, sphere=sphere)
for (_, name) in picks(t) if name !== missing && occursin(r"^[psPS]", name)]

"Throw an error if a Trace doesn't contain the right headers to call TauPy.travel_time."
_check_headers_taup(evt::GeogEvent, sta::GeogStation) = any(ismissing,
Expand Down
12 changes: 11 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ using Test, Seis, SeisTau
@test travel_times(t) == []
t.picks.P = (0, "P")
@test travel_times(t) == [travel_time(t, "P")]
t.picks.X = 1
t′ = deepcopy(t)
# Ignore unnamed picks
t′.picks.X = 1
@test travel_times(t′) == travel_times(t)
# Ignore empty but not missing names
t′.picks.S = 2, ""
@test travel_times(t′) == travel_times(t)
# Ignore picks with the wrong kind of name
t′.picks.sS = 3, "asS"
@test travel_times(t′) == travel_times(t)
end
@testset "Default phases" begin
@test travel_time(t) == travel_time(t, "ttall")
Expand All @@ -31,6 +40,7 @@ using Test, Seis, SeisTau
t.evt.lon, t.evt.lat, t.evt.dep = 0, 0, 0
t.sta.lon, t.sta.lat = 0, 80
@test path(t) == path(t, "ttall")
@test path(t) == path(t.evt, t.sta)
arr = path(t, "P")
@test length(arr) == 1
@test arr[1].name == "P"
Expand Down

0 comments on commit 357cb96

Please sign in to comment.