added codes

This commit is contained in:
MiriamLoecke
2023-07-12 11:36:04 +02:00
parent 1e5d1f3fe1
commit 5c1efe956f
9 changed files with 1205 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
################################################################
#
# Workspace
#
################################################################
# Import modules here
from __future__ import print_function
import numpy as np
import sys
from fenics import *
import glob
from unwrapper import Unwrapper
def read_parameters(infile):
''' Read in parameters yaml file.
Args:
infile path to yaml file
Return:
prms parameters dictionary
'''
import ruamel.yaml as yaml
with open(infile, 'r+') as f:
prms = yaml.load(f, Loader=yaml.Loader)
return prms
def getfiles(path):
#get the velocities from the input files
files = glob.glob(path + '/**/[0-9]*/u.h5', recursive=True)
if files == []:
files = glob.glob(path + 'u[0-9]*.h5', recursive=True)
files.sort(key=lambda f: int(''.join(filter(str.isdigit, f))))
return files
def ROUTINES(options):
'''
All the process activated in the input file should be coded here
'''
#unwrap from filenames for h5 files:
velocity_files = getfiles(options['io']['in_file'])
unwrapper = Unwrapper(options)
unwrapper.unwrap(velocity_files)
#unwrap from numpy file:
#unwrapper.set_method('Laplacian')
#unwrapper.unwrap(options['io']['in_file'] + 'u.npy')
if __name__ == '__main__':
# This lines are necessary in order to read the input file as well of the 'read_parameters' function.
inputfile = sys.argv[1]
print('Found input file ' + inputfile)
# this part will be executed first and will call all the other process.
options = read_parameters(inputfile)
ROUTINES(options)