cheatah
Module

space::irbem::purr

cheatah-space v0.1.0-alpha — Biome Standard 0.6.5-alpha

Classes

Functions

fn Epoch epoch_at(int year, int doy, double ut_seconds) #

The epoch for a date and time.

Parameters
year

the calendar year.

doy

the day of year, 1-366.

ut_seconds

seconds since midnight UT.

Returns

the epoch; Epoch::ok is false when the date lies outside IGRF's published range, in which case every routine taking it returns Status::OutOfValidityRange rather than a plausible wrong number.

Complexity

O(NMAX²) once, then reused by every call that takes it.

Allocation

none.

Unit testIrbemPurr.EpochMatchesTheTypedCore
System testsystests/test_irbem.purr
import fixarray
import space.irbem.purr as irbem
let e = irbem.epoch_at(2015, 182, 43200.0)
fn bool epoch_ok(const Epoch &e) #

Whether e names an instant this model can evaluate.

Parameters
e

the epoch.

Returns

Epoch::ok.

Complexity

O(1).

Allocation

none.

Unit testIrbemPurr.EpochMatchesTheTypedCore
System testsystests/test_irbem.purr
import fixarray
import space.irbem.purr as irbem
let e = irbem.epoch_at(1750, 1, 0.0)
let usable = irbem.epoch_ok(e)          # false — before IGRF begins
fn std::string status_name(int code) #

The name of a Status code, for a program that wants to report why a call declined.

Parameters
code

the status, as returned in a result array's status slot.

Returns

a short name such as "Ok" or "OutOfValidityRange"; "Unknown" for an unrecognised code, so this never throws on a value from an older build.

Complexity

O(1).

Allocation

the returned string.

Unit testIrbemPurr.StatusNamesEveryCode
System testsystests/test_irbem.purr
import io
import fixarray
import space.irbem.purr as irbem
io.print(irbem.status_name(0))          # -> Ok
fn ::cheatah::ndarray::NDArray make_lstar(const Epoch &e, double x1, double x2, double x3, int sysaxes, double pitch_angle_deg) #

The magnetic coordinates of one point — IRBEM's MAKE_LSTAR.

Parameters
e

the epoch, from epoch_at.

x1

first position component.

x2

second.

x3

third — read per sysaxes.

sysaxes

IRBEM's frame code: 0 GDZ, 1 GEO, 2 GSM, 3 GSE, 4 SM, 5 GEI, 6 MAG, 7 SPH, 8 RLL.

pitch_angle_deg

the local pitch angle; 90 is IRBEM's MAKE_LSTAR convention.

Returns

an ndarray of lstar_slots values: Lm, L*, Blocal, Bmin, I, MLT, and the Status code as the last slot. A declined call fills the physical slots with IRBEM's baddata and names the reason in the status slot rather than returning nothing.

Complexity

~10⁵ field evaluations — the drift-shell integral.

Allocation

one array of lstar_slots doubles.

Unit testIrbemPurr.MakeLstarMatchesTheTypedCore
System testsystests/test_irbem.purr
import io
import fixarray
import space.irbem.purr as irbem
let e = irbem.epoch_at(2015, 182, 43200.0)
let c = irbem.make_lstar(e, 6.6, 0.0, 0.0, 1, 90.0)
io.print("L* =", c[1])
fn double get_mlt(const Epoch &e, double x1, double x2, double x3, int sysaxes) #

Magnetic local time at a geographic point — IRBEM's GET_MLT.

Parameters
e

the epoch, from epoch_at.

x1

first position component.

x2

second position component.

x3

third position component — read per sysaxes.

sysaxes

the frame code the components are in.

Returns

MLT in hours, folded into [0, 24); a negative value signals a declined call, which cannot collide with a real MLT.

Complexity

O(1) beyond the frame transform.

Allocation

none.

Unit testIrbemPurr.MltMatchesTheTypedCore
System testsystests/test_irbem.purr
import io
import fixarray
import space.irbem.purr as irbem
let e = irbem.epoch_at(2015, 182, 43200.0)
io.print("MLT =", irbem.get_mlt(e, 6.6, 0.0, 0.0, 1))
fn ::cheatah::ndarray::NDArray coord_trans(const Epoch &e, double x1, double x2, double x3, int sysaxes_in, int sysaxes_out) #

Convert a position between any two of IRBEM's frames — its COORD_TRANS.

Parameters
e

the epoch, whose rotations the transform needs.

x1

first input component.

x2

second input component.

x3

third input component — read per sysaxes_in.

sysaxes_in

the frame the input is in.

sysaxes_out

the frame to convert to.

Returns

an ndarray of four values: the three output components, then the Status code.

Complexity

O(1) — at most two 3×3 products.

Allocation

one array of four doubles.

Unit testIrbemPurr.CoordTransRoundTrips
System testsystests/test_irbem.purr
import fixarray
import space.irbem.purr as irbem
let e = irbem.epoch_at(2015, 182, 43200.0)
let gsm = irbem.coord_trans(e, 6.6, 0.0, 0.0, 1, 2)   # GEO -> GSM

Constants & variables

var long long lstar_slots #

How many values make_lstar returns, and the slot each occupies.

Types

The internal-field truncation the facade pins.

Degree 13 is IGRF-14 as IAGA publishes it, and fixing it here is what removes Igrf's non-type template parameter from the surface.