コード例 #1
0
                    nstd=1.5,
                    ran=(box[0][0], box[1][0], box[0][1], box[1][1]),
                    title='Example 5: Summing over voxels')

# In[ ]:

reload(psi)

psi.write(fields, 'test.out')

# print "read"
# fields = psi.readFields('test.out')

# In[ ]:

fields = psi.read('test.out')

# flatten arrays, divide by mass, and filter out voxels with zero mass
# mass = fields['m'].reshape((-1,1))
# cm = fields['x'].reshape((-1,3))/mass
# cm = cm[np.all(mass>0.0, axis=1)]
# sxx = fields['xx'].reshape((-1,3,3))/mass.reshape((-1,1,1))
# sxx = sxx[np.all(mass>0.0, axis=1)]
# mass = mass[mass>0.0]

# # print the error and show the figure
# print '\nGlobal error = %.10e' % np.abs(np.sum(fields['m'])-1.0)
# hlp.scatterEllipses(mass, cm[:,1:], cov=sxx[:,1:,1:], title='Example 5: Summing over voxels')

# In[ ]:
コード例 #2
0
hlp.scatterEllipses(mass, cm[:,1:], cov=sxx[:,1:,1:], nstd = 1.5,     ran=(box[0][0], box[1][0], box[0][1], box[1][1]), title='Example 5: Summing over voxels')


# In[ ]:

reload(psi)

psi.write(fields, 'test.out')

# print "read"
# fields = psi.readFields('test.out')


# In[ ]:

fields = psi.read('test.out')


    
# flatten arrays, divide by mass, and filter out voxels with zero mass
# mass = fields['m'].reshape((-1,1))
# cm = fields['x'].reshape((-1,3))/mass
# cm = cm[np.all(mass>0.0, axis=1)]
# sxx = fields['xx'].reshape((-1,3,3))/mass.reshape((-1,1,1))
# sxx = sxx[np.all(mass>0.0, axis=1)]
# mass = mass[mass>0.0]

# # print the error and show the figure
# print '\nGlobal error = %.10e' % np.abs(np.sum(fields['m'])-1.0)
# hlp.scatterEllipses(mass, cm[:,1:], cov=sxx[:,1:,1:], title='Example 5: Summing over voxels')