Skip to content

Commit

Permalink
📚 Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ronisbr committed May 24, 2024
1 parent 949746c commit bdac278
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 54 deletions.
3 changes: 1 addition & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
SatelliteToolboxGravityModels.jl
================================
# SatelliteToolboxGravityModels.jl

This package implements the support of gravity models for the **SatelliteToolbox.jl**
ecosystem. We can use it to obtain, for example, the gravitational acceleration to
Expand Down
3 changes: 1 addition & 2 deletions docs/src/man/api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
GravityModels API
=================
# GravityModels API

This document describes the API required for a gravity model. The user can add new models by
overloading the functions listed here.
Expand Down
85 changes: 35 additions & 50 deletions docs/src/man/usage.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
Usage
=====
# Usage

```@meta
CurrentModule = SatelliteToolboxGravityModels
DocTestSetup = quote
using SatelliteToolboxGravityModels
end
```

```@repl usage
using SatelliteToolboxGravityModels
```

## Initialization

We can initialize a gravity model using the function:

```julia
function load(::Type{T}, args...; kwargs...) where T<:AbstractGravityModel -> T
load(::Type{T}, args...; kwargs...) where T<:AbstractGravityModel -> T
```

where the arguments and keywords depend on the gravity model type `T`. For ICGEM files, we
must use `T = IcgemFile` and the following signature:

```julia
function GravityModels.load(::Type{IcgemFile}, filename::AbstractString, T::DataType = Float64)
GravityModels.load(::Type{IcgemFile}, filename::AbstractString, T::DataType = Float64)
```

where it loads the ICGEM file in the path `filename` converting the coefficients to the type
Expand All @@ -29,8 +29,8 @@ where it loads the ICGEM file in the path `filename` converting the coefficients
We also provide a function to help downloading the ICGEM files:

```julia
function fetch_icgem_file(url::AbstractString; kwargs...)
function fetch_icgem_file(model::Symbol; kwargs...)
fetch_icgem_file(url::AbstractString; kwargs...)
fetch_icgem_file(model::Symbol; kwargs...)
```

It fetches a ICGEM file from the `url` and return its file path to be parsed with the
Expand All @@ -50,26 +50,16 @@ supported values are:

Finally, we can initialize, for example, the EGM96 model using:

