Skip to content

Commit

Permalink
Merge branch 'OceanParcels:master' into kdtree-with-nans
Browse files Browse the repository at this point in the history
  • Loading branch information
dicaearchus authored Jan 11, 2024
2 parents 8e046ac + 6507fe3 commit eba91d3
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 109 deletions.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/general-issue.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: Parcels feature requests, enhancements, or bug reporting
about: Create an Issue about bugs in the Parcels codebase, or required improvements
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---
3 changes: 1 addition & 2 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- published
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -79,7 +79,6 @@ jobs:
repository_url: https://test.pypi.org/legacy/
verbose: true


upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [macos, ubuntu, windows]
include: # TODO check if these can go?
include: # TODO check if these can go?
- os: macos
os-short: osx
- os: ubuntu
Expand Down
44 changes: 24 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-ast
- id: check-json
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-ast
- id: check-json
types: [text]
files: \.(json|ipynb)$
- repo: https://github.com/pycqa/flake8
rev: '6.1.0'
- repo: https://github.com/pycqa/flake8
rev: "6.1.0"
hooks:
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0 # pick a git hash / tag to point to
- id: flake8
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0 # pick a git hash / tag to point to
hooks:
- id: pydocstyle
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
- id: pydocstyle
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
hooks:
- id: nbqa-black
- id: nbqa-check-ast
- id: nbqa-isort
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- id: nbqa-black
- id: nbqa-check-ast
- id: nbqa-isort
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- id: isort
name: isort (python)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
- id: prettier
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/_templates
28 changes: 14 additions & 14 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Van Sebille"
given-names: "Erik"
orcid: "https://orcid.org/0000-0003-2041-0704"
- family-names: "Kehl"
given-names: "Christian"
orcid: "https://orcid.org/0000-0003-4200-1450"
- family-names: "Lange"
given-names: "Michael"
orcid: "https://orcid.org/0000-0002-3232-0127"
- family-names: "Delandmeter"
given-names: "Philippe"
orcid: "https://orcid.org/0000-0003-0100-5834"
- name: "The Parcels contributors"
website: "https://github.com/OceanParcels/parcels/graphs/contributors"
- family-names: "Van Sebille"
given-names: "Erik"
orcid: "https://orcid.org/0000-0003-2041-0704"
- family-names: "Kehl"
given-names: "Christian"
orcid: "https://orcid.org/0000-0003-4200-1450"
- family-names: "Lange"
given-names: "Michael"
orcid: "https://orcid.org/0000-0002-3232-0127"
- family-names: "Delandmeter"
given-names: "Philippe"
orcid: "https://orcid.org/0000-0003-0100-5834"
- name: "The Parcels contributors"
website: "https://github.com/OceanParcels/parcels/graphs/contributors"
title: "Parcels"
version: 2.4.2
doi: 10.5281/zenodo.8010997
Expand Down
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@

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

*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/).*
_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/)._

### Parcels manuscript and code

