From 27532cfa4e0ff4ab0c1d2e144b00302b39c45d5a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 19 Mar 2020 11:51:30 +0100 Subject: [PATCH] small fixes --- processing/post/DADF5toDREAM3D.py | 2 +- processing/post/vtk_addData.py | 2 ++ processing/pre/geom_fromVoronoiTessellation.py | 12 +++++++----- python/damask/environment.py | 9 +++------ python/damask/ktv.py | 1 - 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/processing/post/DADF5toDREAM3D.py b/processing/post/DADF5toDREAM3D.py index d90f3a19c..95b62c7ce 100755 --- a/processing/post/DADF5toDREAM3D.py +++ b/processing/post/DADF5toDREAM3D.py @@ -70,7 +70,7 @@ for filename in options.filenames: pass o = h5py.File(dirname + '/' + os.path.splitext(filename)[0] \ - + 'inc_{}.dream3D'.format(inc[3:].zfill(N_digits)),'w') + + '_inc_{}.dream3D'.format(inc[3:].zfill(N_digits)),'w') o.attrs['DADF5toDREAM3D'] = '1.0' o.attrs['FileVersion'] = '7.0' diff --git a/processing/post/vtk_addData.py b/processing/post/vtk_addData.py index e16a27ddd..25fcdada0 100755 --- a/processing/post/vtk_addData.py +++ b/processing/post/vtk_addData.py @@ -5,6 +5,8 @@ import sys from io import StringIO from optparse import OptionParser +import numpy as np + import damask scriptName = os.path.splitext(os.path.basename(__file__))[0] diff --git a/processing/pre/geom_fromVoronoiTessellation.py b/processing/pre/geom_fromVoronoiTessellation.py index 510486238..2551e702e 100755 --- a/processing/pre/geom_fromVoronoiTessellation.py +++ b/processing/pre/geom_fromVoronoiTessellation.py @@ -3,6 +3,7 @@ import os import sys import multiprocessing +from io import StringIO from optparse import OptionParser,OptionGroup import numpy as np @@ -15,7 +16,7 @@ scriptName = os.path.splitext(os.path.basename(__file__))[0] scriptID = ' '.join([scriptName,damask.version]) -def Laguerre_tessellation(grid, seeds, weights, grains, periodic = True, cpus = 2): +def Laguerre_tessellation(grid, seeds, grains, size, periodic, weights, cpus): def findClosestSeed(fargs): point, seeds, myWeights = fargs @@ -52,10 +53,10 @@ def Laguerre_tessellation(grid, seeds, weights, grains, periodic = True, cpus = [ -1, 1, 1 ], [ 0, 1, 1 ], [ 1, 1, 1 ], - ]).astype(float)*info['size'] if periodic else \ + ],dtype=np.float)*size if periodic else \ np.array([ [ 0, 0, 0 ], - ]).astype(float) + ],dtype=np.float) repeatweights = np.tile(weights,len(copies)).flatten(order='F') # Laguerre weights (1,2,3,1,2,3,...,1,2,3) for vec in copies: # periodic copies of seed points ... @@ -237,9 +238,10 @@ for name in filenames: damask.util.croak('tessellating...') if options.laguerre: - indices = Laguerre_tessellation(coords,seeds,table.get(options.weight),grains,options.periodic,options.cpus) + indices = Laguerre_tessellation(coords,seeds,grains,size,options.periodic, + table.get(options.weight),options.cpus) else: - indices = Voronoi_tessellation(coords,seeds,grains,size,options.periodic) + indices = Voronoi_tessellation (coords,seeds,grains,size,options.periodic) config_header = [] if options.config: diff --git a/python/damask/environment.py b/python/damask/environment.py index 6ce020406..df690314c 100644 --- a/python/damask/environment.py +++ b/python/damask/environment.py @@ -1,20 +1,17 @@ import os -try: - import tkinter -except: - tkinter = None +import tkinter class Environment: def __init__(self): """Read and provide values of DAMASK configuration.""" self.options = self._get_options() - if tkinter: + try: tk = tkinter.Tk() self.screen_width = tk.winfo_screenwidth() self.screen_height = tk.winfo_screenheight() tk.destroy() - else: + except tkinter.TclError: self.screen_width = 1024 self.screen_height = 768 diff --git a/python/damask/ktv.py b/python/damask/ktv.py index 65db2dd00..e0b0982a2 100644 --- a/python/damask/ktv.py +++ b/python/damask/ktv.py @@ -49,7 +49,6 @@ class VTK: Spatial origin. """ - geom = vtk.vtkRectilinearGrid() geom.SetDimensions(*(grid+1)) geom.SetXCoordinates(np_to_vtk(np.linspace(origin[0],origin[0]+size[0],grid[0]+1),deep=True))