Coverage for python/gsfit/gsfit_ts.py: 57%

14 statements  

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

1from .gsfit import Gsfit 

2 

3 

4class Gsfit_Ts(Gsfit): 

5 """Pressure-constrained ("Thomson scattering") GSFit, writing to the ``GSFIT_TS`` tree. 

6 

7 This configures the simple EFIT-polynomial pressure workflow: 

8 1. only reconstruct time-slices where the pressure (TS) sensors are "good", 

9 2. turn the pressure (Thomson scattering) sensors on, and 

10 3. use the EFIT polynomial for p', with either fixed or free edge pressure. 

11 

12 It also forces ``analysis_name="GSFIT_TS"`` so the results are written to the 

13 ``GSFIT_TS`` MDSplus tree rather than the default ``GSFIT`` tree (the tree name is 

14 derived from ``analysis_name`` in ``DiagnosticAndSimulationBase``). 

15 """ 

16 

17 PRESSURE_EDGE_FREE: bool 

18 

19 def __init__( 

20 self, 

21 pulseNo: int, 

22 run_name: str, 

23 run_description: str = "Pressure-constrained (Thomson scattering) GSFit", 

24 write_to_mds: bool = True, 

25 pulseNo_write: int | None = None, 

26 link_run_to_best: bool = False, 

27 ) -> None: 

28 super().__init__( 

29 pulseNo=pulseNo, 

30 run_name=run_name, 

31 run_description=run_description, 

32 write_to_mds=write_to_mds, 

33 pulseNo_write=pulseNo_write, 

34 analysis_name="GSFIT_TS", 

35 link_run_to_best=link_run_to_best, 

36 ) 

37 

38 # 1. Only reconstruct the time-slices where the pressure (TS) sensors are "good". 

39 self.settings["GSFIT_code_settings.json"]["timeslices"]["method"] = "good_pressure_sensors" 

40 # 2. Turn on the pressure (Thomson scattering) sensors. 

41 self.settings["sensor_weights_pressure.json"]["include"] = True 

42 # 3. Use the EFIT polynomial for p' and select the edge-pressure constraint. 

43 p_prime_settings = self.settings["source_function_p_prime.json"] 

44 p_prime_settings["method"] = "efit_polynomial" 

45 p_prime_settings["pressure_edge"]["free"] = self.PRESSURE_EDGE_FREE 

46 

47 

48class Gsfit_Ts_1(Gsfit_Ts): 

49 """Pressure-constrained GSFit with the edge pressure fixed to zero.""" 

50 

51 PRESSURE_EDGE_FREE = False 

52 

53 

54class Gsfit_Ts_2(Gsfit_Ts): 

55 """Pressure-constrained GSFit with a free edge pressure.""" 

56 

57 PRESSURE_EDGE_FREE = True