diff --git a/pyGPA/imagetools.py b/pyGPA/imagetools.py index dd46368..4f36266 100644 --- a/pyGPA/imagetools.py +++ b/pyGPA/imagetools.py @@ -34,18 +34,19 @@ def fftplot(fftim, d=1, pcolormesh=True, contour=False, levels=None, **kwargs): Any other kwargs are forwarded to the call to `pcolormesh`""" x, y = [fftbounds(n, d) for n in fftim.shape] + origin = kwargs.pop('origin', 'upper') if 'ax' in kwargs: ax = kwargs.pop('ax') else: fig, ax = plt.subplots() if pcolormesh: X, Y = np.meshgrid(x, y, indexing='xy') - im = ax.pcolormesh(X, Y, fftim.T, **kwargs) + im = ax.pcolormesh(X, Y, fftim.T, origin=origin, **kwargs) else: extent = [x[0], x[-1], y[0], y[-1]] - im = ax.imshow(fftim.T, extent=extent, origin='lower', **kwargs) + im = ax.imshow(fftim.T, extent=extent, origin=origin, **kwargs) if contour: - ax.contour(fftim.T, colors='white', origin='lower', + ax.contour(fftim.T, colors='white', extent=extent, alpha=0.3, levels=levels) ax.set_aspect('equal') return im diff --git a/pyGPA/property_extract.py b/pyGPA/property_extract.py index d80e835..423cff1 100644 --- a/pyGPA/property_extract.py +++ b/pyGPA/property_extract.py @@ -680,7 +680,7 @@ def moire_diffs(args): print(res2) if res2.cost < res.cost: res = res2 - if res.success and (res.cost <= 1e-10): + if res.success and (res.cost <= 0.1): params = res.x else: params = np.full(4, np.nan) diff --git a/tests/test_phase_unwrap.py b/tests/test_phase_unwrap.py index e1a1332..31ecd26 100644 --- a/tests/test_phase_unwrap.py +++ b/tests/test_phase_unwrap.py @@ -13,13 +13,14 @@ def test_equivalent_phase_unwrap_ref_phase_unwrap(kmax): N = 256 xx, yy = np.meshgrid(np.arange(N), np.arange(N), indexing='ij') - psi0 = (yy+xx)/(4*np.sqrt(2)) + psi0 = (yy+xx) / (4*np.sqrt(2)) psi = pu._wrapToPi(psi0) weight = np.ones_like(psi) result_phase_unwrap_ref = pu.phase_unwrap_ref( psi=psi, weight=weight, kmax=kmax ) - assert np.allclose(result_phase_unwrap_ref - result_phase_unwrap_ref.mean(), psi0-psi0.mean()) + assert np.allclose(result_phase_unwrap_ref - result_phase_unwrap_ref.mean(), + psi0 - psi0.mean()) result_phase_unwrap = pu.phase_unwrap( psi=psi, weight=weight, kmax=kmax ) @@ -33,7 +34,7 @@ def test_equivalent_phase_unwrap_ref_phase_unwrap(kmax): def test_equivalent_phase_unwrap_gaussian_weight(): N = 256 xx, yy = np.meshgrid(np.arange(N), np.arange(N), indexing='ij') - psi0 = (yy+xx)/(4*np.sqrt(2)) + psi0 = (yy+xx) / (4*np.sqrt(2)) psi = pu._wrapToPi(psi0) gaussian = np.exp(-((xx-N//2)**2+(yy-N//2)**2)/(0.3*N**2)) result_phase_unwrap = pu.phase_unwrap( @@ -50,7 +51,7 @@ def test_equivalent_phase_unwrap_gaussian_weight(): def test_equivalent_phase_unwrap_ref_prediff_phase_unwrap_prediff(kmax): N = 256 xx, yy = np.meshgrid(np.arange(N), np.arange(N), indexing='ij') - psi0 = (yy+xx)/(4*np.sqrt(2)) + psi0 = (yy+xx) / (4*np.sqrt(2)) psi = pu._wrapToPi(psi0) dx = np.diff(psi, axis=1) dy = np.diff(psi, axis=0)