From 81e98055dd3f6df8abf50bc4251a0854eb54a7d9 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 12 Mar 2020 19:52:33 +0100 Subject: [PATCH] polishing --- python/damask/environment.py | 22 +++++++++++++++------- python/damask/ktv.py | 9 ++++++--- python/damask/result.py | 13 +++++++------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/python/damask/environment.py b/python/damask/environment.py index 4c9ab762c..b5feb4fcd 100644 --- a/python/damask/environment.py +++ b/python/damask/environment.py @@ -1,24 +1,32 @@ +import tkinter import os class Environment(): - __slots__ = [ \ - 'options', - ] def __init__(self): """Read and provide values of DAMASK configuration.""" - self.options = {} - self.__get_options() + self.options = self._get_options() + tk = tkinter.Tk() + self.screen_width = tk.winfo_screenwidth() + self.screen_height = tk.winfo_screenheight() + def relPath(self,relative = '.'): + """Return absolute path from path relative to DAMASK root.""" return os.path.join(self.rootDir(),relative) + def rootDir(self): + """Return DAMASK root path.""" return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../')) - def __get_options(self): + + def _get_options(self): + options = {} for item in ['DAMASK_NUM_THREADS', 'MSC_ROOT', 'MARC_VERSION', ]: - self.options[item] = os.environ[item] if item in os.environ else None + options[item] = os.environ[item] if item in os.environ else None + + return options diff --git a/python/damask/ktv.py b/python/damask/ktv.py index 12252e093..19b87efdf 100644 --- a/python/damask/ktv.py +++ b/python/damask/ktv.py @@ -5,9 +5,11 @@ import numpy as np import vtk from vtk.util.numpy_support import numpy_to_vtk as np_to_vtk -from . import table +from . import Table +from . import Environment from . import version + class VTK: """ Spatial visualization (and potentially manipulation). @@ -200,7 +202,7 @@ class VTK: self.geom.GetPointData().AddArray(d) elif isinstance(data,pd.DataFrame): pass - elif isinstance(data,table): + elif isinstance(data,Table): pass @@ -232,7 +234,8 @@ class VTK: ren.AddActor(actor) ren.SetBackground(0.2,0.2,0.2) - renWin.SetSize(1024, 1024) + + renWin.SetSize(Environment().screen_width,Environment().screen_height) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) diff --git a/python/damask/result.py b/python/damask/result.py index 7d6a06441..748ea63fd 100644 --- a/python/damask/result.py +++ b/python/damask/result.py @@ -8,14 +8,15 @@ import h5py import numpy as np from . import VTK -from . import util -from . import version -from . import table -from . import mechanics +from . import Table from . import Rotation from . import Orientation from . import Environment from . import grid_filters +from . import mechanics +from . import util +from . import version + class Result: """ @@ -287,12 +288,12 @@ class Result: try: tbl[inc].add(path,data) except KeyError: - tbl[inc] = table.Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]}) + tbl[inc] = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]}) else: try: tbl.add(path,data) except AttributeError: - tbl = table.Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]}) + tbl = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]}) return tbl