```julia-repl
julia> egm96 = GravityModels.load(IcgemFile, fetch_icgem_file(:EGM96))
IcgemFile{Float64}:
Product type : gravity_field
Model name : EGM96
Gravity constant : 3.986004415e14
Radius : 6.3781363e6
Maximum degree : 360
Errors : formal
Tide system : tide_free
Norm : fully_normalized
Data type : Float64
```@repl usage
egm96 = GravityModels.load(IcgemFile, fetch_icgem_file(:EGM96))
```

## Gravitational Field Derivative

The following function:

```julia
function gravitational_field_derivative(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number
gravitational_field_derivative(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number -> NTuple{3, T}
```

computes the gravitational field derivative [SI] with respect to the spherical coordinates:
Expand All @@ -82,14 +72,16 @@ using the `model` in the position `r` [m], represented in ITRF, at instant `time
latter argument is omitted, the J2000.0 epoch is used.

!!! info

In this case, $$\phi$$ is the geocentric latitude and $$\lambda$$ is the longitude.

The following keywords are available:

- `max_degree::Int`: Maximum degree used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than the available number of
coefficients in the `model`, it will be clamped. If it is lower than 0, it will be set
to the maximum degree available. (**Default** = -1)
to the maximum degree available.
(**Default** = -1)
- `max_order::Int`: Maximum order used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than `max_degree`, it will be clamped.
If it is lower than 0, it will be set to the same value as `max_degree`.
Expand All @@ -98,14 +90,15 @@ The following keywords are available:
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
coefficients, reducing the allocations. If it is `nothing`, the matrix will be created
when calling the function.
(**Default** = `nothing`)
- `dP::Union{Nothing, AbstractMatrix}`: An optional matrix that must contain at least
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
derivative coefficients, reducing the allocations. If it is `nothing`, the matrix will
be created when calling the function.
(**Default** = `nothing`)

```julia-repl
julia> GravityModels.gravitational_field_derivative(egm96, [6378.137e3, 0, 0])
(-9.814284376497435, 49.45906319417034, -115.71285105900459)
```@repl usage
GravityModels.gravitational_field_derivative(egm96, [6378.137e3, 0, 0])
```

## Gravitational Acceleration
Expand All @@ -114,7 +107,7 @@ The gravitational acceleration is the acceleration caused by the central body ma
i.e., without considering the centrifugal potential. We can compute it using the function:

```julia
function gravitational_acceleration(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number
gravitational_acceleration(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number -> NTuple{3, T}
```

where it returns the gravitational field acceleration [m / s²] represented in ITRF using the
Expand All @@ -126,7 +119,8 @@ The following keywords are available:
- `max_degree::Int`: Maximum degree used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than the available number of
coefficients in the `model`, it will be clamped. If it is lower than 0, it will be set
to the maximum degree available. (**Default** = -1)
to the maximum degree available.
(**Default** = -1)
- `max_order::Int`: Maximum order used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than `max_degree`, it will be clamped.
If it is lower than 0, it will be set to the same value as `max_degree`.
Expand All @@ -135,17 +129,15 @@ The following keywords are available:
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
coefficients, reducing the allocations. If it is `nothing`, the matrix will be created
when calling the function.
(**Default** = `nothing`)
- `dP::Union{Nothing, AbstractMatrix}`: An optional matrix that must contain at least
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
derivative coefficients, reducing the allocations. If it is `nothing`, the matrix will
be created when calling the function.
(**Default** = `nothing`)

```julia-repl
julia> GravityModels.gravitational_acceleration(egm96, [6378.137e3, 0, 0])
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
-9.814284376497435
-1.814210812013047e-5
7.754468615862334e-6
```@repl usage
GravityModels.gravitational_acceleration(egm96, [6378.137e3, 0, 0])
```

## Gravity Acceleration
Expand All @@ -154,7 +146,7 @@ The gravity acceleration is the compound acceleration caused by the central body
the centrifugal force due to the planet's rotation. We can compute it using the function:

```julia
function gravity_acceleration(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number
gravity_acceleration(model::AbstractGravityModel{T}, r::AbstractVector, time::DateTime = DateTime("2000-01-01"); kwargs...) where T<:Number -> NTuple{3, T}
```

where it computes the gravity acceleration [m / s²] represented in ITRF using the `model` in
Expand All @@ -166,7 +158,8 @@ The following keywords are available:
- `max_degree::Int`: Maximum degree used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than the available number of
coefficients in the `model`, it will be clamped. If it is lower than 0, it will be set
to the maximum degree available. (**Default** = -1)
to the maximum degree available.
(**Default** = -1)
- `max_order::Int`: Maximum order used in the spherical harmonics when computing the
gravitational field derivative. If it is higher than `max_degree`, it will be clamped.
If it is lower than 0, it will be set to the same value as `max_degree`.
Expand All @@ -175,29 +168,21 @@ The following keywords are available:
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
coefficients, reducing the allocations. If it is `nothing`, the matrix will be created
when calling the function.
(**Default** = `nothing`)
- `dP::Union{Nothing, AbstractMatrix}`: An optional matrix that must contain at least
`max_degree + 1 × max_degree + 1` real numbers that will be used to store the Legendre
derivative coefficients, reducing the allocations. If it is `nothing`, the matrix will
be created when calling the function.
(**Default** = `nothing`)

Thus, we can compute the gravity acceleration in Equator using the EGM96 model by:

```julia-repl
julia> egm96 = GravityModels.load(IcgemFile, fetch_icgem_file(:EGM96));
julia> GravityModels.gravitational_acceleration(egm96, [6378.137e3, 0, 0])
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
-9.814284376497435
-1.814210812013047e-5
7.754468615862334e-6
```@repl usage
egm96 = GravityModels.load(IcgemFile, fetch_icgem_file(:EGM96));
```

Whereas we can obtain the gravity acceleration at the poles by:

```julia-repl
julia> GravityModels.gravitational_acceleration(egm96, [0, 0, 6356.7523e3])
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
-6.12152785935481e-5
0.0
-9.83208158872835
```@repl usage
GravityModels.gravitational_acceleration(egm96, [0, 0, 6356.7523e3])
```

0 comments on commit bdac278

Please sign in to comment.