GeoCotrans.jl
GeoCotrans
— ModuleCoordinate systems, transformations, and geomagnetic field models.
Coordinate systems
GEO
: Geocentric Geographic (cartesian) (GEO) coordinate system(x [𝐋], y [𝐋], z [𝐋])
.GSM
: Geocentric Solar Magnetospheric (GSM) coordinate system.GSE
: Geocentric Solar Ecliptic (GSE) coordinate system.GEI
: Geocentric Equatorial Inertial (GEI) coordinate system.GDZ
: Geodetic (GDZ) coordinate system(altitude [km], latitude [deg], longitude [deg])
.MAG
: Geomagnetic (MAG) coordinate system.SPH
: Geocentric Geographic (spherical) (SPH) coordinate system(r [𝐋], θ [deg], φ [deg])
.
Coordinate transformations
geo2gei
,gei2geo
: Transform between GEO and GEI coordinate systems.geo2gsm
,gsm2geo
: Transform between GEO and GSM coordinate systems.gei2gsm
,gsm2gei
: Transform between GEI and GSM coordinate systems.gse2gsm
,gsm2gse
: Transform between GSE and GSM coordinate systems.
References
International Geomagnetic Reference Field (IGRF)
The International Geomagnetic Reference Field (IGRF) is a standard mathematical description of the Earth's main magnetic field. It is used widely in studies of the Earth's deep interior, crust, ionosphere, and magnetosphere.
Functions
igrf_B
: Compute the geomagnetic field (IGRF-14, dipole model)
Examples
r, θ, φ = 6500., 30., 4.
t = Date(2021, 3, 28)
Br, Bθ, Bφ = igrf_Bd(r, θ, φ, t)
# Input position in geodetic coordinates, output magnetic field in East-North-Up (ENU) coordinates
Be, Bn, Bu = igrf_B(GDZ(0, 60.39299, 5.32415), t)
References
Elsewhere
- SatelliteToolboxGeomagneticField.jl: Models to compute the geomagnetic field (IGRF-13, dipole model)
- ppigrf: Pure Python code to calculate IGRF model predictions.
- geopack: Python code to calculate IGRF model predictions.
Installation
using Pkg
Pkg.add("GeoCotrans")
Coordinate Systems
GeoCotrans.GDZ
— TypeGeodetic (GDZ) coordinate system (altitude [km], latitude [deg], longitude [deg])
.
Defined using a reference ellipsoid. Both the altitude and latitude depend on the ellipsoid used. GeoCotrans uses the WGS84 reference ellipsoid.
GeoCotrans.GEI
— TypeGeocentric Equatorial Inertial (GEI) coordinate system.
GeoCotrans.GEO
— TypeGeocentric Geographic (cartesian) (GEO) coordinate system (x [𝐋], y [𝐋], z [𝐋])
.
GeoCotrans.GSM
— TypeGeocentric Solar Magnetospheric (GSM) coordinate system.
X points sunward from Earth's center. The X-Z plane is defined to contain Earth's dipole axis (positive North).
GeoCotrans.GSE
— TypeGeocentric Solar Ecliptic (GSE) coordinate system.
GeoCotrans.MAG
— TypeGeomagnetic (MAG) coordinate system.
GeoCotrans.SM
— TypeSolar Magnetic (SM) coordinate system.
GeoCotrans.SPH
— TypeGeocentric Geographic (spherical) (SPH) coordinate system (r [𝐋], θ [deg], φ [deg])
.
API Reference
Public
GeoCotrans.GeoCotrans
— ModuleCoordinate systems, transformations, and geomagnetic field models.
Coordinate systems
GEO
: Geocentric Geographic (cartesian) (GEO) coordinate system(x [𝐋], y [𝐋], z [𝐋])
.GSM
: Geocentric Solar Magnetospheric (GSM) coordinate system.GSE
: Geocentric Solar Ecliptic (GSE) coordinate system.GEI
: Geocentric Equatorial Inertial (GEI) coordinate system.GDZ
: Geodetic (GDZ) coordinate system(altitude [km], latitude [deg], longitude [deg])
.MAG
: Geomagnetic (MAG) coordinate system.SPH
: Geocentric Geographic (spherical) (SPH) coordinate system(r [𝐋], θ [deg], φ [deg])
.
Coordinate transformations
geo2gei
,gei2geo
: Transform between GEO and GEI coordinate systems.geo2gsm
,gsm2geo
: Transform between GEO and GSM coordinate systems.gei2gsm
,gsm2gei
: Transform between GEI and GSM coordinate systems.gse2gsm
,gsm2gse
: Transform between GSE and GSM coordinate systems.
References
International Geomagnetic Reference Field (IGRF)
The International Geomagnetic Reference Field (IGRF) is a standard mathematical description of the Earth's main magnetic field. It is used widely in studies of the Earth's deep interior, crust, ionosphere, and magnetosphere.
Functions
igrf_B
: Compute the geomagnetic field (IGRF-14, dipole model)
Examples
r, θ, φ = 6500., 30., 4.
t = Date(2021, 3, 28)
Br, Bθ, Bφ = igrf_Bd(r, θ, φ, t)
# Input position in geodetic coordinates, output magnetic field in East-North-Up (ENU) coordinates
Be, Bn, Bu = igrf_B(GDZ(0, 60.39299, 5.32415), t)
References
Elsewhere
- SatelliteToolboxGeomagneticField.jl: Models to compute the geomagnetic field (IGRF-13, dipole model)
- ppigrf: Pure Python code to calculate IGRF model predictions.
- geopack: Python code to calculate IGRF model predictions.
GeoCotrans.CoordinateVector
— TypeCoordinateVector{C, T}
3-element FieldVector
in a specific coordinate system C
.
GeoCotrans.GDZ
— TypeGeodetic (GDZ) coordinate system (altitude [km], latitude [deg], longitude [deg])
.
Defined using a reference ellipsoid. Both the altitude and latitude depend on the ellipsoid used. GeoCotrans uses the WGS84 reference ellipsoid.
GeoCotrans.GDZ
— MethodGDZ(x, y, z)
Construct a CoordinateVector
in GDZ
coordinates.
GeoCotrans.GDZ
— MethodGDZ(𝐫)
Construct a CoordinateVector
in GDZ
coordinates.
GeoCotrans.GEI
— TypeGeocentric Equatorial Inertial (GEI) coordinate system.
GeoCotrans.GEI
— MethodGEI(x, y, z)
Construct a CoordinateVector
in GEI
coordinates.
GeoCotrans.GEI
— MethodGEI(𝐫)
Construct a CoordinateVector
in GEI
coordinates.
GeoCotrans.GEO
— TypeGeocentric Geographic (cartesian) (GEO) coordinate system (x [𝐋], y [𝐋], z [𝐋])
.
GeoCotrans.GEO
— MethodGEO(x, y, z)
Construct a CoordinateVector
in GEO
coordinates.
GeoCotrans.GEO
— MethodGEO(𝐫)
Construct a CoordinateVector
in GEO
coordinates.
GeoCotrans.GSE
— TypeGeocentric Solar Ecliptic (GSE) coordinate system.
GeoCotrans.GSE
— MethodGSE(x, y, z)
Construct a CoordinateVector
in GSE
coordinates.
GeoCotrans.GSE
— MethodGSE(𝐫)
Construct a CoordinateVector
in GSE
coordinates.
GeoCotrans.GSM
— TypeGeocentric Solar Magnetospheric (GSM) coordinate system.
X points sunward from Earth's center. The X-Z plane is defined to contain Earth's dipole axis (positive North).
GeoCotrans.GSM
— MethodGSM(x, y, z)
Construct a CoordinateVector
in GSM
coordinates.
GeoCotrans.GSM
— MethodGSM(𝐫)
Construct a CoordinateVector
in GSM
coordinates.
GeoCotrans.MAG
— TypeGeomagnetic (MAG) coordinate system.
GeoCotrans.MAG
— MethodMAG(x, y, z)
Construct a CoordinateVector
in MAG
coordinates.
GeoCotrans.MAG
— MethodMAG(𝐫)
Construct a CoordinateVector
in MAG
coordinates.
GeoCotrans.SM
— TypeSolar Magnetic (SM) coordinate system.
GeoCotrans.SM
— MethodSM(x, y, z)
Construct a CoordinateVector
in SM
coordinates.
GeoCotrans.SM
— MethodSM(𝐫)
Construct a CoordinateVector
in SM
coordinates.
GeoCotrans.SPH
— TypeGeocentric Geographic (spherical) (SPH) coordinate system (r [𝐋], θ [deg], φ [deg])
.
GeoCotrans.SPH
— MethodSPH(x, y, z)
Construct a CoordinateVector
in SPH
coordinates.
GeoCotrans.SPH
— MethodSPH(𝐫)
Construct a CoordinateVector
in SPH
coordinates.
GeoCotrans.gdz2sph
— Methodgdz2sph(alt, lat, lon)
Convert (alt [km], lat [deg], lon [deg])
in Geodetic coordinate to Spherical geocentric coordinate.
GeoCotrans.gei2geo
— Methodgei2geo(x, t)
Transforms x
vector from Geocentric Equatorial Inertial (GEI) to Geographic (GEO) coordinates at time t
.
GeoCotrans.gei2gsm
— Methodgei2gsm(x, t)
Transforms x
vector from Geocentric Equatorial Inertial (GEI) to Geocentric Solar Magnetic (GSM) coordinates at time t
.
GeoCotrans.geo2gei
— Methodgeo2gei(x, t)
Transforms x
vector from Geographic (GEO) to Geocentric Equatorial Inertial (GEI) coordinates at time t
.
GeoCotrans.geo2gsm
— Methodgeo2gsm(x, t)
Transforms x
vector from Geographic (GEO) to Geocentric Solar Magnetic (GSM) coordinates at time t
.
GeoCotrans.get_igrf_coeffs
— Methodget_igrf_coeffs(time)
Get IGRF-14 coefficients for a given time.
Similar to IRBEM implementation, but with higher precision (IRBEM uses year
as the time unit).
GeoCotrans.gse2gsm
— FunctionSee also: gse2gsm_mat
GeoCotrans.gse2gsm
— Methodgse2gsm(x, t)
Transforms x
vector from Geocentric Solar Ecliptic (GSE) to Geocentric Solar Magnetic (GSM) coordinates at time t
.
GeoCotrans.gsm2gei
— Methodgsm2gei(x, t)
Transforms x
vector from Geocentric Solar Magnetic (GSM) to Geocentric Equatorial Inertial (GEI) coordinates at time t
.
GeoCotrans.gsm2geo
— Methodgsm2geo(x, t)
Transforms x
vector from Geocentric Solar Magnetic (GSM) to Geographic (GEO) coordinates at time t
.
GeoCotrans.gsm2gse
— Methodgsm2gse(x, t)
Transforms x
vector from Geocentric Solar Magnetic (GSM) to Geocentric Solar Ecliptic (GSE) coordinates at time t
.
GeoCotrans.igrf_B
— Methodigrf_B(r, θ, φ, t; max_degree=IGRF_degree) -> (Br, Bθ, Bφ)
Calculate IGRF model components in geocentric coordinates (r [km], θ [rad], φ [rad])
at time t
.
Parameters
- r: radius [km]
- θ: colatitude [rad]
- φ: longitude [rad], positive east
- maxdegree: highest degree of expansion (1 <= maxdegree <= 13)
GeoCotrans.igrf_B
— Methodigrf_B(𝐫::CoordinateVector{GDZ}, t; max_degree=IGRF_degree) -> (Be, Bn, Bu)
Calculate IGRF model components in east, north, up (ENU) coordinates for geodetic coordinates 𝐫
at time t
.
GeoCotrans.igrf_Bd
— Methodigrf_Bd(r, θ, φ, t; max_degree=IGRF_degree) -> (Br, Bθ, Bφ)
Calculate IGRF model components in geocentric coordinates (r [km], θ [deg], φ [deg])
at time t
.
Parameters
- r: radius [km]
- θ: colatitude [deg]
- φ: longitude [deg]
- maxdegree: highest degree of expansion (1 <= maxdegree <= 13)
Private
GeoCotrans.Schmidt_normalization
— MethodSchmidt_normalization(l, m)
Compute Schmidt normalization factor for degree l and order m.
Reference: Geomagnetism and Schmidt quasi-normalization
GeoCotrans.calc_dipole_angle
— Methodcalc_dipole_angle(g10, g11, h11)
Calculate dipole angle (θ, φ) and dipole strength (b0) from spherical harmonic coefficients g10
, g11
, h11
.
θ: dipole tilt angle (radians) φ: dipole longitude/phase (radians) b0: dipole strength (nT)
GeoCotrans.calc_dipole_geo
— Methodcalc_dipole_geo(time)
Compute dipole direction in GEO coordinates. [IRBEM]
GeoCotrans.calc_sun_gei
— Methodcalc_sun_gei(ra, dec)
Calculate sun direction vector in GEI given right ascension ra
and declination dec
.
GeoCotrans.calculate_gst
— Methodcalculate_gst(time)
Calculate Greenwich sidereal time (GST) in radians from the given time.
Reference: https://aa.usno.navy.mil/faq/GAST, https://github.com/JuliaAstro/AstroLib.jl/blob/main/src/ct2lst.jl
GeoCotrans.calculate_gst_alt
— Methodcalculate_gst_alt(time)
Alternative implementation of Greenwich sidereal time calculation based on the reference algorithm from pyspedas.cotrans_tools.csundir_vect
.
GeoCotrans.car2sph
— Methodcar2sph(x, y, z)
Convert (x, y, z)
in Cartesian coordinate to (r, colat [deg], lon [deg])
in spherical coordinate.
GeoCotrans.cdipdir
— Methodcdipdir(time)
Compute dipole direction in GEO coordinates. [PySPEDAS]
References
- https://pyspedas.readthedocs.io/en/latest/coords.html#pyspedas.cotranstools.cotranslib.cdipdir
GeoCotrans.csundir
— Methodcsundir(time) -> (gst, ra, dec, elong, obliq)
Calculate the direction of the sun, returns a tuple of (gst, ra, dec, elong, obliq)
in radians.
gst
: Greenwich mean sidereal timera
: Right ascensiondec
: Declination of the sunelong
: ecliptic longitudeobliq
: Inclination of Earth's axis
See also AstroLib.sunpos
.
GeoCotrans.gei2gsm_mat
— Methodgei2gsm_mat(time)
Compute the GEI to GSM transformation matrix.
First axis: sun direction (xS, yS, zS) Second axis: y-axis (cross product of dipole and sun, normalized) Third axis: z-axis (cross product of sun and y-axis, normalized)
GeoCotrans.get_dipole_terms
— Methodget_dipole_terms(g, h)
Compute dipole parameters (θ, φ, x0, y0, z0, b0) from IGRF coefficients.
Returns a named tuple: (θ, φ, x0, y0, z0, b0)
GeoCotrans.gse2gsm_mat
— Methodgse2gsm_mat(time)
Compute the GSE to GSM transformation matrix T3 = <- psi,X>, where the rotation angle psi is the GSE-GSM angle.
This transformation is a rotation in the GSE YZ plane from the GSE Z axis to the GSM Z axis.
GeoCotrans.matrix_form
— MethodFormat into matrix form (l, m)