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 psi_data import fetch_mas_data

Load in the coronal and heliospheric magnetic field files

cor_files = fetch_mas_data(domains="cor", variables="br,bt,bp")
hel_files = fetch_mas_data(domains="hel", variables="br,bt,bp")

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, 1203)
Trace 1, shape: (3, 500)
Trace 2, shape: (3, 1468)
Trace 3, shape: (3, 182)
Trace 4, shape: (3, 1314)
Trace 5, shape: (3, 1555)
Trace 6, shape: (3, 86)
Trace 7, shape: (3, 979)
Trace 8, shape: (3, 81)
Trace 9, shape: (3, 175)
Trace 10, shape: (3, 101)
Trace 11, shape: (3, 237)
Trace 12, shape: (3, 757)
Trace 13, shape: (3, 142)
Trace 14, shape: (3, 1079)
Trace 15, shape: (3, 1363)
Trace 16, shape: (3, 278)
Trace 17, shape: (3, 228)
Trace 18, shape: (3, 639)
Trace 19, shape: (3, 219)
Trace 20, shape: (3, 1525)
Trace 21, shape: (3, 159)
Trace 22, shape: (3, 1660)
Trace 23, shape: (3, 1173)
Trace 24, shape: (3, 1377)
Trace 25, shape: (3, 102)
Trace 26, shape: (3, 783)
Trace 27, shape: (3, 1473)
Trace 28, shape: (3, 1318)
Trace 29, shape: (3, 199)
Trace 30, shape: (3, 1472)
Trace 31, shape: (3, 614)
Trace 32, shape: (3, 325)
Trace 33, shape: (3, 1058)
Trace 34, shape: (3, 57)
Trace 35, shape: (3, 1025)
Trace 36, shape: (3, 647)
Trace 37, shape: (3, 1021)
Trace 38, shape: (3, 671)
Trace 39, shape: (3, 1939)
Trace 40, shape: (3, 1202)
Trace 41, shape: (3, 926)
Trace 42, shape: (3, 815)
Trace 43, shape: (3, 1567)
Trace 44, shape: (3, 1292)
Trace 45, shape: (3, 94)
Trace 46, shape: (3, 1738)
Trace 47, shape: (3, 51)
Trace 48, shape: (3, 2264)
Trace 49, shape: (3, 1723)
Trace 50, shape: (3, 614)
Trace 51, shape: (3, 135)
Trace 52, shape: (3, 1137)
Trace 53, shape: (3, 161)
Trace 54, shape: (3, 1640)
Trace 55, shape: (3, 424)
Trace 56, shape: (3, 1048)
Trace 57, shape: (3, 57)
Trace 58, shape: (3, 483)
Trace 59, shape: (3, 97)
Trace 60, shape: (3, 532)
Trace 61, shape: (3, 953)
Trace 62, shape: (3, 1114)
Trace 63, shape: (3, 161)
Trace 64, shape: (3, 28)
Trace 65, shape: (3, 209)
Trace 66, shape: (3, 723)
Trace 67, shape: (3, 38)
Trace 68, shape: (3, 282)
Trace 69, shape: (3, 1020)
Trace 70, shape: (3, 520)
Trace 71, shape: (3, 17)
Trace 72, shape: (3, 1931)
Trace 73, shape: (3, 581)
Trace 74, shape: (3, 666)
Trace 75, shape: (3, 1655)
Trace 76, shape: (3, 1135)
Trace 77, shape: (3, 459)
Trace 78, shape: (3, 604)
Trace 79, shape: (3, 14)
Trace 80, shape: (3, 726)
Trace 81, shape: (3, 795)
Trace 82, shape: (3, 44)
Trace 83, shape: (3, 145)
Trace 84, shape: (3, 236)
Trace 85, shape: (3, 663)
Trace 86, shape: (3, 824)
Trace 87, shape: (3, 1287)
Trace 88, shape: (3, 148)
Trace 89, shape: (3, 557)
Trace 90, shape: (3, 201)
Trace 91, shape: (3, 1364)
Trace 92, shape: (3, 84)
Trace 93, shape: (3, 416)
Trace 94, shape: (3, 556)
Trace 95, shape: (3, 741)
Trace 96, shape: (3, 181)
Trace 97, shape: (3, 384)
Trace 98, shape: (3, 554)
Trace 99, shape: (3, 294)

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.829 seconds)

Gallery generated by Sphinx-Gallery