Skip to content
Merged
Changes from all commits
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
28 changes: 14 additions & 14 deletions docs/examples/example_peninsula.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,25 @@

# Create the fields
x, y = np.meshgrid(La, Wa, sparse=True, indexing="xy")
P = (u0 * R**2 * y / ((x - x0) ** 2 + y**2) - u0 * y) / 1e3
P = u0 * R**2 * y / ((x - x0) ** 2 + y**2) - u0 * y

# Set land points to zero
landpoints = P >= 0.0
P[landpoints] = 0.0

if grid_type == "A":
U = u0 - u0 * R**2 * ((x - x0) ** 2 - y**2) / (((x - x0) ** 2 + y**2) ** 2)
V = -2 * u0 * R**2 * ((x - x0) * y) / (((x - x0) ** 2 + y**2) ** 2)
U[landpoints] = 0.0
V[landpoints] = 0.0
elif grid_type == "C":
U = np.zeros(P.shape)
V = np.zeros(P.shape)
V[:, 1:] = P[:, 1:] - P[:, :-1]
U[1:, :] = -(P[1:, :] - P[:-1, :])
V[:, 1:] = (P[:, 1:] - P[:, :-1]) / (La[1] - La[0])
U[1:, :] = -(P[1:, :] - P[:-1, :]) / (Wa[1] - Wa[0])

Check warning on line 75 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L74-L75

Added lines #L74 - L75 were not covered by tests
else:
raise RuntimeError(f"Grid_type {grid_type} is not a valid option")

# Set land points to NaN
landpoints = P >= 0.0
P[landpoints] = np.nan
U[landpoints] = np.nan
V[landpoints] = np.nan

# Convert from m to lat/lon for spherical meshes
lon = La / 1852.0 / 60.0 if mesh == "spherical" else La
lat = Wa / 1852.0 / 60.0 if mesh == "spherical" else Wa
Expand Down Expand Up @@ -185,7 +185,7 @@
pset = peninsula_example(fieldset, outfile, 5, mode=mode, degree=1)
# Test advection accuracy by comparing streamline values
err_adv = np.abs(pset.p_start - pset.p)
assert (err_adv <= 1.0e-3).all()
assert (err_adv <= 1.0).all()

Check warning on line 188 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L188

Added line #L188 was not covered by tests
# Test Field sampling accuracy by comparing kernel against Field sampling
err_smpl = np.array(
[
Expand All @@ -196,7 +196,7 @@
for i in range(pset.size)
]
)
assert (err_smpl <= 1.0e-3).all()
assert (err_smpl <= 1.0).all()

Check warning on line 199 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L199

Added line #L199 was not covered by tests


@pytest.mark.parametrize(
Expand All @@ -213,7 +213,7 @@
# Test advection accuracy by comparing streamline values
err_adv = np.array([abs(p.p_start - p.p) for p in pset])

tol = {"scipy": 3.0e-1, "jit": 1.0e-1}.get(mode)
tol = {"scipy": 3.0e2, "jit": 1.0e2}.get(mode)

Check warning on line 216 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L216

Added line #L216 was not covered by tests
assert (err_adv <= tol).all()


Expand All @@ -239,7 +239,7 @@
pset = peninsula_example(fieldset, outfile, 5, mode=mode, degree=1)
# Test advection accuracy by comparing streamline values
err_adv = np.abs(pset.p_start - pset.p)
assert (err_adv <= 1.0e-3).all()
assert (err_adv <= 1.0).all()

Check warning on line 242 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L242

Added line #L242 was not covered by tests
# Test Field sampling accuracy by comparing kernel against Field sampling
err_smpl = np.array(
[
Expand All @@ -250,7 +250,7 @@
for i in range(pset.size)
]
)
assert (err_smpl <= 1.0e-3).all()
assert (err_smpl <= 1.0).all()

Check warning on line 253 in docs/examples/example_peninsula.py

View check run for this annotation

Codecov / codecov/patch

docs/examples/example_peninsula.py#L253

Added line #L253 was not covered by tests


def main(args=None):
Expand Down
Loading