ptyrad.params.parser#
Params files parsing functions
Functions
|
Copies the params file to the output directory if it exists. |
|
|
|
|
|
|
|
Load parameters from a TOML file. |
|
|
|
Convert old constraint param format {freq} (pre v0.1.0b11) to {start_iter, step, end_iter}. |
|
Normalize probe params in init_params This includes: - Migrate legacy keys (pre v0.1.0b13) like probe_defocus, probe_c3, probe_c5 into probe_aberrations. |
|
- ptyrad.params.parser.load_params(file_path, validate=True)[source]#
- Parameters:
file_path (str)
validate (bool)
- ptyrad.params.parser.load_toml_params(file_path)[source]#
Load parameters from a TOML file.
Parameters: file_path (str): The path to the TOML file to be loaded.
Returns: dict: A dictionary containing the parameters loaded from the TOML file.
Raises: FileNotFoundError: If the specified file does not exist. ImportError: If the tomli package is not installed for Python < 3.11.
- ptyrad.params.parser.normalize_probe_params(init_params)[source]#
Normalize probe params in init_params This includes: - Migrate legacy keys (pre v0.1.0b13) like probe_defocus, probe_c3, probe_c5 into probe_aberrations. - Canonicalizes probe_aberrations into standard Krivanek polar format {‘Cnm’: XX, ‘phinm’: XX}.
Note that the init_params will be normalized before optionally passing into pydantic
- Parameters:
init_params (Dict)
- Return type:
Dict
- ptyrad.params.parser.normalize_constraint_params(constraint_params)[source]#
Convert old constraint param format {freq} (pre v0.1.0b11) to {start_iter, step, end_iter}.
- ptyrad.params.parser.copy_params_to_dir(params_path, output_dir, params=None)[source]#
Copies the params file to the output directory if it exists. If the params file does not exist, it dumps the provided params dictionary to a YAML file in the output directory.
- Parameters:
params_path (str) – Path to the params file (can be None if params are programmatically generated).
output_dir (str) – Directory where the params file or YAML dump will be saved.
params (dict, optional) – The programmatically generated params dictionary to save if no file exists.