Coverage for python/gsfit/database_readers/st40_astra_mdsplus/astra_flux_loop_reader.py: 0%
18 statements
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-07 13:12 +0000
« prev ^ index » next coverage.py v7.15.0, created at 2026-07-07 13:12 +0000
1"""Flux loop reader for ASTRA simulations using the fl_loop.dat file.
3This module reads flux loop geometry from the fl_loop.dat file
4which contains flux loop data in the following format:
5 r, z, name
6"""
8import os
9from typing import Any
12def astra_flux_loop_reader() -> dict[str, dict[str, Any]]:
13 """
14 Read flux loop data from the fl_loop.dat file.
16 The fl_loop.dat file contains flux loop data with columns:
17 - Column 0: r (radial position in meters)
18 - Column 1: z (vertical position in meters)
19 - Column 2: name (flux loop name, e.g., FLOOP_001)
21 :return: Dictionary mapping flux loop names to their properties:
22 - r: radial position (float)
23 - z: vertical position (float)
24 """
25 # Get the path to the fl_loop.dat file (in the same directory as this module)
26 fl_loop_dat_path = os.path.join(os.path.dirname(__file__), "fl_loop.dat")
28 # Read and parse the fl_loop.dat file
29 flux_loops_data: dict[str, dict[str, Any]] = {}
31 with open(fl_loop_dat_path, "r") as f:
32 for line in f:
33 line = line.strip()
34 if not line:
35 continue
37 parts = line.split()
38 if len(parts) < 3:
39 continue
41 # Parse columns: r, z, name
42 r: float = float(parts[0])
43 z: float = float(parts[1])
44 name: str = parts[2].strip()
46 flux_loops_data[name] = {
47 "r": r,
48 "z": z,
49 }
51 return flux_loops_data