# Examples of analysis that can be done with SatelliteToolbox.jl

**URL:** <https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330>\
**Category:** Astro/Space\
**Created:** [January 6, 2019, 6:15pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330 "2019-01-06T18:15:33Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 3, 2021, 3:48pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/21 "2021-09-03T15:48:43Z")

</div>

Yeap, so it seems thanks. Now up to find how to [TEME 2 ECEF](https://juliaspace.github.io/SatelliteToolbox.jl/stable/man/transformations/ecef_eci/), but only later tonigh.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 3, 2021, 11:45pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/22 "2021-09-03T23:45:30Z")

</div>

I guess I still need help on this. From my understanding of reading the docs one must compute a rotation matrix between the two reference frames and apply it. That’s what I try to do by adding these three steps

```julia
eop_IAU1980 = SatelliteToolbox.get_iers_eop()
rot = SatelliteToolbox.r_eci_to_ecef(SatelliteToolbox.TEME(), SatelliteToolbox.ITRF(), t[n], eop_IAU1980)
tt = reshape(r[n], 1,3) * rot

```

Now, what I see is that even at intervals of 60 seconds the rotation matrix changes a lot and the result or rotating the TEME vectors result in garbage. If I apply the same rotation to all points along the track, the result looks reasonable but still wrong.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 4, 2021, 4:50pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/23 "2021-09-04T16:50:51Z")

</div>

Hi @joa-quim !

The rotation between TEME and ITRF changes mainly with Earth’s rotation. That’s why you are seeing the difference in 60s. Hence, you need to compute the rotation matrix using `r_eci_to_ecef` at every step updating the Julian day.

What I do not understand in you example is why you are reshaping the vector. The result of `r_eci_to_ecef` is a DCM. Thus, you only need:

```julia
tt = rot * r

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 4, 2021, 5:01pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/24 "2021-09-04T17:01:06Z")

</div>

@Ronis_BR, I realized that I had an error in calculating the `t[n]`_s_ (they were not julian days) but I still do not get the correct result.

The reshaping is because Static arrays my be convenient for speed but they are a PITA when we need to send the data to C libs. GMT.jl doesn’t know what they are.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 4, 2021, 5:11pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/25 "2021-09-04T17:11:54Z")

</div>

But it seems you are computing `t’ * rot`, which does not provide the same result. Why not `Vector(rot * t)`?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 4, 2021, 5:45pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/26 "2021-09-04T17:45:13Z")

</div>

Yes, you are right, though I had to do `tt = rot * r[n]` because `tt = rot * r` errored with (I’m computing a single position)

```julia
ERROR: DimensionMismatch("Tried to multiply arrays of size (3, 3) and (1,)")

```

Now I get the same result as with the Matlab program. To help with the confusion, I cannot find the same locations as are being displayed in [this site](https://www.n2yo.com/satellite/?s=27424) (even used theirs TLE) but that’s not what I care. I’ll check again with [OceanColor](https://oceancolor.gsfc.nasa.gov/)’s data but that takes longer to find the precise instant.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 4, 2021, 6:01pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/27 "2021-09-04T18:01:25Z")

</div>

A bit better now 😄

 ![track](https://global.discourse-cdn.com/julialang/original/3X/6/c/6c35def320cb772728209771e2e137d4c37e0d1e.png)

_vs_

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/0/a02e6e53eb883973bc672fea04a0cd29d96b584e.jpeg)

---

<div class="post-metadata">

**Author:** ![helgee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgee/32/2022_2.png) [@helgee](https://discourse.julialang.org/u/helgee)\
**Post date:** [September 4, 2021, 7:53pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/28 "2021-09-04T19:53:46Z")

</div>

> [@joa-quim](#):
>
> The reshaping is because Static arrays my be convenient for speed but they are a PITA when we need to send the data to C libs. GMT.jl doesn’t know what they are.

Out of curiosity: What is the issue here? I remember that we had a problem with StaticArrays in ERFA.jl when I turned all `Ptr{Cdouble}` parameters to `Ref{Cdouble}`. But with the former StaticArrays work without problems, see here: [https://github.com/JuliaAstro/ERFA.jl/blob/main/test/runtests.jl#L38](https://github.com/JuliaAstro/ERFA.jl/blob/main/test/runtests.jl#L38)

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 4, 2021, 8:34pm UTC](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330/29 "2021-09-04T20:34:58Z")

</div>

Well, probably the transmission StaticArrays to the GMT dll could be solve but before that the data often has to be stored in a [GMTdataset](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/gmt_main.jl#L100) and the functions that create and use instances of it know nothing about StaticArrays. So having to deal with a

```julia
typeof(r) = Vector{StaticArrays.SVector{3, Float64}}

```

in the middle of trying out to figure out how to make the main task work was something I really didn’t to worry about. Fighting with types is tiring and often frustrating.

[Previous page](https://discourse.julialang.org/t/examples-of-analysis-that-can-be-done-with-satellitetoolbox-jl/19330.md?page=1)
