22Knob Extraction
33---------------
44
5- This module provides functionality to extract knob values from NXCALS and convert them to
6- MAD-X compatible format using LSA services.
5+ This module provides functionality to extract knob values from NXCALS for the LHC and
6+ convert them to MAD-X compatible format using LSA services.
77
88It handles retrieval of raw variable data from NXCALS, conversion of power converter
99currents to K-values, and mapping of power converter names to MAD-X naming
@@ -54,7 +54,7 @@ def get_knob_vals(
5454 delta_days : float = 0.25 ,
5555) -> list [NXCALSResult ]:
5656 """
57- Retrieve knob values for a given beam and time using specified patterns.
57+ Retrieve knob values for a given beam and time using specified patterns for the LHC .
5858
5959 This is the main entry point for extracting magnet knob values from NXCALS. The function
6060 performs a complete workflow:
@@ -218,7 +218,7 @@ def get_raw_vars(
218218
219219def get_energy (spark : SparkSession , time : datetime ) -> tuple [float , pd .Timestamp ]:
220220 """
221- Retrieve the beam energy from NXCALS.
221+ Retrieve the beam energy of the LHC from NXCALS.
222222
223223 Args:
224224 spark (SparkSession): Active Spark session.
@@ -242,7 +242,7 @@ def get_energy(spark: SparkSession, time: datetime) -> tuple[float, pd.Timestamp
242242
243243def calc_k_from_iref (lsa_client , currents : dict [str , float ], energy : float ) -> dict [str , float ]:
244244 """
245- Calculate K values from IREF using the LSA service.
245+ Calculate K values in the LHC from IREF using the LSA service.
246246
247247 Args:
248248 lsa_client: The LSA client instance.
@@ -294,9 +294,11 @@ def strip_i_meas(text: str) -> str:
294294 return text .removesuffix (":I_MEAS" )
295295
296296
297+ # Note: this will have to be updated if we ever want to support other magnet types
298+ # such as dipoles, sextupoles, octupoles, etc.
297299def map_pc_name_to_madx (pc_name : str ) -> str :
298300 """
299- Convert a power converter name or circuit name to its corresponding MAD-X name.
301+ Convert an LHC power converter name or circuit name to its corresponding MAD-X name.
300302
301303 This function processes the input name by removing the ':I_MEAS' suffix if present,
302304 extracting the circuit name from full power converter names (starting with 'RPMBB' or 'RPL'),
@@ -329,6 +331,4 @@ def map_pc_name_to_madx(pc_name: str) -> str:
329331 replacements = {"RQ" : "KQ" , "RCB" : "ACB" }
330332 for old , new in replacements .items ():
331333 circuit_name = circuit_name .replace (old , new )
332-
333- # Return in lowercase as required by MAD-X
334334 return circuit_name .lower ()
0 commit comments