Coverage for python/gsfit/database_readers/st40_astra_mdsplus/astra_bp_probe_reader.py: 0%

19 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-07 13:12 +0000

1"""Bp probe reader for ASTRA simulations using the pf_probe.dat file. 

2 

3This module reads Bp probe geometry from the pf_probe.dat file 

4which contains probe data in the following format: 

5 r, z, angle_pol, name 

6""" 

7 

8import os 

9from typing import Any 

10 

11 

12def astra_bp_probe_reader() -> dict[str, dict[str, Any]]: 

13 """ 

14 Read Bp probe data from the pf_probe.dat file. 

15 

16 The pf_probe.dat file contains Bp probe data with columns: 

17 - Column 0: r (radial position in meters) 

18 - Column 1: z (vertical position in meters) 

19 - Column 2: angle_pol (poloidal angle in radians) 

20 - Column 3: name (probe name, e.g., BPPROBE_101) 

21 

22 :return: Dictionary mapping Bp probe names to their properties: 

23 - r: radial position (float) 

24 - z: vertical position (float) 

25 - angle_pol: poloidal angle in radians (float) 

26 """ 

27 # Get the path to the pf_probe.dat file (in the same directory as this module) 

28 pf_probe_dat_path = os.path.join(os.path.dirname(__file__), "pf_probe.dat") 

29 

30 # Read and parse the pf_probe.dat file 

31 bp_probes_data: dict[str, dict[str, Any]] = {} 

32 

33 with open(pf_probe_dat_path, "r") as f: 

34 for line in f: 

35 line = line.strip() 

36 if not line: 

37 continue 

38 

39 parts = line.split() 

40 if len(parts) < 4: 

41 continue 

42 

43 # Parse columns: r, z, angle_pol, name 

44 r: float = float(parts[0]) 

45 z: float = float(parts[1]) 

46 angle_pol: float = float(parts[2]) 

47 name: str = parts[3].strip() 

48 

49 bp_probes_data[name] = { 

50 "r": r, 

51 "z": z, 

52 "angle_pol": angle_pol, 

53 } 

54 

55 return bp_probes_data