# API

This page is a dump of all the docstrings found in the code.

`EarthAlbedo.REFL`

— TypeREFL Structure for holding reflectivity data

`EarthAlbedo.albedo_per_cell`

— MethodInternal function that evaluates the albedo reflected by every cell.

Arguments:

- sat: Vector from center of Earth to satellite | SVector{3, Float64}
- refl_data: Matrix containing the averaged reflectivity data for current cell | Array{Float64, 2}
- cell_i: Latitude index of cell
- cell_j: Longitude index of cell
- sun_i: Latitude index of sun
- sun_j: Longitude index of sun
- num_lat: Number of latitude cells Earth's surface is divided into | Int
- num_lon: Number of longitude cells Earth's surface is divided into | Int
- Rₑ: (Optional) Average radius of the Earth (default is 6371010 m) | Scalar
- AM₀: (Optional) Solar irradiance (default is 1366.9) | Scalar

Returns:

- P_out: Cell albedo generated by current cell towards the satellite | Float64

`EarthAlbedo.cellarea`

— FunctionCalculate the area of a TOMS REFL Matrix cell for use in calculating Earth albedo.

Arguments:

- i: TOMS REFL Matrix latitude index of desired cell (0 < i ≤ sy) | Int
- j: TOMS REFL Matrix longitude index of desired cell (0 < j ≤ sx) | Int
- sy: Number of latitude cells in grid | Int
- sx: Number of longitude cells in grid | Int
- Rₑ: (Optional) Average radius of the Earth, defaults to meters | Scalar

Returns:

- A: Area of desired cell | Scalar

`EarthAlbedo.earth_albedo`

— MethodDetermines the Earth's albedo at a satellite for a given set of reflectivity data. First divides the Earth's surface into a set of cells (determined by the size of the refl data), and then determines which cells are visible by both the satellite and the Sun. This is then used to determine how much sunlight is reflected by the Earth towards the satellite.

Arguments:

- sat: Vector from center of Earth to satellite | SVector{3, Float64}
- sun: Vector from center of Earth to Sun | SVector{3, Flaot64}
- refl_data: Matrix containing the averaged reflectivity data for each cell | Array{Float64, 2}
- Rₑ: (Optional) Average radius of the Earth (default is 6371010 m) | Scalar
- AM₀: (Optional) Solar irradiance (default is 1366.9) | Scalar

Returns:

- cell
*albedos: Matrix with each element corresponding to the albedo coming from the corresponding cell on the surface of the earth | [num*lat x num_lon]

`EarthAlbedo.earthfov`

— FunctionDetermines which cells on the Earth's surface are in the field of view of an object in space (e.g., satellite, sun) using spherical coordinates.

Arguments:

- pos_sph: Vector from Earth to the object in question (e.g., satellite, sun) in ECEF frame using spherical coordinates [θ, ϵ, r] | [3,]
- sy: Number of latitude cells Earth's surface is divided into | Int
- sx: Number of longitude cells Earth's surface is divided into | Int
- Rₑ: (Optional) Average radius of the Earth (m) | Float

Returns:

- fov: Cells on Earth's surface that are in the field of view of the given object | BitMatrix [sy, sx]

`EarthAlbedo.earthfov!`

— FunctionDetermines which cells on the Earth's surface are in the field of view of an object in space (e.g., satellite, sun) using spherical coordinates. This version takes in and updates a field-of-view (FOV) matrix in place.

Arguments:

- fov: Cells on Earth's surface (updated in place with cells that are in field | Bitmatrix [sy, sx] of view of provided object)
- pos_sph: Vector from Earth to the object in question (e.g., satellite, sun) | [3,] in ECEF frame using spherical coordinates [θ, ϵ, r]
- sy: Number of latitude cells Earth's surface is divided into | Int
- sx: Number of longitude cells Earth's surface is divided into | Int
- Rₑ: (Optional) Average radius of the Earth (m) | Float

`EarthAlbedo.gridangle`

— MethodDetermines the angle between two cells given their indices

Arguments:

- i₁: Latitude index of first cell in grid | Int
- j₁: Longitude index of first cell in grid | Int
- i₂: Latitude index of second cell in grid | Int
- j₂: Longitude index of second cell in grid | Int
- sy: Number of latitude cells in grid | Int
- sx: Number of longitude cells in grid | Int

Outputs:

- ρ: Angle between the two grid index pairs (rad) | Float

`EarthAlbedo.idx2rad`

— MethodTransforms from TOMS REFL Matrix indices to spherical coordinates (radians)

Arguments:

- i: TOMS REFL Matrix latitude index of desired cell | Int
- j: TOMS REFL Matrix longitude index of desired cell | Int
- sy: Number of latitude cells in grid | Int
- sx: Number of longitude cells in grid | Int

Returns: (Tuple)

- (θ, ϵ): Tuple of (Polar, Elevation) angle corresponding to center of desired cell (rad) | Tuple{Float, Float}

`EarthAlbedo.load_refl`

— FunctionLoads in reflectivity data and stores it in a REFL struct

`EarthAlbedo.rad2idx`

— MethodTransforms location of a cell center in spherical coordinates (radians) to TOMS REFL Matrix indices. (NOTE that we are forcing a specific rounding style to match MATLAB's)

Arguments:

- θ: Polar angle corresponding to center of desired cell (rad) | Scalar
- ϵ: Elevation angle corresponding to center of desired cell (rad) | Scalar
- sy: Number of latitude cells in grid | Int
- sx: Number of longitude cells in grid | Int

Returns:

- (i, j): TOMS REFL Matrix (latitude, longitude) index of desired cell | Tuple{Int, Int}