made getArray more general; updated gitignore

This commit is contained in:
P.M. Sutter 2014-05-13 08:11:16 -05:00
parent 76ea3567c8
commit 87445abfab
2 changed files with 16 additions and 1 deletions

View file

@ -447,7 +447,12 @@ def loadVoidCatalog(sampleDir, dataPortion="central", loadParticles=True,
def getArray(objectList, attr):
if hasattr(objectList[0], attr):
return np.fromiter((getattr(v, attr) for v in objectList), float)
ndim = np.shape( np.atleast_1d( getattr(objectList[0], attr) ) )[0]
attrArr = np.zeros(( len(objectList), ndim ))
for idim in xrange(ndim):
attrArr[:,idim] = np.fromiter((np.atleast_1d(getattr(v, attr))[idim] \
for v in objectList), float )
return attrArr
else:
print " Attribute", attr, "not found!"
return -1