Пример #1
0
def HIO(rho, mod, support, mask, b=0.9, positive=False, debug=False):
    if (debug):
        print ("support")
        plt.imshow(det.centerFFTImage(support), interpolation='nearest')
        plt.colorbar()
        plt.show()
    modRho=modulusProjection(rho, mod, mask)
    if (positive):
        support = makePositiveMask(modRho*np.array(support))
    suppModRho=modRho*np.array(support)
    hiodiff=(rho-b*modRho)*invertMask(support)
    if (debug):
        print ("suppModRho")
        plt.imshow(det.centerFFTImage(suppModRho.real), interpolation='nearest')
        plt.colorbar()
        plt.show()
        print ("hiodiff")
        plt.imshow(det.centerFFTImage(hiodiff.real), interpolation='nearest')
        plt.colorbar()
        plt.show()
        print ("modRho")
        plt.imshow(det.centerFFTImage(modRho.real), interpolation='nearest')
        plt.colorbar()
        plt.show()
        print ("rho")
        plt.imshow(det.centerFFTImage(rho.real), interpolation='nearest')
        plt.colorbar()
        plt.show()
        print ("invsupport")
        plt.imshow(det.centerFFTImage(invertMask(support)), interpolation='nearest')
        plt.colorbar()
        plt.show()
        
    return  suppModRho+hiodiff
Пример #2
0
     [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
     [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]]

print "Real Rho"
plt.imshow(realrho, interpolation='nearest')
plt.show()

f=np.fft.fft2(realrho)
# print "scattering factor"
# print f

Iobs= np.ndarray.conjugate(f)*f

print "Observed Intensity"
# print Iobs
plt.imshow(det.centerFFTImage(Iobs.real), interpolation='nearest')
plt.show()

mod = np.sqrt(Iobs.real)
mod = mod.real

f0=mod*np.exp(1j*np.array([[np.random.random()*2*np.pi for i in range(len(j))] for j in Iobs]))

# print f0

myRho = np.fft.ifft2(f0)
# myRho = np.array(support)+1j*0.
# myRho=zeroPhase(myRho)
# myRho=makePositive(myRho)
print "Initial Rho"
# print myRho
Пример #3
0
support = [[1., 1., 1., 0., 0., 1., 1., 1.], [1., 1., 0., 0., 0., 0., 1., 1.],
           [1., 0., 0., 0., 0., 0., 0., 1.], [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.], [1., 0., 0., 0., 0., 0., 0., 1.],
           [1., 1., 0., 0., 0., 0., 1., 1.], [1., 1., 1., 0., 0., 1., 1., 1.]]

print "Real Rho"
plt.imshow(realrho, interpolation='nearest')
plt.show()

f = np.fft.fft2(realrho)

Iobs = np.ndarray.conjugate(f) * f

print "Observed Intensity"
plt.imshow(det.centerFFTImage(Iobs.real), interpolation='nearest')
plt.show()

mod = np.sqrt(Iobs)
mod = mod.real

print "Autocorrelation"
# plt.imshow(centerImage(np.absolute(np.fft.ifft2(Iobs))), interpolation = "nearest")
# plt.show()
autocorr = ip.autoCorrelation(Iobs)
support = ip.makePositiveMask(autocorr)
plt.imshow(det.centerFFTImage(support), interpolation="nearest")
plt.show()

f0 = np.vectorize(complex)(
    np.sqrt(Iobs),