Sgp4Ex (Sgp4Ex v0.1.1)

View Source

SGP4 propagation module for Elixir.

Summary

Functions

Parse a TLE (Two-Line Element) set into a TLE struct. The TLE consists of two lines, each with a specific format.

Propagate a TLE to a specific epoch using the SGP4 algorithm. The epoch is the time to which the TLE should be propagated.

Functions

parse_tle(line1, line2)

@spec parse_tle(String.t(), String.t()) ::
  {:ok, Sgp4Ex.TLE.t()} | {:error, String.t()}

Parse a TLE (Two-Line Element) set into a TLE struct. The TLE consists of two lines, each with a specific format.

Parameters

  • line1: The first line of the TLE.
  • line2: The second line of the TLE.

Returns

  • {:ok, TLE.t()}: The parsed TLE struct.
  • {:error, String.t()}: An error message if the parsing fails.

Example

iex> line1 = "1 25544U 98067A   21275.54791667  .00001264  00000-0  39629-5 0  9993"
iex> line2 = "2 25544  51.6456  23.4367 0001234  45.6789 314.3210 15.48999999    12"
iex> Sgp4Ex.parse_tle(line1, line2)
{:ok, %Sgp4Ex.TLE{...}}

propagate_tle_to_epoch(tle, epoch)

@spec propagate_tle_to_epoch(Sgp4Ex.TLE.t(), DateTime.t()) ::
  {:ok, Sgp4Ex.TemeState.t()} | {:error, String.t()}

Propagate a TLE to a specific epoch using the SGP4 algorithm. The epoch is the time to which the TLE should be propagated.

Parameters

  • tle: The TLE data structure containing the satellite's orbital elements.
  • epoch: The epoch to which the TLE should be propagated.

Returns

  • {:ok, TemeState.t()}: The propagated Teme state of the satellite.
  • {:error, String.t()}: An error message if the propagation fails.

Example

iex> tle = Sgp4Ex.parse_tle(
...>   line1: "1 25544U 98067A   21275.54791667  .00001264  00000-0  39629-5 0  9993",
...>   line2: "2 25544  51.6456  23.4367 0001234  45.6789 314.3210 15.48999999    12"
...> )
iex> epoch = ~U[2021-10-02T14:00:00Z]
iex> Sgp4Ex.propagate_tle_to_epoch(tle, epoch)
{:ok, %Sgp4Ex.TemeState{position: {x, y, z}, velocity: {vx, vy, vz}}}