openPIV示例代码错误

时间:2017-05-26 04:20:46

标签: python-2.7

我正在研究openPIV的示例代码。该版本是最新的(openpiv-python-master)。我收到了一个错误; AttributeError:'module'对象没有属性'validation' 虽然我设置了路径,但似乎openPIV找不到validation.py。 你能让我知道如何解决它吗?

import openpiv.tools
import openpiv.process
import openpiv.scaling
import numpy as np
import sys
sys.path.append('/Users/myname/openpiv-python-master/openpiv')

filedir = '/Users/myname/tutorial-part1/'
frame_a  = openpiv.tools.imread( filedir + 'exp1_001_a.bmp' )
frame_b  = openpiv.tools.imread( filedir + 'exp1_001_b.bmp' )

u, v, sig2noise = openpiv.process.extended_search_area_piv( frame_a.astype(np.int32), frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' )
x, y = openpiv.process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 1.3 )
u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)
x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
openpiv.tools.save(x, y, u, v, mask, 'exp1_001.txt' )
openpiv.tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)

1 个答案:

答案 0 :(得分:2)

我有同样的错误。您只需要在示例代码中导入它。只需添加这些行。

import openpiv.validation
import openpiv.filters