diff --git a/processing/pre/abq_addUserOutput.py b/processing/pre/abq_addUserOutput.py index b14399509..1e0614c21 100755 --- a/processing/pre/abq_addUserOutput.py +++ b/processing/pre/abq_addUserOutput.py @@ -1,16 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -''' -Writes meaningful labels to the Abaqus input file (*.inp) -based on the files -.output -that are written during the first run of the model. -See Abaqus Keyword Reference Manual (AKRM) *DEPVAR for details. -Original script: marc_addUserOutput.py modified by Benjamin Bode -''' - -import sys,os,re,string +import sys,os,re from optparse import OptionParser import damask @@ -19,7 +10,6 @@ scriptID = ' '.join([scriptName,damask.version]) # ----------------------------- def ParseOutputFormat(filename,what,me): -# ----------------------------- format = {'outputs':{},'specials':{'brothers':[]}} outputmetafile = filename+'.output'+what @@ -120,7 +110,7 @@ for file in files: for what in me: outputFormat[what] = ParseOutputFormat(formatFile,what,me[what]) - if not '_id' in outputFormat[what]['specials']: + if '_id' not in outputFormat[what]['specials']: print "'%s' not found in <%s>"%(me[what],what) print '\n'.join(map(lambda x:' '+x,outputFormat[what]['specials']['brothers'])) sys.exit(1) @@ -164,19 +154,14 @@ for file in files: if m: lastSection = thisSection thisSection = m.group(1) - #Abaqus keyword can be upper or lower case - if (lastSection.upper() == '*DEPVAR' and thisSection.upper() == '*USER'): - #Abaqus SDVs are named SDV1...SDVn if no specific name is given - #Abaqus needs total number of SDVs in the line after *Depvar keyword + if (lastSection.upper() == '*DEPVAR' and thisSection.upper() == '*USER'): #Abaqus keyword can be upper or lower case if options.number > 0: - #number of SDVs - output.write('%i\n'%options.number) + output.write('%i\n'%options.number) #Abaqus needs total number of SDVs in the line after *Depvar keyword else: - #number of SDVs output.write('%i\n'%len(UserVars)) - #index,output variable key,output variable description + for i in range(len(UserVars)): - output.write('%i,"%i%s","%i%s"\n'%(i+1,0,UserVars[i],0,UserVars[i])) + output.write('%i,"%i%s","%i%s"\n'%(i+1,0,UserVars[i],0,UserVars[i])) #index,output variable key,output variable description if (thisSection.upper() != '*DEPVAR' or not re.match('\s*\d',line)): output.write(line) output.close() diff --git a/processing/pre/geom_addPrimitive.py b/processing/pre/geom_addPrimitive.py index 9200f2df7..3dd60bc24 100755 --- a/processing/pre/geom_addPrimitive.py +++ b/processing/pre/geom_addPrimitive.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,math,string +import os,sys,math import numpy as np from optparse import OptionParser import damask @@ -114,7 +114,7 @@ for name in filenames: microstructure = microstructure.reshape(info['grid'],order='F') - if options.dimension != None: + if options.dimension is not None: mask = (np.array(options.dimension) < 0).astype(float) # zero where positive dimension, otherwise one dim = abs(np.array(options.dimension)) # dimensions of primitive body pos = np.zeros(3,dtype='float') @@ -134,10 +134,9 @@ for name in filenames: # --- report --------------------------------------------------------------------------------------- + if ( newInfo['microstructures'] != info['microstructures']): + damask.util.croak('--> microstructures: %i'%newInfo['microstructures']) - remarks = [] - if ( newInfo['microstructures'] != info['microstructures']): remarks.append('--> microstructures: %i'%newInfo['microstructures']) - if remarks != []: damask.util.croak(remarks) #--- write header --------------------------------------------------------------------------------- diff --git a/processing/pre/geom_canvas.py b/processing/pre/geom_canvas.py index 93df742da..882f32c88 100755 --- a/processing/pre/geom_canvas.py +++ b/processing/pre/geom_canvas.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,math,string +import os,sys,math import numpy as np from optparse import OptionParser import damask @@ -81,7 +81,8 @@ for name in filenames: 'microstructures': 0, } - newInfo['grid'] = np.array([int(o*float(n.translate(None,'xX'))) if n[-1].lower() == 'x' else int(n) for o,n in zip(info['grid'],options.grid)],'i') + newInfo['grid'] = np.array([int(o*float(n.translate(None,'xX'))) if n[-1].lower() == 'x'\ + else int(n) for o,n in zip(info['grid'],options.grid)],'i') newInfo['grid'] = np.where(newInfo['grid'] > 0, newInfo['grid'],info['grid']) microstructure_cropped = np.zeros(newInfo['grid'],'i') @@ -143,7 +144,7 @@ for name in filenames: "origin\tx {origin[0]}\ty {origin[1]}\tz {origin[2]}".format(origin=newInfo['origin']), "homogenization\t{homog}".format(homog=info['homogenization']), "microstructures\t{microstructures}".format(microstructures=newInfo['microstructures']), - extra_header + extra_header ]) table.labels_clear() table.head_write() diff --git a/processing/pre/geom_check.py b/processing/pre/geom_check.py index 3f9e50864..d607a1f73 100755 --- a/processing/pre/geom_check.py +++ b/processing/pre/geom_check.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string,vtk +import os,sys,vtk import numpy as np from optparse import OptionParser import damask @@ -91,8 +91,7 @@ for name in filenames: (directory,filename) = os.path.split(name) writer.SetDataModeToBinary() writer.SetCompressorTypeToZLib() - writer.SetFileName(os.path.join(directory,os.path.splitext(filename)[0] - +'.'+writer.GetDefaultFileExtension())) + writer.SetFileName(os.path.join(directory,os.path.splitext(filename)[0]+'.'+writer.GetDefaultFileExtension())) else: writer = vtk.vtkDataSetWriter() writer.WriteToOutputStringOn() @@ -101,6 +100,6 @@ for name in filenames: if vtk.VTK_MAJOR_VERSION <= 5: writer.SetInput(grid) else: writer.SetInputData(grid) writer.Write() - if name == None: sys.stdout.write(writer.GetOutputString()[0:writer.GetOutputStringLength()]) + if name is None: sys.stdout.write(writer.GetOutputString()[0:writer.GetOutputStringLength()]) table.close() diff --git a/processing/pre/geom_clean.py b/processing/pre/geom_clean.py index b55149a61..18caf68b9 100755 --- a/processing/pre/geom_clean.py +++ b/processing/pre/geom_clean.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string,math +import os,sys,math import numpy as np import damask from scipy import ndimage diff --git a/processing/pre/geom_fromEuclideanDistance.py b/processing/pre/geom_fromEuclideanDistance.py index 405fca630..a932583c2 100755 --- a/processing/pre/geom_fromEuclideanDistance.py +++ b/processing/pre/geom_fromEuclideanDistance.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string,math,itertools +import os,sys,math,itertools import numpy as np from scipy import ndimage from optparse import OptionParser diff --git a/processing/pre/geom_fromImage.py b/processing/pre/geom_fromImage.py index 5ef524dcb..0977c5e7e 100755 --- a/processing/pre/geom_fromImage.py +++ b/processing/pre/geom_fromImage.py @@ -1,10 +1,10 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,math,string +import os,sys,math import numpy as np from optparse import OptionParser -from PIL import Image,ImageOps +from PIL import Image import damask scriptName = os.path.splitext(os.path.basename(__file__))[0] @@ -51,7 +51,7 @@ for name in filenames: try: img.seek(slice) # advance to slice layer = np.expand_dims(1+np.array(img,dtype = 'uint16'),axis = 0) # read image layer - microstructure = layer if slice == 0 else np.vstack((microstructure,layer)) # add to microstructure data + microstructure = layer if slice == 0 else np.vstack((microstructure,layer)) # noqa slice += 1 # advance to next slice except EOFError: break diff --git a/processing/pre/geom_fromMinimalSurface.py b/processing/pre/geom_fromMinimalSurface.py index 915f1f9f3..a3729dc30 100755 --- a/processing/pre/geom_fromMinimalSurface.py +++ b/processing/pre/geom_fromMinimalSurface.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string,math +import os,sys,math import numpy as np from optparse import OptionParser import damask diff --git a/processing/pre/geom_fromOsteonGeometry.py b/processing/pre/geom_fromOsteonGeometry.py index 9e8280a72..bc49b9dca 100755 --- a/processing/pre/geom_fromOsteonGeometry.py +++ b/processing/pre/geom_fromOsteonGeometry.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string,math +import os,sys,math import numpy as np from optparse import OptionParser import damask diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index 9edb8c3dc..17d1cb63c 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,sys,string +import os,sys import numpy as np from optparse import OptionParser import damask