gravelamps.core.graveconfig¶
Functions handling interactions with Gravelamps configuration INI and JSON files.
- gravelamps.core.graveconfig.get_and_ensure_folder(config: ConfigParser, section: str, option: str, fallback=<object object>) Path¶
Retrieve a folder from the config and ensure it exists.
- Parameters:
- config: ConfigParser
INI configuration values.
- section: str
Section from which to retrieve folder.
- option: str
Key to retrieve from the section.
- fallback: str, optional
Fallback option if key is missing.
- Returns:
- fp: pathlib.Path
Path to folder.
- gravelamps.core.graveconfig.get_data_generation_args(config: ConfigParser) dict¶
Gets the positional arguments for the data generation function. This is the file paths for the grid and data files. This will be stored in a dictionary whose keys are the types of file.
- Parameters:
- config: ConfigParser
INI configuration values.
- Returns:
- file_dict: dict
Contains file paths for the dimensionless frequency and source position grid files and the amplification factor real and imaginary component data files. Keys are the types of file.
- gravelamps.core.graveconfig.get_data_generation_func(lens_module: ModuleType) Callable¶
Get the data generation function from the module.
The first preference for this function is the generate_data attribute of the module. If this is not present, and the module has an amplification attribute, the function will be set to the generate_data_from_amplification function.
- Parameters:
- lens_module: ModuleType
Module containing lens model implementation.
- Returns:
- data_generation_func: Callable
Function that will result in the creation of the amplification factor data files.
- Raises:
- AttributeError
If the module contains neither a generate_data or amplification attribute from which to determine the correct function to use.
- gravelamps.core.graveconfig.get_data_generation_kwargs(config: ConfigParser) dict¶
Gets keyword arguments for the data generation function. Returns an empty dictionary if none are provided
- Parameters:
- config: ConfigParser
INI configuration values.
- Returns:
- data_generation_kwargs: dict
Keyword arguments to be passed to the data generation function
- gravelamps.core.graveconfig.get_section(config: ConfigParser, section: str, excluded_keys: list[str] = None) dict¶
Gets a section from the config and returns it as a dict excluding the specified keys.
- Parameters:
- config: ConfigParser
INI configuration values.
- section: str
Section of the configuration to get
- excluded_keys: list[str], optional, default=None
Keys to exclude from the retrieval.
- Returns:
- settings: dict
Retrieved keys
- gravelamps.core.graveconfig.get_setting_or_default(key: str, settings: dict, defaults: dict = None) str¶
Get a key from either the specific settings dictionary or the default value.
- Parameters:
- key: str
Name of key to retrieve
- settings: dict
Settings which take precedence which may contain the specific key.
- defaults: dict, optional, default=None
Default settings.
- Returns:
- value: str
Value for the given setting
- Raises:
- KeyError
If the key is missing from both the settings and defaults dict.
- gravelamps.core.graveconfig.get_user_condor_settings(config: ConfigParser) dict¶
Gets user condor settings from the INI
- Parameters:
- config: ConfigParser
INI configuration values
- Returns:
- settings: dict
User condor settings
- gravelamps.core.graveconfig.get_user_slurm_settings(config: ConfigParser) dict¶
Gets user slurm settings from the INI.
- Parameters:
- config: ConfigParser
INI configuration values.
- Returns:
- settings: dict
User slurm settings.
- gravelamps.core.graveconfig.make_generation_config(config: ConfigParser, idx: int) tuple[dict, Path]¶
Generate a configuration suitable for gravelamps_generate_lens from the current configuration, appending idx to the label, etc.
- Parameters:
- config: ConfigParser
INI configuration values.
- idx: int
Value to be used to append label, interpolator files, etc.
- Returns:
- gen_cfg: ConfigParser
Generated configuration.
- gen_cfg_fp: pathlib.Path
Path to generated configuration
- gravelamps.core.graveconfig.make_injection_config(config: ConfigParser) tuple[ConfigParser, Path]¶
Generate injection configuration. This is a replica of the input configuration, but pulling any changes from the lens.injection section into the lens section.
- Parameters:
- config: ConfigParser
INI configuration values.
- Returns:
- injection_config: ConfigParser
Injection configuration values.
- config_fp: pathlib.Path
Path to newly written configuration.