# Error in the code for calculating the final variogram, error in hermitian matrices

**URL:** <https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336>\
**Category:** New to Julia\
**Tags:** question, geostatistics\
**Created:** [January 10, 2022, 1:26pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336 "2022-01-10T13:26:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaquetdiamantino](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jaquetdiamantino](https://discourse.julialang.org/u/jaquetdiamantino)\
**Post date:** [January 10, 2022, 1:26pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/1 "2022-01-10T13:26:33Z")

</div>

I’m new to Julia and I’m trying to create a notebook that works with different geostatic methods, when I finish the code for calculating the final variogram this error appears:

begin

```
# Elipsoides de anisotropia (θ seguindo regra da mão esquerda)
ellipsoid₁ = Ellipsoid([rpri₁, rsec₁, rter₁], [azi, -dip, -θ], convention = GSLIB)

ellipsoid₂ = Ellipsoid([rpri₂, rsec₂, rter₂], [azi, -dip, -θ], convention = GSLIB)

# Estruturas do variograma final
γₒ = NuggetEffect(nugget = Float64(cₒ))

γ₁ = model[m](sill = Float64(c₁), distance = metric(ellipsoid₁))

γ₂ = model[m](sill = Float64(c₂), distance = metric(ellipsoid₂))

# Variograma final
γ = γₒ + γ₁ + γ₂

```

end;

The error would be this:

Only hermitian matrices are diagonalizable by _StaticArrays_. Non-Hermitian matrices should be converted to `Array` first.

1. **error** (::String)@ _error.jl:33_
2. **#eigvals#619** @ _eigen.jl:12_ [inlined]
3. **#eigmin#80** @ _eigen.jl:416_ [inlined]
4. **eigmin** @ _eigen.jl:416_ [inlined]
5. (::Distances.var"#Mahalanobis#5#6")(::Bool, ::Type{Distances.Mahalanobis}, ::StaticArrays.SMatrix{3, 3, Float64, 9})@ _mahalanobis.jl:28_
6. **Distances.Mahalanobis** (::StaticArrays.SMatrix{3, 3, Float64, 9})@ _mahalanobis.jl:26_
7. **var"#Ellipsoid#96"** (::Type{Meshes.GSLIB}, ::Type{Meshes.Ellipsoid}, ::Vector{Float64}, ::Vector{Float64})@ _ellipsoid.jl:41_
8. **top-level scope** @ _[Local: 4](http://localhost:1234/edit?id=edc6dfc0-7187-11ec-37ee-970ebb24f55e#)_ [inlined]

Could someone explain to me the reason for this error and how do I fix it for the code to process?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 10, 2022, 1:43pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/2 "2022-01-10T13:43:04Z")

</div>

Hi @jaquetdiamantino , this is an error that was fixed in more recent releases of the project. Can you please update to the latest release of GeoStats.jl v0.29.1 and use the new anisotropic model interface?

[https://juliaearth.github.io/GeoStats.jl/stable/variography/theoretical.html#Anisotropy](https://juliaearth.github.io/GeoStats.jl/stable/variography/theoretical.html#Anisotropy)

---

<div class="post-metadata">

**Author:** ![jaquetdiamantino](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jaquetdiamantino](https://discourse.julialang.org/u/jaquetdiamantino)\
**Post date:** [January 11, 2022, 5:05pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/3 "2022-01-11T17:05:53Z")

</div>

Hi, @juliohm. Thanks for the feedback. So, I updated the new version of the update on the notebook and made some changes, but I’m having trouble conveting the rotation. So far the code looks like this:

begin

```
ellipsoid₁ = MetricBall([range(fit_gpri),range(fit_gsec), range(fit_gter)], [azi, dip, θ])

	# Estruturas do variograma final
γₒ = NuggetEffect(nugget = Float64(fit_gdh.nugget))

γ₁ = SineHoleVariogram(ellipsoid₁, sill = Float64(fit_gdh.sill))

# Variograma final
γ = γₒ + γ₁ 

```

end

I saw that the EulerAngles function is used to make the conversion, but I am not able to apply it in the algorithm.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 11, 2022, 6:12pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/4 "2022-01-11T18:12:34Z")

</div>

Hi @jaquetdiamantino , what do you mean by apply the rotation in the algorithm?

---

<div class="post-metadata">

**Author:** ![jaquetdiamantino](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jaquetdiamantino](https://discourse.julialang.org/u/jaquetdiamantino)\
**Post date:** [January 11, 2022, 7:34pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/5 "2022-01-11T19:34:56Z")

</div>

Sorry, I used the wrong expression. It’s just that I’m working on a project of yours with Franco, and in the part of using a rotation convention, and defining the theoretical 3D variogram model, I wasn’t able to make the rotation convention of the GSLIB for the new function after the package update. But I think that now I get it, I used the GslibAngles function.

begin

```
ellipsoid₁ = MetricBall([range(fit_gpri),range(fit_gsec), range(fit_gter)], GslibAngles(azi, -dip, -θ))

	# Estruturas do variograma final
γₒ = NuggetEffect(nugget = Float64(fit_gdh.nugget))

γ₁ = SineHoleVariogram(ellipsoid₁, sill = Float64(fit_gdh.sill))

# Variograma final
γ = γₒ + γ₁ 

```

end

---

<div class="post-metadata">

**Author:** ![Larson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larson/32/32742_2.png) [@Larson](https://discourse.julialang.org/u/Larson)\
**Post date:** [January 13, 2022, 11:52am UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/6 "2022-01-13T11:52:44Z")

</div>

```julia
 plot(thisvgm, fitvgm2, main = paste0(Reduce(paste, deparse(FORMULAS[[MOD]] )), " range = 15"), ylim = c(0,1500),
         panel = function(x, ...) {
           panel = vgm.panel.xyplot(x, ...);
           panel.abline(h = c(fitvgm2$psill[1],sum(fitvgm2$psill)), v = fitvgm2$range[2])})

```

I have try this out[.](https://www.liteblue.app/)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 13, 2022, 12:00pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/7 "2022-01-13T12:00:45Z")

</div>

This is not Julia code @Larson , can you please explain why you are posting this random snippet in the thread?

---

<div class="post-metadata">

**Author:** ![jaquetdiamantino](https://avatars.discourse-cdn.com/v4/letter/j/3da27b/32.png) [@jaquetdiamantino](https://discourse.julialang.org/u/jaquetdiamantino)\
**Post date:** [January 18, 2022, 5:32pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/8 "2022-01-18T17:32:42Z")

</div>

Hi, @juliohm. After applying this code, post it here. I got the following answers:  
NestedVariogram{2} (anisotropic)  
structures  
└─NuggetEffect(nugget=0.06113842883173626)  
└─SineHoleVariogram(sill=0.22022981842719538, nugget=0.0, ranges=(161.74488721490707, 99.9464437260163, 57.37471854119326), metric=EulerAngles)  
coefficients  
└─1  
└─1  
So the metric = EulerAngles, which in my opinion I should have gotten the Mahalanobis metric. Is there any adjustment I should make more in this code?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 18, 2022, 6:23pm UTC](https://discourse.julialang.org/t/error-in-the-code-for-calculating-the-final-variogram-error-in-hermitian-matrices/74336/9 "2022-01-18T18:23:28Z")

</div>

Hi @jaquetdiamantino, EulerAngles is a rotation specification. Mahalanobis is a metric.

Can you please share the code you are using? Also, feel free to send me a direct message here or on Zulip in Portuguese if you find it easier. I can’t understand what you are trying to ask in English.
