diff --git a/nafuma/xrd/__init__.py b/nafuma/xrd/__init__.py index e0e052c..d89f20e 100644 --- a/nafuma/xrd/__init__.py +++ b/nafuma/xrd/__init__.py @@ -1 +1 @@ -from . import io, plot \ No newline at end of file +from . import io, plot, refinement \ No newline at end of file diff --git a/nafuma/xrd/refinement.py b/nafuma/xrd/refinement.py new file mode 100644 index 0000000..64a98e8 --- /dev/null +++ b/nafuma/xrd/refinement.py @@ -0,0 +1,34 @@ +import os +import shutil +import time +import datetime + +import nafuma.auxillary as aux + +def make_big_inp(data: dict, options={}): + + required_options = ['output', 'overwrite', 'backup', 'backup_path'] + + default_options = { + 'output': 'big.inp', # Name of the output .INP file + 'overwrite': False, # Toggles overwrite on / off + 'backup': True, # Toggles backup on / off. Makes a backup of the file if it already exists. Only runs if overwrite is enabled. + 'backup_dir': 'backup' # Specifies the path where the backup files should be located + } + + options = aux.update_options(options=options, required_options=required_options, default_options=default_options) + + + # Raises exception if files exists and overwrite is not enabled + if not options['overwrite']: + if os.path.exists(options['output']): + raise Exception(f'Overwrite disabled and file already exists: {options["output"]}') + + + # Makes a backup of file + elif options['backup'] and os.path.exists(options['output']): + aux.backup_file(filename=options['output'], backup_dir=options['backup_dir']) + + + + \ No newline at end of file