示例#1
0
def test_load_vec():
    fname = "Run000001.T000.D000.P000.H001.L.vec"
    data = io.load_vec(os.path.join(path, "Insight", fname))
    assert data["u"].shape == (63, 63, 1)
    assert data["u"][0, 0, 0] == 0.0
    assert np.allclose(data.coords["x"][0], 0.31248)
    assert "t" in data.dims
示例#2
0
def test_loadopenpivtxt():
    data = io.load_vec(os.path.join(path, "openpiv", "exp1_001_b.txt"))
示例#3
0
def test_quiver_openpiv_vec():
    filename = pkg.resource_filename("pivpy", "data/openpiv/exp1_001_b.vec")
    # load data
    _d = io.load_vec(filename)
    _d.piv.quiver()
示例#4
0
from pivpy import io, graphics, pivpy
import pkg_resources as pkg

# f1 = 'Run000001.T000.D000.P000.H001.L.vec'
filename = pkg.resource_filename(
    "pivpy", "data/Insight/Run000001.T000.D000.P000.H001.L.vec")
# load data
_d = io.load_vec(filename)


def test_showscal():
    graphics.showscal(_d, property="ke")


def test_quiver():
    graphics.quiver(_d)
    _d.piv.quiver()


def test_xarray_plot():
    _d.piv.vec2scal(property="curl")
    _d["w"].isel(t=0).plot.pcolormesh()


def test_histogram():
    graphics.histogram(_d)


def test_showf():
    graphics.showf(_d)
示例#5
0
def test_pan():
    """ test a shift by dx,dy using pan method """
    _a = io.load_vec(os.path.join(path, f1))
    _c = _a.piv.pan(1.0, -1.0)  # note the use of .piv.
    assert np.allclose(_c.coords["x"][0], 1.312480)
    assert np.allclose(_c.coords["y"][0], -1.31248)
示例#6
0
def test_curl():
    """ tests curl that is also vorticity """
    _a = io.load_vec(os.path.join(path, f1))
    _a.piv.vec2scal(property="curl")
    assert _a.attrs["variables"][-1] == "vorticity"
示例#7
0
# test_methods.py
from pivpy import io, pivpy
import numpy as np
import pkg_resources as pkg

import os

f1 = "Run000001.T000.D000.P000.H001.L.vec"
f2 = "Run000002.T000.D000.P000.H001.L.vec"
path = pkg.resource_filename("pivpy", "data/Insight")

_a = io.load_vec(os.path.join(path, f1))
_b = io.load_vec(os.path.join(path, f2))


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


def test_pan():
    """ test a shift by dx,dy using pan method """
    _a = io.load_vec(os.path.join(path, f1))
    _c = _a.piv.pan(1.0, -1.0)  # note the use of .piv.
    assert np.allclose(_c.coords["x"][0], 1.312480)
    assert np.allclose(_c.coords["y"][0], -1.31248)