예제 #1
0
def test_vec2scal():
    data = io.create_sample_dataset()
    data.piv.vec2scal()
    data.piv.vec2scal(property='curl')
    data.piv.vec2scal(property='ke')
    assert len(data.attrs['variables']) == 5
    assert data.attrs['variables'][-1] == 'ke'
예제 #2
0
def test_set_get_dt():
    """ tests setting the new dt """
    data = io.create_sample_dataset()
    assert data.attrs['dt'] == 1.0
    assert data.piv.get_dt == 1.0
    data.piv.set_dt(2.0)
    assert data.attrs['dt'] == 2.0
예제 #3
0
def test_vec2scal():
    data = io.create_sample_dataset()
    data.piv.vec2scal()
    data.piv.vec2scal(property="curl")
    data.piv.vec2scal(property="ke")
    assert len(data.attrs["variables"]) == 5
    assert data.attrs["variables"][-1] == "ke"
예제 #4
0
def test_set_get_dt():
    """ tests setting the new dt """
    data = io.create_sample_dataset()
    assert data.attrs['dt'] == 1.0
    assert data.piv.get_dt == 1.0
    data.piv.set_dt(2.0)
    assert data.attrs['dt'] == 2.0
예제 #5
0
def test_crop():
    """ tests crop """
    _c = _a.piv.crop([5, 15, -5, -15])
    assert _c.u.shape == (32, 32, 1)

    _c = io.create_sample_dataset()
    _c = _c.sel(x=slice(35, 70), y=slice(30, 90))
    assert _c.u.shape == (2, 2, 5)  # note the last dimension is preserved
예제 #6
0
def test_crop():
    """ tests crop """
    _c = _a.piv.crop([.6, 19.,-.6,-19.])
    assert _c.u.shape == (59,59,1)
    
    _c = io.create_sample_dataset()
    _c = _c.sel(x = slice(30,90),y=slice(60,80))
    assert _c.u.shape == (2,2,5) # note the last dimension is preserved
예제 #7
0
def test_crop():
    """ tests crop """
    _c = _a.piv.crop([.6, 19., -.6, -19.])
    assert _c.u.shape == (59, 59, 1)

    _c = io.create_sample_dataset()
    _c = _c.sel(x=slice(30, 90), y=slice(60, 80))
    assert _c.u.shape == (2, 2, 5)  # note the last dimension is preserved
예제 #8
0
def load_data(data_selectbox='Demo'):
    if data_selectbox == 'Demo':
        data = io.create_sample_dataset()
    elif data_selectbox == 'Jet':
        data = io.load_directory(data_path, basename='Run*', ext='.vec')
    elif data_selectbox == 'Canopy':
        data = io.load_directory(os.path.join(data_path, 'urban_canopy'),
                                 ext='.vc7')

    return data
예제 #9
0
def test_shear():
    """ tests shear estimate """
    
    data = io.create_sample_field()
    data.piv.shear()
    assert data['w'][0,0] == 0.0 
    
    data = io.create_sample_dataset()
    data.piv.vec2scal(property='ke')
    data.piv.vec2scal(property='tke') # now defined
    assert data.attrs['variables'][-1] == 'tke'

    
    _a.piv.vec2scal(property='curl')
예제 #10
0
def test_multiply():
    """ tests subtraction """
    data = io.create_sample_dataset()
    tmp = data * 3.5
    assert tmp['u'][0, 0, 0] == 3.5
예제 #11
0
def test_subtract():
    """ tests subtraction """
    data = io.create_sample_dataset()
    tmp = data - data
    assert tmp['u'][0, 0, 0] == 0.0
예제 #12
0
def test_subtract():
    """ tests subtraction """
    data = io.create_sample_dataset()
    tmp = data - data
    assert tmp['u'][0,0,0] == 0.0
예제 #13
0
def test_vec2scal():
    data = io.create_sample_dataset()
    data.piv.vec2scal()
    # tests that first data['w'] exists and then 
    # the first value is 0.0
    assert data['w'][0,0,0] == 0.0
예제 #14
0
def test_mean():
    data = io.create_sample_dataset(10)
    assert np.allclose(data.piv.average.u.median(), 4.5)
예제 #15
0
def test_tke():
    """ tests TKE """
    data = io.create_sample_dataset()
    data.piv.vec2scal(property="ke")
    data.piv.vec2scal(property="tke")  # now defined
    assert data.attrs["variables"][-1] == "tke"
예제 #16
0
def test_mean():
    data = io.create_sample_dataset(10)
    assert data.piv.average.u.median() == 4.0
예제 #17
0
def test_mean():
    data = io.create_sample_dataset(10)
    assert data.piv.average.u.median() == 4.0
예제 #18
0
def test_add():
    data = io.create_sample_dataset()
    tmp = data + data
    assert tmp['u'][0,0,0] == 2.0
예제 #19
0
def test_vec2scal():
    data = io.create_sample_dataset()
    data.piv.vec2scal()
    # tests that first data['w'] exists and then
    # the first value is 0.0
    assert data['w'][0, 0, 0] == 0.0
예제 #20
0
def test_multiply():
    """ tests subtraction """
    data = io.create_sample_dataset()
    tmp = data * 3.5
    assert tmp['u'][0,0,0] == 3.5
예제 #21
0
def test_add():
    data = io.create_sample_dataset()
    tmp = data + data
    assert tmp['u'][0, 0, 0] == 2.0
예제 #22
0
def test_create_sample_dataset(n=3):
    data = io.create_sample_dataset(n=n)
    assert data.dims["t"] == 3
    assert np.allclose(data["t"], np.arange(3))
예제 #23
0
파일: test_io.py 프로젝트: OpenPIV/pivpy
def test_create_sample_dataset(n=3):
    data = io.create_sample_dataset(n=n)
    assert data.dims['t'] == 3
    assert np.allclose(data['t'],np.arange(3))