Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions tests/deconv1d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,28 @@
print info
print '-----------------------------------------------------------------'

p.subplot(311)
p.title('Real')
p.plot(n.abs(cln), 'b')
p.plot(n.abs(img), 'k.')
p.plot(n.abs(img - cln), 'r')

img = n.array([0,0,0,4j,6j,4j,0,0,2+2j,3+3j,2+2j,0], dtype=n.complex)
ker = n.array([3,2,0,0,0,0,0,0,0,0,0,2], dtype=n.complex)

print 'CMPLX TEST:'
print 'img', img
print 'ker', ker
mdl, info = a.deconv.clean(img, ker)
cln, info = a.deconv.clean(img, ker)
print 'cln', cln
print info
print '-----------------------------------------------------------------'
p.subplot(312)
p.title('Complex, real part')
p.plot(cln.real, 'b',label='Model')
p.plot(img.real, 'k.',label='Image')
p.plot((img - cln).real, 'r',label='Resid')
p.legend()

SIZE = 16
img = n.zeros((SIZE,), n.complex)
Expand All @@ -39,7 +51,9 @@
print 'cln', cln
print info

p.plot(n.abs(cln), 'b')
p.plot(n.abs(img), 'k.')
p.plot(n.abs(img - cln), 'r')
p.subplot(313)
p.title('Complex, imaginary part')
p.plot(cln.imag, 'b')
p.plot(img.imag, 'k.')
p.plot((img - cln).imag, 'r')
p.show()
32 changes: 18 additions & 14 deletions tests/deconv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self):
i[30:40,30:40] = .1
self.i = i
self.b = a.img.gaussian_beam(2, shape=i.shape)
self.b[0,0] = .05
#self.b[0,0] = .05

self.d = n.abs(n.fft.ifft2(n.fft.fft2(i) * n.fft.fft2(self.b)))
ns = n.random.normal(scale=NOISE, size=i.shape)
Expand All @@ -24,23 +24,27 @@ def setUp(self):
def test_clean(self):
"""Test that the standard clean deconvolution runs"""
#print 'Clean'
p.subplot(131)
c,info = a.deconv.clean(self.d, self.b, verbose=False)
p.subplot(221)
c,info = a.deconv.clean(self.d, self.b, verbose=True,tol=1e-7,stop_if_div=False)
print "max i,c,i-c"
print self.i.max(),c.max(),(self.i-c).max()
# p.imshow(n.log10(self.i),vmin=-5, vmax=1)
p.imshow(self.i,vmin=0.1,vmax=5)
p.title('model')
p.imshow(n.log10(self.i),vmin=-5, vmax=1)
#p.imshow(self.i,vmin=0.1,vmax=5)
p.title('Dirty Image')

p.subplot(132)
p.imshow(c,vmin=0.1,vmax=5)
# p.imshow(n.log10(c),vmin=-5, vmax=1)
p.title('cc')
p.subplot(222)
p.imshow(n.log10(n.fft.fftshift(self.b)),vmin=-5,vmax=1)
p.title('Dirty Beam')

p.subplot(133)
# p.imshow(n.log10(c - self.i),vmin=-5, vmax=1)
p.imshow(c-self.i,vmin=0.1,vmax=5)
p.title('cc - model')
p.subplot(223)
#p.imshow(c,vmin=0.1,vmax=5)
p.imshow(n.log10(c),vmin=-5, vmax=1)
p.title('Clean Components')

p.subplot(224)
p.imshow(n.log10(c - self.i),vmin=-5, vmax=1)
#p.imshow(c-self.i,vmin=0.1,vmax=5)
p.title('Resid')
#print n.sum(c - self.i)
#p.title('CLEAN')
#p.imshow(n.log10(c), vmin=-5, vmax=1)
Expand Down