Trace¶

OTSO.trace ¶
trace(
coordsys: str = "GEO",
solar_wind_params: SolarWindParams = {},
geomagnetic_params: GeomagneticParams = {},
tsyganenko_params: TsyganenkoParams = {},
datetime_params: DateTimeParams = {},
magfield_params: MagFieldParams = {},
computation_params: ComputationParams = {},
data_retrieval_params: DataRetrievalParams = {},
custom_field_params: CustomFieldParams = {},
integration_params: IntegrationParams = {},
coordinate_params: CoordinateParams = {},
grid_params: GridParams = {},
) -> list
Trace magnetic field lines using the OTSO framework.
Traces magnetic field lines across a global grid to visualize the magnetosphere structure. Useful for understanding magnetic connectivity and field line topology. Computation also returns the McIlwain L value for the field line and invariant latitude for the origin location of the field line. Users should be cautious when interpreting low- or high-latitude origin invariant latitudes as they are ill-defined in such locations.
Parameters:
-
Coordsys(str) –Coordinate system for field line positions.
-
datetime_params(DateTimeParams, default:{}) –Date/time parameters.
Available keys:
year(int, default=2024): Year (e.g., 2023)month(int, default=1): Month (1–12)day(int, default=1): Day (1–31)hour(int, default=12): Hour (0–23)minute(int, default=0): Minute (0–59)second(int, default=0): Second (0–59)
-
magfield_params(MagFieldParams, default:{}) –Magnetic field models.
Available keys:
internalmag(str, default="IGRF"): "NONE", "IGRF", "Dipole", "Custom Gauss", "CHAOS"externalmag(str, default="TSY89c"): "NONE", "TSY87short", "TSY87long", "TSY89a", "TSY96", "TSY01", "TSY01S", "TSY04", "TSY89c", "TSY15N", "TSY15B", "TA16_RBF", "TSY89_refit", "MHD"boberg(bool, default=False): Enable Boberg extensionbobergtype(str, default="EXTENSION"): "EXTENSION", "CONTINUOUS", "DST_DEPENDENT", "DST_MIDPOINT"magnetopause(str, default="Kobel"): "NONE", "Kobel", "Sibeck", "Lin", "Sphere", "aFormisano"spheresize(float, default=25): Spherical boundary radius (Re)AdaptiveExternalModel(bool, default=False): Auto-select external modeloptimise_tsy(bool, default=False): Use the faster implementation of the selected Tsyganenko model (affects externalmag="TSY01", "TSY01S", "TSY04", or "TSY96"; other models are unaffected by this flag). Both settings give numerically identical results (all known bugs are fixed in both); True is just faster
-
solar_wind_params(SolarWindParams, default:{}) –Solar wind parameters. Defaults are quiet-time medians (Kp <= 1) of OMNI data, 1996-2025.
Available keys:
vx(float, default=-359.4): Solar wind velocity x-component (km/s)vy(float, default=0): Solar wind velocity y-component (km/s)vz(float, default=0): Solar wind velocity z-component (km/s)bx(float, default=0.11): IMF x-component (nT)by(float, default=-0.16): IMF y-component (nT)bz(float, default=0.58): IMF z-component (nT)by_avg(float, default=-0.17): Averaged IMF By over last 30mins (nT)bz_avg(float, default=0.59): Averaged IMF Bz over last 30mins (nT)density(float, default=4.94): Solar wind density (particles/cm³)pdyn(float, default=1.31): Solar wind dynamic pressure (nPa); computed from density and velocity when 0, or when density or velocity is given without pdyn
-
geomagnetic_params(GeomagneticParams, default:{}) –Geomagnetic indices. Defaults are quiet-time medians (Kp <= 1) of OMNI data, 1996-2025.
Available keys:
Dst(float, default=-4): Dst index (nT)kp(float, default=0.7): Kp index (0-9)n_index(float, default=0.145): Newell coupling functionb_index(float, default=0.032): Boynton coupling functionsym_h_corrected(float, default=-18.07): Corrected SYM-H index (nT)
-
tsyganenko_params(TsyganenkoParams, default:{}) –Tsyganenko model coefficients. Defaults are quiet-time medians (Kp <= 1) of OMNI data, 1996-2025.
Available keys:
G1(float, default=0.38): Tsyganenko G1 coefficientG2(float, default=0.12): Tsyganenko G2 coefficientG3(float, default=0.47): Tsyganenko G3 coefficientW1(float, default=0.07): Tsyganenko W1 coefficientW2(float, default=0.06): Tsyganenko W2 coefficientW3(float, default=0.13): Tsyganenko W3 coefficientW4(float, default=0.03): Tsyganenko W4 coefficientW5(float, default=0.05): Tsyganenko W5 coefficientW6(float, default=0.08): Tsyganenko W6 coefficient
-
grid_params(GridParams, default:{}) –Grid configuration parameters.
Available keys:
latstep(float, default=-5): Latitude step size for gridlongstep(float, default=5): Longitude step size for gridmaxlat(float, default=90): Maximum latitude for gridminlat(float, default=-90): Minimum latitude for gridmaxlong(float, default=360): Maximum longitude for gridminlong(float, default=0): Minimum longitude for grid
-
computation_params(ComputationParams, default:{}) –Computation settings.
Available keys:
corenum(int, default=None): Number of CPU cores for multicore processingVerbose(bool, default=True): Enable verbose output
-
data_retrieval_params(DataRetrievalParams, default:{}) –Data retrieval.
Available keys:
serverdata(str, default="OFF"): Server data retrieval from OMNIlivedata(str, default="OFF"): real-time data retrieval from NOAA
-
custom_field_params(CustomFieldParams, default:{}) –Custom fields.
Available keys:
g(list, default=None): Gauss g coefficientsh(list, default=None): Gauss h coefficientsmax_degree(int, default=13): Max degree of spherical harmonic expansionMHDfile(str, default=None): MHD simulation fileMHDcoordsys(str, default=None): MHD coordinate systemMHDgridtype(str, default="auto"): How the MHD grid is looked up - "auto" detects per-axis spacing automatically, "uniform" forces the fast fixed-spacing path (only correct if every axis really is evenly spaced), "stretched" forces the general path needed for a grid whose resolution varies with position (e.g. finer near Earth)MHDinterpolation(str, default="trilinear"): How the field is reconstructed between grid points - "trilinear" is the classic fast corner-blend (kinked gradients at cell boundaries), "tricubic" is a smooth C^1 fit that's far more accurate in smooth field regions but can overshoot near sharp gradients/boundaries, "monotonic" is the same tricubic fit with overshoot limiting (recommended for general use), "divfree" returns the curl of an interpolated vector potential so the field is exactly divergence-free (for long quasi-trapped trajectories; less point-wise accurate than "tricubic"; the gridded field must itself be divergence-free, e.g. an external-only field - a warning is issued otherwise)
Returns:
-
list(list) –[trace_data, readme_text]
- trace_data: Dictionary with magnetic field line positions
- readme_text: OTSO computation summary
Examples:
from OTSO import trace
if __name__ == '__main__':
# Example using grouped parameters
trace_results = trace(
computation_params={"corenum": 4},
magfield_params={"externalmag":"TSY89c"},
grid_params={"latstep": -30, "longstep": 180, "maxlat": 60, "minlat": 0},
)
# Access the results
trace_dict, metadata = trace_result