Commit 89a37b1d authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'bugfix/workaround_pyfftw_bug' into 'master'

Bugfix/workaround pyfftw bug

Closes #71

See merge request !25
parents 4094e1ac e2bd1722
Pipeline #37935 passed with stages
in 10 minutes and 4 seconds
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
History History
======= =======
1.7.5 (2021-01-28)
------------------
* Implemented a workaround for #71 (pyFFTW RuntimeError: Undefined plan with nthreads. This is a bug).
Pin pyFFTW to <0.13.0. (!25)
1.7.4 (2021-12-15) 1.7.4 (2021-12-15)
------------------ ------------------
...@@ -653,7 +660,7 @@ History ...@@ -653,7 +660,7 @@ History
0.8.3 (2018-03-07) 0.8.3 (2018-03-07)
------------------ ------------------
* Fixed ValueError as reported in https://gitext.gfz-potsdam.de/EnMAP/sicor/issues/22. * Fixed ValueError as reported in https://git.gfz-potsdam.de/EnMAP/sicor/issues/22.
0.8.2 (2018-01-23) 0.8.2 (2018-01-23)
......
...@@ -1141,23 +1141,28 @@ class COREG(object): ...@@ -1141,23 +1141,28 @@ class COREG(object):
PLT.subplot_imshow([np.real(in_arr0).astype(np.float32), np.real(in_arr1).astype(np.float32)], PLT.subplot_imshow([np.real(in_arr0).astype(np.float32), np.real(in_arr1).astype(np.float32)],
['FFTin ' + self.ref.title, 'FFTin ' + self.shift.title], grid=True) ['FFTin ' + self.ref.title, 'FFTin ' + self.shift.title], grid=True)
fft_arr0, fft_arr1 = None, None
if pyfftw and self.fftw_works is not False: # if module is installed and working if pyfftw and self.fftw_works is not False: # if module is installed and working
fft_arr0 = pyfftw.FFTW(in_arr0, np.empty_like(in_arr0), axes=(0, 1))() try:
fft_arr1 = pyfftw.FFTW(in_arr1, np.empty_like(in_arr1), axes=(0, 1))() fft_arr0 = pyfftw.FFTW(in_arr0, np.empty_like(in_arr0), axes=(0, 1))()
fft_arr1 = pyfftw.FFTW(in_arr1, np.empty_like(in_arr1), axes=(0, 1))()
# catch empty output arrays (for some reason this happens sometimes..) -> use numpy fft # catch empty output arrays (for some reason this happens sometimes..) -> use numpy fft
# => this is caused by the call of pyfftw.FFTW. Exactly in that moment the input array in_arr0 is # => this is caused by the call of pyfftw.FFTW. Exactly in that moment the input array
# overwritten with zeros (maybe this is a bug in pyFFTW?) # in_arr0 is overwritten with zeros (maybe this is a bug in pyFFTW?)
if self.fftw_works in [None, True] and (np.std(fft_arr0) == 0 or np.std(fft_arr1) == 0): if np.std(fft_arr0) == 0 or np.std(fft_arr1) == 0:
raise RuntimeError('FFTW result is unexpectedly empty.')
self.fftw_works = True
except RuntimeError:
self.fftw_works = False self.fftw_works = False
# recreate input arrays and use numpy fft as fallback # recreate input arrays and use numpy fft as fallback
in_arr0 = im0[ymin:ymax, xmin:xmax].astype(precision) in_arr0 = im0[ymin:ymax, xmin:xmax].astype(precision)
in_arr1 = im1[ymin:ymax, xmin:xmax].astype(precision) in_arr1 = im1[ymin:ymax, xmin:xmax].astype(precision)
fft_arr0 = np.fft.fft2(in_arr0)
fft_arr1 = np.fft.fft2(in_arr1) if self.fftw_works is False or fft_arr0 is None or fft_arr1 is None:
else:
self.fftw_works = True
else:
fft_arr0 = np.fft.fft2(in_arr0) fft_arr0 = np.fft.fft2(in_arr0)
fft_arr1 = np.fft.fft2(in_arr1) fft_arr1 = np.fft.fft2(in_arr1)
......
...@@ -40,7 +40,7 @@ to resolve the following dependencies before the pip installer is run: ...@@ -40,7 +40,7 @@ to resolve the following dependencies before the pip installer is run:
* matplotlib * matplotlib
* numpy * numpy
* pandas * pandas
* pyfftw * pyfftw <0.13.0
* pykrige * pykrige
* pyproj >2.2.0 * pyproj >2.2.0
* scikit-image >=0.16.0 * scikit-image >=0.16.0
......
...@@ -52,7 +52,7 @@ req = [ ...@@ -52,7 +52,7 @@ req = [
'numpy', 'numpy',
'pandas', 'pandas',
'plotly', 'plotly',
'pyfftw', 'pyfftw<0.13.0', # https://github.com/pyFFTW/pyFFTW/issues/294
'pykrige', 'pykrige',
'pyproj>2.2.0', 'pyproj>2.2.0',
'py_tools_ds>=0.18.0', 'py_tools_ds>=0.18.0',
......
...@@ -18,7 +18,7 @@ dependencies: ...@@ -18,7 +18,7 @@ dependencies:
- numpy - numpy
- pandas - pandas
- plotly - plotly
- pyfftw - pyfftw<0.13.0
- pykrige - pykrige
- pyproj>2.2.0 - pyproj>2.2.0
- py-tools-ds>=0.18.0 - py-tools-ds>=0.18.0
......
...@@ -324,13 +324,17 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase): ...@@ -324,13 +324,17 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
'ignore', category=UserWarning, message='Matplotlib is currently using agg, ' 'ignore', category=UserWarning, message='Matplotlib is currently using agg, '
'which is a non-GUI backend, so cannot show the figure.') 'which is a non-GUI backend, so cannot show the figure.')
CR.show_cross_power_spectrum() CR.show_cross_power_spectrum()
CR.show_cross_power_spectrum(interactive=True)
CR.show_matchWin(interactive=False, after_correction=None) CR.show_matchWin(interactive=False, after_correction=None)
CR.show_matchWin(interactive=False, after_correction=True) CR.show_matchWin(interactive=False, after_correction=True)
CR.show_matchWin(interactive=False, after_correction=False) CR.show_matchWin(interactive=False, after_correction=False)
CR.show_matchWin(interactive=True, after_correction=None) # only works if test is started with ipython try:
CR.show_matchWin(interactive=True, after_correction=True) __IPYTHON__ # noqa
CR.show_matchWin(interactive=True, after_correction=False) CR.show_cross_power_spectrum(interactive=True)
CR.show_matchWin(interactive=True, after_correction=None) # only works if test is started with ipython
CR.show_matchWin(interactive=True, after_correction=True)
CR.show_matchWin(interactive=True, after_correction=False)
except NameError:
pass
CR.show_image_footprints() CR.show_image_footprints()
def test_correct_shifts_without_resampling(self): def test_correct_shifts_without_resampling(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment