Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions docs/getting_started/tutorial_output.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that if you are running Parcels on multiple processors with `mpirun`, you will need to concatenate the files of each processor, see also the [MPI documentation](https://docs.oceanparcels.org/en/latest/examples/documentation_MPI.html#Reading-in-the-ParticleFile-data-in-zarr-format).\n",
"\n",
"Also, once you have loaded the data as an `xarray` DataSet using `xr.open_zarr()`, you can always save the file to NetCDF if you prefer with the `.to_netcdf()` method.\n"
"Once you have loaded the data as an `xarray` DataSet using `xr.open_zarr()`, you can always save the file to NetCDF if you prefer with the `.to_netcdf()` method.\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"id": "4",
"metadata": {},
"source": [
"## How to save the output of an MPI ocean parcels run to a single zarr dataset\n"
"## (TODO: Remove section now that we don't support MPI) How to save the output of an MPI ocean parcels run to a single zarr dataset\n"
]
},
{
Expand Down
207 changes: 0 additions & 207 deletions docs/user_guide/examples_v3/documentation_MPI.ipynb

This file was deleted.

43 changes: 9 additions & 34 deletions docs/user_guide/examples_v3/example_stommel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ def AgeP(particle, fieldset, time): # pragma: no cover
particle.delete()


def simple_partition_function(coords, mpi_size=1):
"""A very simple partition function that assigns particles to processors (for MPI testing purposes))"""
return np.linspace(0, mpi_size, coords.shape[0], endpoint=False, dtype=np.int32)


def stommel_example(
npart=1,
verbose=False,
Expand All @@ -101,7 +96,6 @@ def stommel_example(
outfile="StommelParticle.zarr",
repeatdt=None,
maxage=None,
custom_partition_function=False,
):
parcels.timer.fieldset = parcels.timer.Timer(
"FieldSet", parent=parcels.timer.stommel
Expand All @@ -125,27 +119,15 @@ def stommel_example(
]
MyParticle = parcels.Particle.add_variables(extra_vars)

if custom_partition_function:
pset = parcels.ParticleSet.from_line(
fieldset,
size=npart,
pclass=MyParticle,
repeatdt=repeatdt,
start=(10e3, 5000e3),
finish=(100e3, 5000e3),
time=0,
partition_function=simple_partition_function,
)
else:
pset = parcels.ParticleSet.from_line(
fieldset,
size=npart,
pclass=MyParticle,
repeatdt=repeatdt,
start=(10e3, 5000e3),
finish=(100e3, 5000e3),
time=0,
)
pset = parcels.ParticleSet.from_line(
fieldset,
size=npart,
pclass=MyParticle,
repeatdt=repeatdt,
start=(10e3, 5000e3),
finish=(100e3, 5000e3),
time=0,
)

if verbose:
print(f"Initial particle positions:\n{pset}")
Expand Down Expand Up @@ -245,12 +227,6 @@ def main(args=None):
type=int,
help="max age of the particles (after which particles are deleted)",
)
p.add_argument(
"-cpf",
"--custom_partition_function",
default=False,
help="Use a custom partition_function (for MPI testing purposes)",
)
args = p.parse_args(args)

parcels.timer.args.stop()
Expand All @@ -262,7 +238,6 @@ def main(args=None):
outfile=args.outfile,
repeatdt=args.repeatdt,
maxage=args.maxage,
custom_partition_function=args.custom_partition_function,
)
parcels.timer.stommel.stop()
parcels.timer.root.stop()
Expand Down
18 changes: 0 additions & 18 deletions src/parcels/_compat.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
"""Import helpers for compatability between installations."""

__all__ = ["MPI", "KMeans"]

from typing import Any

MPI: Any | None = None
KMeans: Any | None = None

try:
from mpi4py import MPI # type: ignore[import-untyped,no-redef]
except ModuleNotFoundError:
pass

# KMeans is used in MPI. sklearn not installed by default
try:
from sklearn.cluster import KMeans
except ModuleNotFoundError:
pass


# for compat with v3 of parcels when users provide `initial=attrgetter("lon")` to a Variable
# so that particle initial state matches another variable
Expand Down
9 changes: 2 additions & 7 deletions src/parcels/_core/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class ParticleSet:
Optional interval on which to repeat the release of the ParticleSet. Either timedelta object, or float in seconds.
trajectory_ids :
Optional list of "trajectory" values (integers) for the particle IDs
partition_function :
Function to use for partitioning particles over processors. Default is to use kMeans

Other Variables can be initialised using further arguments (e.g. v=... for a Variable named 'v')
"""
Expand Down Expand Up @@ -106,11 +104,8 @@ def __init__(
_warn_particle_times_outside_fieldset_time_bounds(time, fieldset.time_interval)

for kwvar in kwargs:
if kwvar not in ["partition_function"]:
kwargs[kwvar] = np.array(kwargs[kwvar]).flatten()
assert lon.size == kwargs[kwvar].size, (
f"{kwvar} and positions (lon, lat, z) don't have the same lengths."
)
kwargs[kwvar] = np.array(kwargs[kwvar]).flatten()
assert lon.size == kwargs[kwvar].size, f"{kwvar} and positions (lon, lat, z) don't have the same lengths."

self._data = create_particle_data(
pclass=pclass,
Expand Down
45 changes: 0 additions & 45 deletions tests-v3/test_mpirun.py

This file was deleted.

Loading