Ejemplo n.º 1
0
def test_is_symetric():
    from xoverturning.compfunc import is_symetric

    names = define_names(model="mom6", vertical="z")
    assert is_symetric(ds_sym, names)
    assert not is_symetric(ds_asym, names)
    with pytest.raises(ValueError):
        is_symetric(ds_wrong, names)
Ejemplo n.º 2
0
def test_interp_to_grid_center(DS):
    from xoverturning.compfunc import interp_to_grid_center

    names = define_names(model="mom6", vertical="z")
    u, v = interp_to_grid_center(DS, DS["umo"], DS["vmo"], names)
    assert isinstance(u, xr.core.dataarray.DataArray)
    assert isinstance(v, xr.core.dataarray.DataArray)
    assert "yh" in u.dims
    assert "xh" in u.dims
    assert "yh" in v.dims
    assert "xh" in v.dims
Ejemplo n.º 3
0
def test_rotate_velocities_to_geo(DS, DSANGLE):
    from xoverturning.compfunc import rotate_velocities_to_geo

    names = define_names(model="mom6", vertical="z")
    with pytest.raises(ValueError):
        u_EW, v_EW = rotate_velocities_to_geo(DS, DS["umo"], DS["vmo"], names)

    ds = xr.merge([DS, DSANGLE])

    u_EW, v_EW = rotate_velocities_to_geo(ds, ds["umo"], ds["vmo"], names)
    assert isinstance(u_EW, xr.core.dataarray.DataArray)
    assert isinstance(v_EW, xr.core.dataarray.DataArray)
    assert "yh" in u_EW.dims
    assert "xh" in u_EW.dims
    assert "yh" in v_EW.dims
    assert "xh" in v_EW.dims
Ejemplo n.º 4
0
def test_select_basin(BASIN):
    from xoverturning.compfunc import select_basins

    if ds_1x1deg is None:
        return

    names = define_names(model="mom6", vertical="z")
    maskbasin, maskmoc = select_basins(ds_1x1deg,
                                       names,
                                       basin=BASIN,
                                       lon="lon",
                                       lat="lat")
    assert isinstance(maskbasin, xr.core.dataarray.DataArray)
    assert isinstance(maskmoc, xr.core.dataarray.DataArray)

    maskbasin, maskmoc = select_basins(ds_1x1deg,
                                       names,
                                       basin=BASIN,
                                       lon="lon",
                                       lat="lat",
                                       vertical="rho2")
    assert maskmoc is None
Ejemplo n.º 5
0
def test_define_grid(DS):
    from xoverturning.compfunc import define_grid

    names = define_names(model="mom6", vertical="z")
    grid = define_grid(DS, names)
    assert isinstance(grid, xgcm.Grid)
Ejemplo n.º 6
0
def test_compute_streamfunction(DS):
    from xoverturning.compfunc import compute_streamfunction

    names = define_names(model="mom6", vertical="z")
    psi = compute_streamfunction(DS, names, transport="vmo")
    assert isinstance(psi, xr.core.dataarray.DataArray)