From 029239c701359e84cadb8c093ebd0ccc26d4f9df Mon Sep 17 00:00:00 2001 From: Justus Kuhlmann Date: Thu, 4 Dec 2025 16:04:14 +0100 Subject: [PATCH] add docstrings for input files --- corrlib/input/implementations.py | 2 +- corrlib/input/openQCD.py | 128 +++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/corrlib/input/implementations.py b/corrlib/input/implementations.py index 2a14d3e..9cb9e84 100644 --- a/corrlib/input/implementations.py +++ b/corrlib/input/implementations.py @@ -1,2 +1,2 @@ - +# List of supported input implementations codes = ['sfcf', 'openQCD'] diff --git a/corrlib/input/openQCD.py b/corrlib/input/openQCD.py index e0caba6..da92645 100644 --- a/corrlib/input/openQCD.py +++ b/corrlib/input/openQCD.py @@ -6,6 +6,24 @@ from typing import Any, Optional def read_ms1_param(path: str, project: str, file_in_project: str) -> dict[str, Any]: + """ + Read the parameters for ms1 measurements from a parameter file in the project. + + Parameters + ---------- + path: str + The path to the backlogger folder. + project: str + The project from which to read the parameter file. + file_in_project: str + The path to the parameter file within the project. + + Returns + ------- + param: dict[str, Any] + The parameters read from the file. + """ + file = os.path.join(path, "projects", project, file_in_project) ds = os.path.join(path, "projects", project) dl.get(file, dataset=ds) @@ -52,6 +70,24 @@ def read_ms1_param(path: str, project: str, file_in_project: str) -> dict[str, A def read_ms3_param(path: str, project: str, file_in_project: str) -> dict[str, Any]: + """ + Read the parameters for ms3 measurements from a parameter file in the project. + + Parameters + ---------- + path: str + The path to the backlogger folder. + project: str + The project from which to read the parameter file. + file_in_project: str + The path to the parameter file within the project. + + Returns + ------- + param: dict[str, Any] + The parameters read from the file. + """ + file = os.path.join(path, "projects", project, file_in_project) ds = os.path.join(path, "projects", project) dl.get(file, dataset=ds) @@ -68,6 +104,36 @@ def read_ms3_param(path: str, project: str, file_in_project: str) -> dict[str, A def read_rwms(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, postfix: str="ms1", version: str='2.0', names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: + """ + Read reweighting factor measurements from the project. + + Parameters + ---------- + path: str + The path to the backlogger folder. + project: str + The project from which to read the measurements. + dir_in_project: str + The directory within the project where the measurements are located. + param: dict[str, Any] + The parameters for the measurements. + prefix: str + The prefix of the measurement files. + postfix: str + The postfix of the measurement files. + version: str + The version of the openQCD used. + names: list[str] + Specific names for the replica of the ensemble the measurement file belongs to. + files: list[str] + Specific files to read. + + Returns + ------- + rw_dict: dict[str, dict[str, Any]] + The reweighting factor measurements read from the files. + """ + dataset = os.path.join(path, "projects", project) directory = os.path.join(dataset, dir_in_project) if files is None: @@ -95,6 +161,37 @@ def read_rwms(path: str, project: str, dir_in_project: str, param: dict[str, Any def extract_t0(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str="", names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: + """ + Extract t0 measurements from the project. + + Parameters + ---------- + path: str + The path to the backlogger folder. + project: str + The project from which to read the measurements. + dir_in_project: str + The directory within the project where the measurements are located. + param: dict[str, Any] + The parameters for the measurements. + prefix: str + The prefix of the measurement files. + dtr_read: int + The dtr_read parameter for the extraction. + xmin: int + The xmin parameter for the extraction. + spatial_extent: int + The spatial_extent parameter for the extraction. + fit_range: int + The fit_range parameter for the extraction. + postfix: str + The postfix of the measurement files. + names: list[str] + Specific names for the replica of the ensemble the measurement file belongs to. + files: list[str] + Specific files to read. + """ + dataset = os.path.join(path, "projects", project) directory = os.path.join(dataset, dir_in_project) if files is None: @@ -133,6 +230,37 @@ def extract_t0(path: str, project: str, dir_in_project: str, param: dict[str, An def extract_t1(path: str, project: str, dir_in_project: str, param: dict[str, Any], prefix: str, dtr_read: int, xmin: int, spatial_extent: int, fit_range: int = 5, postfix: str = "", names: Optional[list[str]]=None, files: Optional[list[str]]=None) -> dict[str, Any]: + """ + Extract t1 measurements from the project. + + Parameters + ---------- + path: str + The path to the backlogger folder. + project: str + The project from which to read the measurements. + dir_in_project: str + The directory within the project where the measurements are located. + param: dict[str, Any] + The parameters for the measurements. + prefix: str + The prefix of the measurement files. + dtr_read: int + The dtr_read parameter for the extraction. + xmin: int + The xmin parameter for the extraction. + spatial_extent: int + The spatial_extent parameter for the extraction. + fit_range: int + The fit_range parameter for the extraction. + postfix: str + The postfix of the measurement files. + names: list[str] + Specific names for the replica of the ensemble the measurement file belongs to. + files: list[str] + Specific files to read. + """ + directory = os.path.join(path, "projects", project, dir_in_project) if files is None: files = []