The manuscript detailing the first release of Parcels, version 0.9, has been published in [Geoscientific Model Development](https://www.geosci-model-dev.net/10/4175/2017/gmd-10-4175-2017.html) and can be cited as

*Lange, M and E van Sebille (2017) Parcels v0.9: prototyping a Lagrangian Ocean Analysis framework for the petascale age. Geoscientific Model Development, 10, 4175-4186. https://doi.org/10.5194/gmd-2017-167*
_Lange, M and E van Sebille (2017) Parcels v0.9: prototyping a Lagrangian Ocean Analysis framework for the petascale age. Geoscientific Model Development, 10, 4175-4186. https://doi.org/10.5194/gmd-2017-167_

The manuscript detailing version 2.0 of Parcels is available at [Geoscientific Model Development](https://www.geosci-model-dev.net/12/3571/2019/gmd-12-3571-2019-discussion.html) and can be cited as:

*Delandmeter, P and E van Sebille (2019) The Parcels v2.0 Lagrangian framework: new field interpolation schemes. Geoscientific Model Development, 12, 3571-3584. https://doi.org/10.5194/gmd-12-3571-2019*
_Delandmeter, P and E van Sebille (2019) The Parcels v2.0 Lagrangian framework: new field interpolation schemes. Geoscientific Model Development, 12, 3571-3584. https://doi.org/10.5194/gmd-12-3571-2019_

The manuscript detailing the performance of Parcels v2.4 is available at [Computers & Geosciences](https://doi.org/10.1016/j.cageo.2023.105322) and can be cited as:

*Kehl, C, PD Nooteboom, MLA Kaandorp and E van Sebille (2023) Efficiently simulating Lagrangian particles in large-scale ocean flows — Data structures and their impact on geophysical applications, Computers and Geosciences, 175, 105322. https://doi.org/10.1016/j.cageo.2023.105322*
_Kehl, C, PD Nooteboom, MLA Kaandorp and E van Sebille (2023) Efficiently simulating Lagrangian particles in large-scale ocean flows — Data structures and their impact on geophysical applications, Computers and Geosciences, 175, 105322. https://doi.org/10.1016/j.cageo.2023.105322_

### Further information

See [oceanparcels.org](http://oceanparcels.org/) for further information about [installing](https://docs.oceanparcels.org/en/latest/installation.html) and [running](https://docs.oceanparcels.org/en/latest/documentation.html) the Parcels code, as well as extended [documentation](https://docs.oceanparcels.org/en/latest/reference.html) of the methods and classes.


### Launch Parcels Tutorials on [mybinder.org](https://mybinder.org/v2/gh/OceanParcels/parcels/master?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb)

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/OceanParcels/parcels/master?labpath=docs%2Fexamples%2Fparcels_tutorial.ipynb)
Expand Down
17 changes: 6 additions & 11 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,36 @@ Even if you don't want to contribute directly to the codebase, getting involved

This document outlines some guidelines for contributing to the parcels codebase. If you have any questions or suggestions for how we can improve this document, please let us know.


## Getting Started

To get started contributing to parcels, you'll need to install the developer version of Parcels following [our installation instructions](installation.rst#installation-for-developers). This will install the latest version of Parcels from the `master` branch of the repository.

**Optional:** Setup `pre-commit` hooks by running `pre-commit install`. This ensures that code is formatted correctly before you commit it.


## Making Changes

Once you have a working environment, you can start making changes to the code! Here are some general guidelines to follow when making changes:

* Follow the [NumPy docstring conventions](https://numpydoc.readthedocs.io/en/latest/format.html) when adding or modifying docstrings.

* Follow the [PEP 8](https://peps.python.org/pep-0008/) style guide when writing code. This codebase also uses [flake8](https://flake8.pycqa.org/en/latest/) and [isort](https://pycqa.github.io/isort/) to ensure a consistent code style (these tools are run automatically by pre-commit).
- Follow the [NumPy docstring conventions](https://numpydoc.readthedocs.io/en/latest/format.html) when adding or modifying docstrings.

* Use Git to manage your changes. Create a new branch for each feature or bug fix.
- Follow the [PEP 8](https://peps.python.org/pep-0008/) style guide when writing code. This codebase also uses [flake8](https://flake8.pycqa.org/en/latest/) and [isort](https://pycqa.github.io/isort/) to ensure a consistent code style (these tools are run automatically by pre-commit).

* Write clear commit messages that explain the changes you've made.
- Use Git to manage your changes. Create a new branch for each feature or bug fix.

* Include tests for any new code you write.
- Write clear commit messages that explain the changes you've made.

* Submit your changes as a pull request to the `master` branch, and wait for feedback!
- Include tests for any new code you write.

- Submit your changes as a pull request to the `master` branch, and wait for feedback!

```{note}
Feel free to create an issue for your proposed feature or change to the codebase so that feedback can be given.
Submitting a "draft pull request" is also a great way to give visibility to your branch during development, allowing for faster feedback.
```


## Working with documentation

The documentation for this project is processed by Sphinx. To view documentation from your changes, you can run
`sphinx-autobuild --ignore "*.zip" docs docs/_build` to create a server to automatically rebuild the documentation when you make changes.


If you have any questions or issues while contributing to parcels, please feel free to [open a discussion](https://github.com/OceanParcels/parcels/discussions). Thank you for your contributions!
68 changes: 30 additions & 38 deletions docs/examples/documentation_unstuck_Agrid.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples/tutorial_timestamps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note, by the way, that adding the `time_periodic=True` argument to `Field.from_netcdf()` will also mean that the climatology can be cycled for multiple years.\n"
"Note, by the way, that adding the `time_periodic` argument to `Field.from_netcdf()` will also mean that the climatology can be cycled for multiple years.\n"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions parcels/particlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _create_variables_attribute_dict(self):

if self.time_origin.calendar is not None:
attrs['time']['units'] = "seconds since " + str(self.time_origin)
attrs['time']['calendar'] = 'standard' if self.time_origin.calendar == 'np_datetime64' else self.time_origin.calendar
attrs['time']['calendar'] = _set_calendar(self.time_origin.calendar)

for vname in self.vars_to_write:
if vname not in ['time', 'lat', 'lon', 'depth', 'id']:
Expand Down Expand Up @@ -183,7 +183,7 @@ def _extend_zarr_dims(self, Z, store, dtype, axis):
if len(obs) == Z.shape[1]:
obs.append(np.arange(self.chunks[1])+obs[-1]+1)
else:
extra_trajs = max(self.maxids - Z.shape[0], self.chunks[0])
extra_trajs = self.maxids - Z.shape[0]
if len(Z.shape) == 2:
a = np.full((extra_trajs, Z.shape[1]), self.fill_value_map[dtype], dtype=dtype)
else:
Expand Down Expand Up @@ -233,7 +233,7 @@ def write(self, pset, time, indices=None):
if (self.maxids > len(ids)) or (self.maxids > self.chunks[0]):
arrsize = (self.maxids, self.chunks[1])
else:
arrsize = (len(ids), 1)
arrsize = (len(ids), self.chunks[1])
ds = xr.Dataset(attrs=self.metadata, coords={"trajectory": ("trajectory", pids),
"obs": ("obs", np.arange(arrsize[1], dtype=np.int32))})
attrs = self._create_variables_attribute_dict()
Expand Down
19 changes: 19 additions & 0 deletions tests/test_particlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ def IncrLon(particle, fieldset, time):
ds.close()


@pytest.mark.parametrize('mode', ['scipy', 'jit'])
@pytest.mark.parametrize('repeatdt', [1, 2])
@pytest.mark.parametrize('nump', [1, 10])
def test_pfile_chunks_repeatedrelease(fieldset, mode, repeatdt, nump, tmpdir):
runtime = 8
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=np.zeros((nump, 1)),
lat=np.zeros((nump, 1)), repeatdt=repeatdt)
outfilepath = tmpdir.join("pfile_chunks_repeatedrelease.zarr")
chunks = (20, 10)
pfile = pset.ParticleFile(outfilepath, outputdt=1, chunks=chunks)

def DoNothing(particle, fieldset, time):
pass

pset.execute(DoNothing, dt=1, runtime=runtime, output_file=pfile)
ds = xr.open_zarr(outfilepath)
assert ds['time'].shape == (int(nump*runtime/repeatdt), chunks[1])


@pytest.mark.parametrize('mode', ['scipy', 'jit'])
def test_write_timebackward(fieldset, mode, tmpdir):
outfilepath = tmpdir.join("pfile_write_timebackward.zarr")
Expand Down

0 comments on commit eba91d3

Please sign in to comment.