Initial commit of refinement submodule
This commit is contained in:
parent
649196570b
commit
cf9499a988
2 changed files with 35 additions and 1 deletions
|
|
@ -1 +1 @@
|
|||
from . import io, plot
|
||||
from . import io, plot, refinement
|
||||
34
nafuma/xrd/refinement.py
Normal file
34
nafuma/xrd/refinement.py
Normal file
|
|
@ -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'])
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue