Skip to content

Commit

Permalink
Fix bug with sorting eigenvectors in eps_non_dc; update docstring
Browse files Browse the repository at this point in the history
- Calling sort on the eigenvalues from eigen() for an
  MT{<:Measurements.Measurement} led to an error.  Remove the call
  to sort() since eigen() by default sorts the eigenvalues in
  ascending order.
- Update the docstring for decompose() to reflect the actual output.
  • Loading branch information
anowacki committed Nov 21, 2019
1 parent b0bccc8 commit bc5549b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "MomentTensors"
uuid = "7bb32750-d21c-11e8-1ebc-09158bc70490"
authors = ["Andy Nowacki <a.nowacki@leeds.ac.uk>"]
version = "0.2.3"
version = "0.2.4"

[compat]
julia = "0.7, 1"
Expand Down
14 changes: 9 additions & 5 deletions src/MomentTensors.jl
Expand Up @@ -399,7 +399,8 @@ where the eigenvalues of the moment tensor are λ₁ ≥ λ₂ ≥ λ₃.
Observation North-Holland, Amsterdam, Theory and Interpretation, pp. 345-353.
"""
function eps_non_dc(m::MT)
λ = sort(eigen(Symmetric(_matrix(m))).values)
# eigen returns eigenvalues sorted by default
λ = eigen(Symmetric(_matrix(m))).values
-λ[2]/max(abs(λ[1]), abs(λ[3]))
end

Expand Down Expand Up @@ -446,11 +447,14 @@ struct MTDecomposition{T<:Number}
end

"""
decompose(m::MT) -> m_iso, m_dev, m_dc, m_clvd
decompose(m::MT) -> iso, dev, dc, clvd, m0_iso, m0_dev, prop_iso, prop_dev, prop_dc, prop_clvd, m0
Decompose the arbitrary moment tensor `m` into its isotropic, `m_iso`,
and deviatoric parts, `m_dev`, plus the CLVD, `m_clvd`, and double-couple,
`m_dc`, components
Decompose the arbitrary moment tensor `m` into its isotropic, `iso`,
and deviatoric parts, `dev`, plus the CLVD, `clvd`, and double-couple,
`dc`, components. The proportion of the moment tensor represented by
the isotropic, deviatoric, double-couple and CLVD components are
given respectively by `prop_iso`, `prop_dev`, `prop_dc` and `prop_clvd`.
The scalar moment in Nm is given by `m0`.
"""
function decompose(m::MT{T}) where T
tr = m[1] + m[2] + m[3]
Expand Down
1 change: 1 addition & 0 deletions test/decompose.jl
Expand Up @@ -22,5 +22,6 @@ using MomentTensors, Test
@test d.prop_clvd 0.32 atol=0.01
@test d.m0 14.9031089939
@test mw(d.m0) -5.25114874821
@test eps_non_dc(m) -0.34250995536253115
end
end

0 comments on commit bc5549b

Please sign in to comment.