file_generation
generate_file_like
- sonnetsuiteshelper.file_generation.generate_file_like(base_filename: str, output_filename: str, base_file_path: str = '', output_file_path: str = '', output_filename_prefix: str = '', output_filename_suffix: str = '', params_to_edit: Mapping[str, str | float | int] | None = None, general_metals_to_edit: Mapping[str, dict[Literal['Rdc', 'Rrf', 'Xdc', 'Ls'], float]] | None = None, adaptive_sweeps_to_edit: Mapping[Literal['sweep_min', 'sweep_max', 'target_freqs'], float | int] | None = None, linear_sweeps_to_edit: Mapping[Literal['sweep_min', 'sweep_max', 'step_size'], float | int] | None = None, em_options_to_edit: Mapping[Literal['speed'], Literal[0, 1, 2]] | None = None, silent: bool = False, ignore_overwrite_warning: bool = False) None[source]
This generates a Sonnet file like the base file specified. This will take in a series of values or other elements to further modify the Sonnet file to be produced.
- Parameters:
base_filename (
str) – This is the name of the base file, this will assume a “.son” file extention if this is not included in the base file name. This will be used to create the new Sonnet file. This can include the path of the file if it does not exist in the same directory as the python script.output_filename (
str) – This is the name for the output file to be generated. If this does not have a “.son” file extention already, one will be added. If a file with this name already exists then its contents will be overwritten.
- Keyword Arguments:
output_file_path (
str) – This is the directory that the output file should be saved to. By default this is a blank string which will save the file in the same directory as the script. When specified the output file will be saved to this directory. If this directory does not already exist it will be created.output_filename_prefix (
str) – This is a string to add to the beggining of the filename. Default is a blank string.output_filename_suffix (
str) – This is a string to add to the end of the filename. Default is a blank string.params_to_edit (
Mapping[str,str | float | int] | None = None) – This is a dictionary that has keys of parameter names and values of the values those parameters should take. Note the values must be of type float or int. This can take any number of key and value pairs. If there is any parameter that isnt in the base file that exists in this dict then this will raise an error and will not continue. An example dictionary to be passed would take the form: >>> Params_to_edit = { … “Length_var_1” : 400, … “Length_var_2” : 250, … “Length_var_3” : 1975, … … … }general_metals_to_edit (
Mapping[str,dict[Literal[``”Rdc”, ``"Rrf","Xdc","Ls"],float]] | None = None) – This is a dictionary that has keys of general metal names and values of dictionarys with “Rdc”, “Rrf”, “Xdc”, “Ls” key names and values with values for those keys. Note those keys must exist in the dict for each general metal to edit. Any number of general metals can be passed. If there is any metal in this dictionary that doesn’t exist in the base file, or if that metal is there but has the wrong dict keys, this will raise an error and will not continue. An example dict to be passed would take the form: >>> gen_mets_edits = { … “gen_met_1”: {“Rdc”: 0.5, “Rrf”: 0.6, “Xdc”: 0.7, “Ls”: 0.8}, … “gen_met_2”: {“Rdc”: 1e-08, “Rrf”: 14e-8, “Xdc”: 0, “Ls”: 0.003}, … … … }None (adaptive_sweeps_to_editMapping[Literal["sweep_min", "sweep_max", "target_freqs"], float | int] | None =) – This is a dictionary that has keys of “sweep_min”, “sweep_max”, “target_freqs” and values of the values for those keys. An example dict to be passed would take the form: >>> adaptive_sweep = { … “sweep_min” : 1.0, … “sweep_max” : 5.0, … “target_freqs” : 500, … }
linear_sweeps_to_edit (
Mapping[Literal[``”sweep_min”, ``"sweep_max","step_size"],float | int] | None = None) – This is a dictionary that has keys of “sweep_min”, “sweep_max”, “step_size” and values of the values for those keys. An example dict to be passed would take the form: >>> linear_sweep = { … “sweep_min” : 1.0, … “sweep_max” : 5.0, … “step_size” : 0.1, … }em_options_to_edit (
Mapping[Literal[``”speed”:class:`]`, :class:`Literal[0`, ``1,2]] | None = None) – This is a dictionary that has keys of “speed” (which is either 0, 1, 2, this corrosponds to “Speed Memory” option in Sonnet EM options). >>> em_opts = { … “speed” : 1, … }silent (
bool = False) – Mute the output from makingg files.ignore_overwrite_warning (
bool = False,) – Ignore warnings about overwriting files.
Warning
If a file with this name already exists then its contents will be overwritten!