made some more functions case insensitive

This commit is contained in:
Martin Diehl 2014-06-17 08:53:37 +00:00
parent eac0217b78
commit 7d8934c9f6
1 changed files with 23 additions and 9 deletions

View File

@ -71,7 +71,10 @@ class Texture(Section):
else: else:
fraction = properties['fraction'] fraction = properties['fraction']
try:
multiKey = theType.lower() multiKey = theType.lower()
except AttributeError:
pass
if multiKey == 'gauss': if multiKey == 'gauss':
self.add_multiKey(multiKey,'phi1 %g\tPhi %g\tphi2 %g\tscatter %g\tfraction %g'%( self.add_multiKey(multiKey,'phi1 %g\tPhi %g\tphi2 %g\tscatter %g\tfraction %g'%(
@ -226,9 +229,20 @@ class Material():
''' Experimental! Needs expansion to multi-constituent microstructures...''' ''' Experimental! Needs expansion to multi-constituent microstructures...'''
microstructure = Microstructure() microstructure = Microstructure()
components=dict((k.lower(), v) for k,v in components.iteritems()) # make keys lower case (http://stackoverflow.com/questions/764235/dictionary-to-lowercase-in-python)
for property in ['phase','texture','fraction','crystallite']: for key in ['phase','texture','fraction','crystallite']:
if type(components[property]) is not list: components[property] = [components[property]] if type(components[key]) is not list:
try:
components[key] = [components[key].lower()]
except AttributeError:
components[key] = [components[key]]
else:
for i, x in enumerate(components[key]):
try:
components[key][i] = x.lower()
except AttributeError:
pass
for (phase,texture,fraction,crystallite) in zip(components['phase'],components['texture'],components['fraction'],components['crystallite']): for (phase,texture,fraction,crystallite) in zip(components['phase'],components['texture'],components['fraction'],components['crystallite']):
microstructure.add_multiKey('constituent','phase %i\ttexture %i\tfraction %g\ncrystallite %i'%( microstructure.add_multiKey('constituent','phase %i\ttexture %i\tfraction %g\ncrystallite %i'%(