TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/stourgai/WPIT/llms.txt
Use this file to discover all available pages before exploring further.
RayUtils_mod sub-module provides six functions that handle the full lifecycle of a ray-tracing dataset in WPIT: parsing the raw ray file into a DataFrame, merging the computed Landau damping results with a rich set of derived plasma and geometric quantities, reading those enriched files back for downstream analysis, and producing several standard diagnostic plots. All functions work with file paths as strings; the appended and raw-input DataFrames are constructed with pandas and are fully interoperable with standard scientific Python workflows.
read_input_ray
Reads a whitespace-delimited ray file into a pandas DataFrame with 37 standardised columns. The file format is the output of the WPIT-compatible ray-tracing code: each row is one time step along the ray, and columns follow a fixed ordering.
Path to the input
.ray file. The file must be whitespace-delimited with no header row.DataFrame with one row per ray step and the following columns:
| Column | Description |
|---|---|
ray | Ray index |
ray_stop | Ray-stop flag |
time | Propagation time (s) |
posx, posy, posz | Position vector (m), Solar Magnetic frame |
vprelx, vprely, vprelz | Phase velocity components (m s⁻¹) |
vgrelx, vgrely, vgrelz | Group velocity components (m s⁻¹) |
nx, ny, nz | Refractive index vector (dimensionless) |
Bx, By, Bz | Background magnetic field (T) |
w | Wave angular frequency (rad s⁻¹) |
Nspec | Number of plasma species |
qs1–qs4 | Species charges (C) |
ms1–ms4 | Species masses (kg) |
Ns1–Ns4 | Species number densities (m⁻³) |
nus1–nus4 | Species collision frequencies (s⁻¹) |
freq | Wave frequency in Hz, derived as w / (2*pi) |
append_ray
Reads the raw ray file and the corresponding <ray_file_name>_damping.csv produced by landau_damping, then computes a comprehensive set of derived quantities at each time step and saves the result as <ray_file_name>_appended.csv. The damp column is set to zero for all steps after the first step at which the normalised wave power falls to 0.01 or below.
Path to the original
.ray file. The function automatically looks for ray_file_name + '_damping.csv' in the same location.Writes
<ray_file_name>_appended.csv. The file retains all time steps from the raw ray; the damp column is zeroed after the first step where wave power drops to 0.01 or below. Columns beyond those in the raw ray include:| Column | Description |
|---|---|
psi | Wave normal angle relative to B₀ (degrees) |
theta_res | Resonance cone angle (degrees) |
gendrin | Gendrin angle (degrees) |
Y | Angular distance from resonance cone: |psi - theta_res| |
L | Magnetic L-shell (computed via SpacePy MAG spherical coordinates) |
alt | Altitude in Earth radii |
lat, lon | Magnetic latitude and longitude (degrees) |
damp | Normalised wave power (0 to 1) |
S_stix, D_stix, P_stix, R_stix, L_stix | Stix cold-plasma parameters |
wce, wcH, wcHe, wcO | Cyclotron frequencies for e, H+, He+, O+ (rad s⁻¹) |
wpe, wpH, wpHe, wpO | Plasma frequencies for e, H+, He+, O+ (rad s⁻¹) |
wlhr | Lower hybrid resonance frequency (rad s⁻¹) |
wuhr | Upper hybrid resonance frequency (rad s⁻¹) |
Ne, NH, NHe, NO | Species densities renamed from Ns1–Ns4 |
append_ray requires the spacepy library for coordinate conversion (SM Cartesian → MAG spherical). If SpacePy is not installed, the function will raise an ImportError at import time.read_appended_ray
Reads an appended ray CSV file (produced by append_ray) back into a pandas DataFrame. This is a thin wrapper around pd.read_csv.
Path to the
_appended.csv file. Pass the full path including the _appended.csv suffix.DataFrame with all columns written by
append_ray (see above). Column types are inferred by pandas.resonance_along_raypath
Computes the resonant velocity and energy of particles interacting with the wave at each point along the ray for a grid of equatorial pitch angles. At each spatial step the resonant parallel and perpendicular velocities are determined from the resonance condition via WPIT.WaveProperties_mod.resonant_velocity, and the kinetic energy is converted to keV.
Path to the
_appended.csv file.Resonance harmonic order m. Use
0 for Landau resonance, 1 for the fundamental cyclotron resonance, -1 for the first counter-propagating resonance, etc.Array of equatorial pitch angles in degrees for which to compute resonant parameters. The function loops over all combinations of pitch angle and ray step.
Propagation time array from the appended ray (seconds).
Wave normal angle array along the ray (degrees).
Resonant kinetic energy in keV. Row index corresponds to pitch-angle index; column index to ray-step index.
Resonant parallel velocity in m s⁻¹ (Fortran order for memory efficiency).
Resonant perpendicular velocity in m s⁻¹.
Lorentz factor at resonance (dimensionless).
enhancement_factor
Computes and plots a wave-power enhancement histogram as a function of L-shell by collecting ray equatorial crossings (latitude sign changes) and weighting each crossing by the local normalised wave power. This reveals which L-shells receive the most cumulative wave energy as the ray bounces.
Path to the
_appended.csv file produced by append_ray.Displays a matplotlib histogram with
L-shell on the x-axis and Cavity enhancement (weighted density) on the y-axis. Bins are 0.1 L-units wide, centred on the mean L-shell of the equatorial crossings.- Interpolate
lat,L, anddamponto a fine time grid (0.1 ms resolution vianumpy.interp). - Detect zero-crossings of the interpolated latitude (equatorial crossings).
- Collect L-shell and wave-power values at each crossing.
- Plot
plt.histwithweights=mag_newanddensity=True.
ray_plots
Generates a comprehensive suite of diagnostic plots from the appended ray file. This is the recommended first step after append_ray to inspect the ray trajectory and damping results.
Path to the
_appended.csv file produced by append_ray.Produces the following matplotlib figures sequentially:
| Figure | Description |
|---|---|
| Wave freq + lat vs time | Wave frequency and lower-hybrid frequency vs time (left axis), magnetic latitude vs time (right axis). |
| Normalised wave power | Wave power (0–1) vs propagation time; shows where Landau damping is significant. |
| L-shell vs time | Ray L-shell trajectory. |
| Latitude vs time | Ray magnetic latitude. |
| Wave normal angle vs time | psi (degrees) vs time. |
| Refractive index vs time | Magnitude of the refractive index vector vs time. |
| L-shell + latitude (combined) | Dual-axis overlay of L-shell and latitude vs time. |
| Wave normal angle + latitude | Dual-axis overlay of psi and latitude vs time. |
| Ray path 3-panel (XY, XZ, YZ) | Ray path in MAG Cartesian coordinates (in Earth radii), with dipole field lines and refractive-index quiver arrows, colour-coded by wave power. |
| 2×2 summary | Ray path (XZ) scatter coloured by damping, wave power vs time, L-shell+latitude, and enhancement histogram. |
| Single ray path with damping | Large single-panel ray-path scatter in XZ plane, colour-coded by Landau damping. |
Complete pipeline example
The following end-to-end example shows all sixRayUtils_mod functions being used in sequence alongside landau_damping.