OpenPIV / openpiv-python

OpenPIV is an open source Particle Image Velocimetry analysis software written in Python and Cython
http://www.openpiv.net
GNU General Public License v3.0
248 stars 143 forks source link

One program error in the document. #231

Closed WK-Luo closed 2 years ago

WK-Luo commented 2 years ago

I found an error on the "Basics of Particle Image Velocimetry (PIV)" page, as shown in the code attached. I guess that is because the program runs every time people open the page, and the picture was deleted. Or just save the wrong version. Although it's a tiny mistake, it can still confuse beginners. https://openpiv.readthedocs.io/en/latest/src/piv_basics.html

[2]:
# load the images:
a = imread('B005_1.tif')
b = imread('B005_2.tif')

figure(figsize=(12,10))
subplot(1,2,1)
imshow(a,cmap=cm.gray)
subplot(1,2,2)
imshow(b,cmap=cm.gray)
# imshow(c_[a,b],cmap=cm.gray)

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-652973821a4e> in <module>
      1 # load the images:
----> 2 a = imread('B005_1.tif')
      3 b = imread('B005_2.tif')
      4
      5 figure(figsize=(12,10))

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
     46
     47     with file_or_url_context(fname) as fname:
---> 48         img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
     49
     50     if not hasattr(img, 'ndim'):

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
    205                                (plugin, kind))
    206
--> 207     return func(*args, **kwargs)
    208
    209

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/skimage/io/_plugins/tifffile_plugin.py in imread(fname, **kwargs)
     28         kwargs['key'] = kwargs.pop('img_num')
     29
---> 30     return tifffile_imread(fname, **kwargs)

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/tifffile/tifffile.py in imread(files, aszarr, **kwargs)
    779
    780         if isinstance(files, (str, os.PathLike)) or hasattr(files, 'seek'):
--> 781             with TiffFile(files, **kwargs_file) as tif:
    782                 if aszarr:
    783                     return tif.aszarr(**kwargs)

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/tifffile/tifffile.py in __init__(self, arg, mode, name, offset, size, _multifile, _useframes, _master, **kwargs)
   2895             raise ValueError(f'invalid mode {mode!r}')
   2896
-> 2897         fh = FileHandle(arg, mode=mode, name=name, offset=offset, size=size)
   2898         self._fh = fh
   2899         self._multifile = bool(_multifile)

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/tifffile/tifffile.py in __init__(self, file, mode, name, offset, size)
   9207         self.is_file = None
   9208         self._lock = NullContext()
-> 9209         self.open()
   9210
   9211     def open(self):

~/miniconda3/envs/openpiv/lib/python3.7/site-packages/tifffile/tifffile.py in open(self)
   9220             self._file = os.path.realpath(self._file)
   9221             self._dir, self._name = os.path.split(self._file)
-> 9222             self._fh = open(self._file, self._mode)
   9223             self._close = True
   9224             if self._offset is None:

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/Downloads/repos/openpiv-python/openpiv/docs/src/B005_1.tif'
alexlib commented 2 years ago

These images exist - but as the document proposes the user has to download them:

http://www.pivchallenge.org/pub/B/B005_1.tif http://www.pivchallenge.org/pub/B/B005_1.tif

The notebook rendered properly on the github

https://github.com/openpiv/openpiv-python/blob/master/openpiv/docs/src/piv_basics.ipynb

alexlib commented 2 years ago

thanks @WK-Luo it's resolved now.