Reference on jhuki.parfile

The parfile module provides functions to programmatically write parameter files. The main functions provided are:

jhuki.parfile.write_many_parfiles_from_template(template, subs_dict, out_file_prefix)[source]

Write several parfiles from the template with substitution specified by the dictionary sub_dict_list. The dictionary has to have as keys the variables to be substituted and as values: - “scalars” for those values that have to be the same in all the parfiles - lists, with one entry per file, for those that have to be change file by file.

For example: {‘dx’: [1, 2], ‘dy’: 3} will create two files with ‘dx = 1’ and ‘dx = 2’ and ‘dy = 3’ in both cases.

We add an header with the list of variables that were introduced.

Parameters
  • template (str) – Basic template with parameters that have to be substituted. It follows Python’s template conventions, so the variables to be substituted are to be prefixed with a dollar sign.

  • subs_dict (dict with lists as values) – Dictionary that maps entries that have to be substituted with their value, one per each file. The values of the dictionary have to be lists or “scalars” (if they have to have the same value for the files).

  • out_file_prefix – Path of the output files, without the extension “.par”. The parfiles will be saved as {out_file_prefix}1.par, {out_file_prefix}2.par, and so on.

jhuki.parfile.write_one_parfile_from_template(template, sub_dict, out_file)[source]

Write a parfile to out_file from template with substitution specified by the dictionary sub_dict.

We add an header with the list of variables that were introduced.

Parameters
  • template (str) – Basic template with parameters that have to be substituted. It follows Python’s template conventions, so the variables to be substituted are to be prefixed with a dollar sign.

  • sub_dict (dict) – Dictionary that maps entries that have to be substituted with their value.

  • out_file (str) – Path of the output file