Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot arrays across faces without cutout #427

Merged
merged 11 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove rename var
  • Loading branch information
Mikejmnez committed Apr 29, 2024
commit b36235b5aff641105c50dbba6390c2d9a6c801a8
27 changes: 13 additions & 14 deletions oceanspy/tests/test_llc_rearrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as _np
import pytest
import xarray as _xr
from xarray.core.dataarray import DataArray, Dataset

# From OceanSpy
from oceanspy import open_oceandataset
Expand Down Expand Up @@ -57,8 +58,6 @@
Nx = od._ds.dims["X"]
Ny = od._ds.dims["Y"]

_datype = _xr.core.dataarray.DataArray
_dstype = _xr.core.dataset.Dataset

# WOCE standard sections
A01_lon = [
Expand Down Expand Up @@ -2233,17 +2232,17 @@ def test_error_range(ds, XRange, YRange):
@pytest.mark.parametrize(
"od, faces, expected, atype, XRange, YRange, opt, cuts, masking, size",
[
(od, faces, expected, _datype, None, None, False, 0, False, None),
(od, faces, expected, DataArray, None, None, False, 0, False, None),
(od, faces[:2], [0, 0, 0, 0], int, None, None, False, 0, False, None),
(od, faces[:6], [0, 0, 0, 0], int, None, None, False, 0, False, None),
(od, [0, 1, 2, 6], [2, 0, 0, 0], _datype, None, None, False, 0, False, None),
(od, faces[:7], [2, 5, 0, 0], _datype, None, None, False, 0, False, None),
(od, [0, 1, 2, 6], [2, 0, 0, 0], DataArray, None, None, False, 0, False, None),
(od, faces[:7], [2, 5, 0, 0], DataArray, None, None, False, 0, False, None),
(od, faces[6:], [0, 0, 7, 10], int, None, None, False, 0, False, None),
(
od,
[2, 6],
[2, 0, 0, 0],
_datype,
DataArray,
[-30, 22],
[60.0, 80.2],
True,
Expand All @@ -2255,7 +2254,7 @@ def test_error_range(ds, XRange, YRange):
od,
[2, 6],
[2, 0, 0, 0],
_datype,
DataArray,
[-30, 22],
[60.0, 80.2],
True,
Expand All @@ -2276,7 +2275,7 @@ def test_arc_connect(
ds, "YG", faces=faces, masking=masking, opt=opt, ranges=cuts
)
for i in range(len(DS)):
if isinstance(DS[i], _datype):
if isinstance(DS[i], atype):
assert _np.shape(DS[i]) == size
else:
arc_faces, *a, DS = arct_connect(ds, "YG", faces)
Expand Down Expand Up @@ -2417,7 +2416,7 @@ def test_transformation(od, faces, varList, XRange, YRange, X0, X1, Y0, Y1):
ARCT[2].append(DS[2])
ARCT[3].append(DS[3])
for i in range(len(ARCT)): # Not all faces survive the cutout
if isinstance(ARCT[i][0], _datype):
if isinstance(ARCT[i][0], DataArray):
ARCT[i] = _xr.merge(ARCT[i])

ds2, ds5, ds7, ds10 = ARCT
Expand Down Expand Up @@ -2453,7 +2452,7 @@ def test_shift_dataset(ds, dimc, dimg, init_c, final_c, init_g, final_g):
)
def test_rotate_dataset(ds, var, dimc, dimg, rot_dims):
nds = rotate_dataset(ds, dimc, dimg)
if isinstance(ds, _dstype):
if isinstance(ds, Dataset):
nvar = nds[var]
assert nvar.dims == rot_dims

Expand Down Expand Up @@ -2484,7 +2483,7 @@ def test_rotate_dataset(ds, var, dimc, dimg, rot_dims):
)
def test_rotate_vars(ds, var, dims0, rot_dims):
nds = rotate_vars(ds)
if isinstance(ds, _dstype):
if isinstance(ds, Dataset):
nvar = nds[var]
assert nvar.dims == rot_dims

Expand Down Expand Up @@ -2875,7 +2874,7 @@ def test_edge_arc_data(od, XRange, YRange, F_indx, Nx):
ARCT[3].append(DS[3])

for i in range(len(ARCT)): # Not all faces survive the cutout
if isinstance(ARCT[i][0], _datype):
if isinstance(ARCT[i][0], DataArray):
ARCT[i] = _xr.merge(ARCT[i])

face_order = _np.array([2, 5, 7, 10])
Expand Down Expand Up @@ -3751,7 +3750,7 @@ def test_ds_edge(od, ix, iy, faces, k, kwargs):
else:
if set([89]).issubset(set.union(set(ix), set(iy))):
_dim = "mooring"
assert isinstance(nds, _dstype)
assert isinstance(nds, Dataset)
assert len(nds.Xp1) == 2
assert len(nds.Yp1) == 2
assert len(nds.X) == 1
Expand Down Expand Up @@ -3791,7 +3790,7 @@ def test_arctic_eval(od, ix, iy):
_dim = "station"
nds = arctic_eval(od._ds, ix, iy, _dim)

assert isinstance(nds, _dstype)
assert isinstance(nds, Dataset)
assert len(nds.Xp1) == 2
assert len(nds.Yp1) == 2
assert len(nds.X) == 1
Expand Down