Interdomain Tracing

Interdomain Tracing#

Perform tracing across coronal and heliospheric domains.

This example demonstrates how to use the inter_domain_tracing() function to trace magnetic field lines across domain boundaries.

import os


import matplotlib.pyplot as plt

from mapflpy.scripts import inter_domain_tracing
from mapflpy.utils import plot_traces, fetch_default_launch_points
from mapflpy.data import fetch_cor_magfiles, fetch_hel_magfiles

Load in the coronal and heliospheric magnetic field files

cor_files = fetch_cor_magfiles()
hel_files = fetch_hel_magfiles()

Define 100 launch points using the fibonacci lattice method (at 1 Rsun)

launch_points = fetch_default_launch_points(n=100, r=1)

Call the interdomain tracing function with the provided coronal and heliospheric magnetic field files and the defined launch points; otherwise, the default keyword arguments are used.

Note

Refer to the inter_domain_tracing() documentation for additional keyword arguments that can be passed to this function, viz. to finetune the way in which traces cross (or recross) the domain boundary. Of particular interest are

  • maxiter

  • r_interface

  • helio_shift

  • rtol

final_traces, traced_to_boundary, boundary_recross = inter_domain_tracing(
    *cor_files,
    *hel_files,
    launch_points=launch_points,
    context=CONTEXT)

This call returns a tuple where the first element is the trace geometry. The remaining two elements are boolean arrays indicating whether a trace successfully travel from the coronal inner boundary to the heliospheric outer boundary, and whether a trace recrossed the domain boundary.

Warning

The final_traces that are returned from inter_domain_tracing() are not a single contiguous (nan buffered) array. Unlike other tracing protocols found throughout the mapflpy package (which return Traces objects), these traces are a list of heterogeneously sized arrays, one per launch point i.e. an N x 3 x M i…n list.

for i, trace in enumerate(final_traces):
    print(f"Trace {i}, shape: {trace.shape}")
Trace 0, shape: (3, 56)
Trace 1, shape: (3, 1352)
Trace 2, shape: (3, 906)
Trace 3, shape: (3, 14)
Trace 4, shape: (3, 49)
Trace 5, shape: (3, 233)
Trace 6, shape: (3, 80)
Trace 7, shape: (3, 39)
Trace 8, shape: (3, 2796)
Trace 9, shape: (3, 239)
Trace 10, shape: (3, 1365)
Trace 11, shape: (3, 396)
Trace 12, shape: (3, 173)
Trace 13, shape: (3, 140)
Trace 14, shape: (3, 257)
Trace 15, shape: (3, 678)
Trace 16, shape: (3, 372)
Trace 17, shape: (3, 744)
Trace 18, shape: (3, 28)
Trace 19, shape: (3, 365)
Trace 20, shape: (3, 917)
Trace 21, shape: (3, 44)
Trace 22, shape: (3, 25)
Trace 23, shape: (3, 311)
Trace 24, shape: (3, 97)
Trace 25, shape: (3, 310)
Trace 26, shape: (3, 170)
Trace 27, shape: (3, 59)
Trace 28, shape: (3, 68)
Trace 29, shape: (3, 1395)
Trace 30, shape: (3, 90)
Trace 31, shape: (3, 80)
Trace 32, shape: (3, 907)
Trace 33, shape: (3, 235)
Trace 34, shape: (3, 177)
Trace 35, shape: (3, 1246)
Trace 36, shape: (3, 1770)
Trace 37, shape: (3, 1506)
Trace 38, shape: (3, 84)
Trace 39, shape: (3, 158)
Trace 40, shape: (3, 349)
Trace 41, shape: (3, 272)
Trace 42, shape: (3, 604)
Trace 43, shape: (3, 1009)
Trace 44, shape: (3, 75)
Trace 45, shape: (3, 274)
Trace 46, shape: (3, 1364)
Trace 47, shape: (3, 233)
Trace 48, shape: (3, 352)
Trace 49, shape: (3, 358)
Trace 50, shape: (3, 124)
Trace 51, shape: (3, 815)
Trace 52, shape: (3, 1489)
Trace 53, shape: (3, 833)
Trace 54, shape: (3, 624)
Trace 55, shape: (3, 504)
Trace 56, shape: (3, 129)
Trace 57, shape: (3, 136)
Trace 58, shape: (3, 40)
Trace 59, shape: (3, 474)
Trace 60, shape: (3, 19)
Trace 61, shape: (3, 222)
Trace 62, shape: (3, 720)
Trace 63, shape: (3, 1041)
Trace 64, shape: (3, 939)
Trace 65, shape: (3, 862)
Trace 66, shape: (3, 95)
Trace 67, shape: (3, 968)
Trace 68, shape: (3, 1854)
Trace 69, shape: (3, 412)
Trace 70, shape: (3, 1134)
Trace 71, shape: (3, 575)
Trace 72, shape: (3, 182)
Trace 73, shape: (3, 344)
Trace 74, shape: (3, 1239)
Trace 75, shape: (3, 220)
Trace 76, shape: (3, 465)
Trace 77, shape: (3, 1035)
Trace 78, shape: (3, 367)
Trace 79, shape: (3, 923)
Trace 80, shape: (3, 114)
Trace 81, shape: (3, 1157)
Trace 82, shape: (3, 308)
Trace 83, shape: (3, 186)
Trace 84, shape: (3, 99)
Trace 85, shape: (3, 1205)
Trace 86, shape: (3, 1225)
Trace 87, shape: (3, 41)
Trace 88, shape: (3, 86)
Trace 89, shape: (3, 281)
Trace 90, shape: (3, 427)
Trace 91, shape: (3, 691)
Trace 92, shape: (3, 132)
Trace 93, shape: (3, 38)
Trace 94, shape: (3, 728)
Trace 95, shape: (3, 17)
Trace 96, shape: (3, 509)
Trace 97, shape: (3, 180)
Trace 98, shape: (3, 157)
Trace 99, shape: (3, 131)

Plot and adjust the field of view to be 200 Solar Radii in each direction so that both domains are visible.

FOV = 200.0  # Rsun

ax = plt.figure().add_subplot(projection='3d')
plot_traces(*final_traces, ax=ax)
for dim in 'xyz':
    getattr(ax, f'set_{dim}lim3d')((-FOV, FOV))
ax.set_box_aspect([1, 1, 1])

plt.show()
p01 interdomain tracing

Total running time of the script: (0 minutes 1.225 seconds)

Gallery generated by Sphinx-Gallery