User Tools

Site Tools


eman2:numpy

This is an old revision of the document!


Using EMAN2 with NumPy

NymPy interoperability is well supported, and with EMAN3 modules, JAX as well.

Note that converting an EMData object to a NumPy array produces an object which shares the memory of the EMData array, but when converting NumPy to EMAN2 a copy is made :

from EMAN2 import *
import numpy as np

emd=test_image()  # an EMData object
npd=to_numpy(emd)

npd*=2    # This will modify the values in BOTH the EMData object and the NumPy object!



npd2=np.zeroes((128,128))
emd2=from_numpy(npd2).      # data is copied to make a new EMData object

npd2+=1   # Modifies the NumPy array, NOT the EMData object
eman2/numpy.1750354758.txt.gz · Last modified: by steveludtke