Skip to content

Commit ebc6517

Browse files
committed
Merge remote-tracking branch 'origin/main' into v/refactor-interp
2 parents 0f98aa6 + 02eb9a7 commit ebc6517

File tree

18 files changed

+141
-95
lines changed

18 files changed

+141
-95
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ci
22
on:
33
push:
44
branches:
5-
- "master"
5+
- "main"
66
- "test-me/*"
77
pull_request:
88
schedule:

.github/workflows/pypi-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,5 @@ jobs:
106106
channels: conda-forge
107107
- run: conda install -c conda-forge c-compiler pip
108108
- run: pip install parcels --no-cache
109-
- run: curl https://raw.githubusercontent.com/OceanParcels/parcels/master/docs/examples/example_peninsula.py > example_peninsula.py
109+
- run: curl https://raw.githubusercontent.com/OceanParcels/parcels/main/docs/examples/example_peninsula.py > example_peninsula.py
110110
- run: python example_peninsula.py

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
[![Zenodo](https://zenodo.org/badge/DOI/10.5281/zenodo.823561.svg)](https://doi.org/10.5281/zenodo.823561)
66
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
77
[![unit-tests](https://github.com/OceanParcels/parcels/actions/workflows/ci.yml/badge.svg)](https://github.com/OceanParcels/parcels/actions/workflows/ci.yml)
8-
[![codecov](https://codecov.io/gh/OceanParcels/parcels/branch/master/graph/badge.svg)](https://codecov.io/gh/OceanParcels/parcels)
8+
[![codecov](https://codecov.io/gh/OceanParcels/parcels/branch/main/graph/badge.svg)](https://codecov.io/gh/OceanParcels/parcels)
99
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5353/badge)](https://bestpractices.coreinfrastructure.org/projects/5353)
10-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/OceanParcels/parcels/master?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb)
10+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/OceanParcels/parcels/main?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb)
1111

1212
**Parcels** (**P**robably **A** **R**eally **C**omputationally **E**fficient **L**agrangian **S**imulator) is a set of Python classes and methods to create customisable particle tracking simulations using output from Ocean Circulation models. Parcels can be used to track passive and active particulates such as water, plankton, [plastic](http://www.topios.org/) and [fish](https://github.com/Jacketless/IKAMOANA).
1313

14-
![Arctic-SO-medusaParticles](https://github.com/OceanParcels/oceanparcels_website/blob/master/images/homepage.gif)
14+
![Arctic-SO-medusaParticles](https://github.com/OceanParcels/oceanparcels_website/blob/main/images/homepage.gif)
1515

1616
_Animation of virtual particles carried by ocean surface flow in the global oceans. The particles are advected with [Parcels](http://oceanparcels.org/) in data from the [NEMO Ocean Model](https://www.nemo-ocean.eu/)._
1717

docs/community/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ What is open source?
2525

2626
Open source is a category of software that is open to the public, meaning that anyone is able to look at, modify, and improve the software. Compare this to closed source software (e.g., Microsoft Word, or Gmail) where only those working for the company on the product are able to look at the source code, or make improvements.
2727

28-
Software being open source allows bugs in the code to be quickly identified and fixed, as well as fosters communities of people involved on projects. Most open source software have permissible licenses making them free to modify, and use even in commercial settings. Parcels, for example, is open source and `licensed under the MIT License <https://github.com/OceanParcels/parcels/blob/master/LICENSE.md>`_.
28+
Software being open source allows bugs in the code to be quickly identified and fixed, as well as fosters communities of people involved on projects. Most open source software have permissible licenses making them free to modify, and use even in commercial settings. Parcels, for example, is open source and `licensed under the MIT License <https://github.com/OceanParcels/parcels/blob/main/LICENSE.md>`_.
2929

3030
This visibility of the codebase results in a higher quality, as well as a more transparent and stable product. This is important in research for reproducibility, as well as in industry where stability is crucial. Open source is not some niche category of software, but in fact `forms the backbone of modern computing and computing infrastructure <https://www.newstatesman.com/science-tech/2016/08/how-linux-conquered-world-without-anyone-noticing>`_ and is used widely in industry. A lot of the digital services that you use (paid, or free) depend on open source code in one way or another.
3131

@@ -72,7 +72,7 @@ Now you have a cloned repo that you have full control over, and a conda environm
7272
From there:
7373

7474
- create a git branch, implement, commit, and push your changes
75-
- `create a pull request <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork>`_ (PR) into ``master`` of the original repo making sure to link to the issue that you are working on. Not yet finished with your feature but still want feedback on how you're going? Then mark it as "draft" and ``@ping`` a maintainer. See our `maintainer notes <maintainer.md>`_ to see our PR review workflow.
75+
- `create a pull request <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork>`_ (PR) into ``main`` of the original repo making sure to link to the issue that you are working on. Not yet finished with your feature but still want feedback on how you're going? Then mark it as "draft" and ``@ping`` a maintainer. See our `maintainer notes <maintainer.md>`_ to see our PR review workflow.
7676

7777
If you made changes to the documentation, and want to render a local version, you can run the command ``sphinx-autobuild --ignore "*.zip" docs docs/_build`` to create a server to automatically rebuild the documentation when you make changes.
7878

docs/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
html_context = {
213213
"github_user": "OceanParcels",
214214
"github_repo": "parcels",
215-
"github_version": "master",
215+
"github_version": "main",
216216
"doc_path": "docs",
217217
}
218218

@@ -295,7 +295,9 @@ def linkcode_resolve(domain, info):
295295
fn = os.path.relpath(fn, start=os.path.dirname(parcels.__file__))
296296

297297
if "-" in parcels.__version__:
298-
return f"https://github.com/OceanParcels/parcels/blob/master/parcels/{fn}{linespec}"
298+
return (
299+
f"https://github.com/OceanParcels/parcels/blob/main/parcels/{fn}{linespec}"
300+
)
299301
else:
300302
return (
301303
f"https://github.com/OceanParcels/parcels/blob/"

docs/documentation/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Documentation and Tutorials
22
===========================
33

4-
Parcels has several documentation and tutorial Jupyter notebooks and scripts which go through various aspects of Parcels. Static versions of the notebooks are available below via the gallery in the site, with the interactive notebooks being available either completely online at the following `Binder link <https://mybinder.org/v2/gh/OceanParcels/parcels/master?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb>`_. Following the gallery of notebooks is a list of scripts which provide additional examples to users. You can work with the example notebooks and scripts locally by downloading :download:`parcels_tutorials.zip </_downloads/parcels_tutorials.zip>` and running with your own Parcels installation.
4+
Parcels has several documentation and tutorial Jupyter notebooks and scripts which go through various aspects of Parcels. Static versions of the notebooks are available below via the gallery in the site, with the interactive notebooks being available either completely online at the following `Binder link <https://mybinder.org/v2/gh/OceanParcels/parcels/main?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb>`_. Following the gallery of notebooks is a list of scripts which provide additional examples to users. You can work with the example notebooks and scripts locally by downloading :download:`parcels_tutorials.zip </_downloads/parcels_tutorials.zip>` and running with your own Parcels installation.
55

66
.. warning::
77
In v3.1.0 we updated kernels in the tutorials to use ``parcels.ParcelsRandom`` instead of ``from parcels import ParcelsRandom``. Due to our C-conversion code, using ``parcels.ParcelsRandom`` only works with v3.1.0+. When browsing/downloading the tutorials, it's important that you are using the documentation corresponding to the version of Parcels that you have installed. You can find which parcels version you have installed by doing ``import parcels`` followed by ``print(parcels.__version__)``. If you don't want to use the latest version of Parcels, you can browse prior versions of the documentation by using the version switcher in the bottom right of this page.

docs/examples/tutorial_analyticaladvection.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"3. Since Analytical Advection does not use timestepping, the `dt` parameter in `pset.execute()` should be set to `np.inf`. For backward-in-time simulations, it should be set to `-np.inf`. \n",
3434
"4. For time-varying fields, only the 'intermediate timesteps' scheme ([section 2.3 of Döös et al 2017](https://www.geosci-model-dev.net/10/1733/2017/gmd-10-1733-2017.pdf)) is implemented. While there is also a way to also analytically solve the time-evolving fields ([section 2.4 of Döös et al 2017](https://www.geosci-model-dev.net/10/1733/2017/gmd-10-1733-2017.pdf)), this is not yet implemented in Parcels.\n",
3535
"\n",
36-
"We welcome contributions to the further development of this algorithm and in particular the analytical time-varying case. See [here](https://github.com/OceanParcels/parcels/blob/master/parcels/application_kernels/advection.py) for the code of the `AdvectionAnalytical` kernel.\n"
36+
"We welcome contributions to the further development of this algorithm and in particular the analytical time-varying case. See [here](https://github.com/OceanParcels/parcels/blob/main/parcels/application_kernels/advection.py) for the code of the `AdvectionAnalytical` kernel.\n"
3737
]
3838
},
3939
{

environment.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dependencies:
55
- python>=3.10
66
- cgen
77
- ffmpeg>=3.2.3
8-
- git
98
- jupyter
109
- matplotlib-base>=2.0.2
1110
- netcdf4>=1.1.9
@@ -19,15 +18,11 @@ dependencies:
1918
- xarray>=0.10.8
2019
- cftime>=1.3.1
2120
- dask>=2.0
22-
- nbval
2321
- scikit-learn
24-
- zarr>=2.11.0,!=2.18.0
25-
26-
# Formatting
27-
- black
28-
- isort
22+
- zarr>=2.11.0,!=2.18.0,<3
2923

3024
# Testing
25+
- nbval
3126
- pytest
3227
- pytest-html
3328
- coverage

parcels/_typing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class ParcelsAST(ast.AST):
2626
"bgrid_w_velocity",
2727
"cgrid_velocity",
2828
"linear_invdist_land_tracer",
29-
"nearest",
3029
"bgrid_tracer",
3130
"cgrid_tracer",
3231
] # corresponds with `tracer_interp_method`

parcels/particleset.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from parcels._compat import MPI
1515
from parcels.application_kernels.advection import AdvectionRK4
1616
from parcels.compilation.codecompiler import GNUCompiler
17-
from parcels.field import NestedField
17+
from parcels.field import Field, NestedField
1818
from parcels.grid import CurvilinearGrid, GridType
1919
from parcels.interaction.interactionkernel import InteractionKernel
2020
from parcels.interaction.neighborsearch import (
@@ -32,7 +32,7 @@
3232
from parcels.tools.global_statics import get_package_dir
3333
from parcels.tools.loggers import logger
3434
from parcels.tools.statuscodes import StatusCode
35-
from parcels.tools.warnings import FileWarning
35+
from parcels.tools.warnings import ParticleSetWarning
3636

3737
__all__ = ["ParticleSet"]
3838

@@ -174,6 +174,8 @@ def ArrayClass_init(self, *args, **kwargs):
174174
raise NotImplementedError("If fieldset.time_origin is not a date, time of a particle must be a double")
175175
time = np.array([self.time_origin.reltime(t) if _convert_to_reltime(t) else t for t in time])
176176
assert lon.size == time.size, "time and positions (lon, lat, depth) do not have the same lengths."
177+
if isinstance(fieldset.U, Field) and (not fieldset.U.allow_time_extrapolation):
178+
_warn_particle_times_outside_fieldset_time_bounds(time, fieldset.U.grid.time_full)
177179

178180
if lonlatdepth_dtype is None:
179181
lonlatdepth_dtype = self.lonlatdepth_dtype_from_field_interp_method(fieldset.U)
@@ -792,7 +794,7 @@ def from_particlefile(
792794
f"Note that the `repeatdt` argument is not retained from {filename}, and that "
793795
"setting a new repeatdt will start particles from the _new_ particle "
794796
"locations.",
795-
FileWarning,
797+
ParticleSetWarning,
796798
stacklevel=2,
797799
)
798800

@@ -1247,6 +1249,22 @@ def _warn_outputdt_release_desync(outputdt: float, starttime: float, release_tim
12471249
"Some of the particles have a start time difference that is not a multiple of outputdt. "
12481250
"This could cause the first output of some of the particles that start later "
12491251
"in the simulation to be at a different time than expected.",
1250-
FileWarning,
1252+
ParticleSetWarning,
12511253
stacklevel=2,
12521254
)
1255+
1256+
1257+
def _warn_particle_times_outside_fieldset_time_bounds(release_times: np.ndarray, time_full: np.ndarray):
1258+
if np.any(release_times):
1259+
if np.any(release_times < time_full[0]):
1260+
warnings.warn(
1261+
"Some particles are set to be released before the fieldset's first time and allow_time_extrapolation is set to False.",
1262+
ParticleSetWarning,
1263+
stacklevel=2,
1264+
)
1265+
if np.any(release_times > time_full[-1]):
1266+
warnings.warn(
1267+
"Some particles are set to be released after the fieldset's last time and allow_time_extrapolation is set to False.",
1268+
ParticleSetWarning,
1269+
stacklevel=2,
1270+
)

0 commit comments

Comments
 (0)