Coverage for python/gsfit/plotting/two_d_coils.py: 0%

17 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-14 15:25 +0000

1import matplotlib.axes 

2import numpy as np 

3 

4from ..gsfit import Gsfit 

5 

6 

7def plot( 

8 gsfit_controller: Gsfit, 

9 ax: matplotlib.axes.Axes, 

10 time_desired: float | None = None, 

11) -> None: 

12 """ 

13 Plot the poloidal-field (PF) coil cross-sections. 

14 

15 The PF coils are stored as axis-aligned rectangular filaments in the `coils` Rust data 

16 structure under `["pf", <coil_name>, "geometry", "r"/"z"/"d_r"/"d_z"]` [metre]. 

17 Colours follow the ST40 physics viewer (`plot_elmag.py`). 

18 

19 :param gsfit_controller: the Gsfit controller holding the populated `coils` object 

20 :param ax: the matplotlib axes to draw on 

21 :param time_desired: unused; kept for API symmetry with the other `two_d_*` plotters 

22 """ 

23 coils = gsfit_controller.coils 

24 

25 # Fixed PF-coil colours (match plot_elmag.py) 

26 facecolor: str = "#F1C40F" 

27 edgecolor: str = "#7D6608" 

28 

29 for pf_coil_name in coils.keys(["pf"]): 

30 filaments_r = coils.get_array1(["pf", pf_coil_name, "geometry", "r"]) # [metre] 

31 filaments_z = coils.get_array1(["pf", pf_coil_name, "geometry", "z"]) # [metre] 

32 filaments_d_r = coils.get_array1(["pf", pf_coil_name, "geometry", "d_r"]) # [metre] 

33 filaments_d_z = coils.get_array1(["pf", pf_coil_name, "geometry", "d_z"]) # [metre] 

34 

35 n_filaments: int = filaments_r.shape[0] 

36 for i_filament in range(n_filaments): 

37 corner_r = filaments_r[i_filament] + filaments_d_r[i_filament] * np.array([-0.5, 0.5, 0.5, -0.5]) 

38 corner_z = filaments_z[i_filament] + filaments_d_z[i_filament] * np.array([-0.5, -0.5, 0.5, 0.5]) 

39 ax.fill( 

40 corner_r, 

41 corner_z, 

42 facecolor=facecolor, 

43 edgecolor=edgecolor, 

44 linewidth=0.5, 

45 zorder=2, 

46 )