Note
Go to the end to download the full example code.
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
maxiterr_interfacehelio_shiftrtol
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, 55)
Trace 1, shape: (3, 1351)
Trace 2, shape: (3, 905)
Trace 3, shape: (3, 13)
Trace 4, shape: (3, 48)
Trace 5, shape: (3, 232)
Trace 6, shape: (3, 79)
Trace 7, shape: (3, 38)
Trace 8, shape: (3, 2795)
Trace 9, shape: (3, 238)
Trace 10, shape: (3, 1364)
Trace 11, shape: (3, 395)
Trace 12, shape: (3, 172)
Trace 13, shape: (3, 139)
Trace 14, shape: (3, 256)
Trace 15, shape: (3, 677)
Trace 16, shape: (3, 371)
Trace 17, shape: (3, 743)
Trace 18, shape: (3, 27)
Trace 19, shape: (3, 364)
Trace 20, shape: (3, 916)
Trace 21, shape: (3, 43)
Trace 22, shape: (3, 24)
Trace 23, shape: (3, 310)
Trace 24, shape: (3, 96)
Trace 25, shape: (3, 309)
Trace 26, shape: (3, 169)
Trace 27, shape: (3, 58)
Trace 28, shape: (3, 67)
Trace 29, shape: (3, 1394)
Trace 30, shape: (3, 89)
Trace 31, shape: (3, 79)
Trace 32, shape: (3, 906)
Trace 33, shape: (3, 234)
Trace 34, shape: (3, 176)
Trace 35, shape: (3, 1245)
Trace 36, shape: (3, 1769)
Trace 37, shape: (3, 1505)
Trace 38, shape: (3, 83)
Trace 39, shape: (3, 157)
Trace 40, shape: (3, 348)
Trace 41, shape: (3, 271)
Trace 42, shape: (3, 603)
Trace 43, shape: (3, 1008)
Trace 44, shape: (3, 74)
Trace 45, shape: (3, 273)
Trace 46, shape: (3, 1363)
Trace 47, shape: (3, 232)
Trace 48, shape: (3, 351)
Trace 49, shape: (3, 357)
Trace 50, shape: (3, 123)
Trace 51, shape: (3, 814)
Trace 52, shape: (3, 1488)
Trace 53, shape: (3, 832)
Trace 54, shape: (3, 623)
Trace 55, shape: (3, 503)
Trace 56, shape: (3, 128)
Trace 57, shape: (3, 135)
Trace 58, shape: (3, 39)
Trace 59, shape: (3, 473)
Trace 60, shape: (3, 18)
Trace 61, shape: (3, 221)
Trace 62, shape: (3, 719)
Trace 63, shape: (3, 1040)
Trace 64, shape: (3, 938)
Trace 65, shape: (3, 861)
Trace 66, shape: (3, 94)
Trace 67, shape: (3, 967)
Trace 68, shape: (3, 1853)
Trace 69, shape: (3, 411)
Trace 70, shape: (3, 1133)
Trace 71, shape: (3, 574)
Trace 72, shape: (3, 181)
Trace 73, shape: (3, 343)
Trace 74, shape: (3, 1238)
Trace 75, shape: (3, 219)
Trace 76, shape: (3, 464)
Trace 77, shape: (3, 1034)
Trace 78, shape: (3, 366)
Trace 79, shape: (3, 922)
Trace 80, shape: (3, 113)
Trace 81, shape: (3, 1156)
Trace 82, shape: (3, 307)
Trace 83, shape: (3, 185)
Trace 84, shape: (3, 98)
Trace 85, shape: (3, 1204)
Trace 86, shape: (3, 1224)
Trace 87, shape: (3, 40)
Trace 88, shape: (3, 85)
Trace 89, shape: (3, 280)
Trace 90, shape: (3, 426)
Trace 91, shape: (3, 690)
Trace 92, shape: (3, 131)
Trace 93, shape: (3, 37)
Trace 94, shape: (3, 727)
Trace 95, shape: (3, 16)
Trace 96, shape: (3, 508)
Trace 97, shape: (3, 179)
Trace 98, shape: (3, 156)
Trace 99, shape: (3, 130)
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()

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