{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Quickstart to Parcels\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Welcome to a quick tutorial on Parcels. This is meant to get you started with the code, and give you a flavour of some of the key features of Parcels.\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "In this tutorial, we will first cover how to run a set of particles [from a very simple idealised field](#Running-particles-in-an-idealised-field). We will show how easy it is to run particles in [time-backward mode](#Running-particles-in-backward-time). Then, we will show how to [add custom behaviour](#Adding-a-custom-behaviour-kernel) to the particles. Then, we will show how to [run particles in a set of NetCDF files from external data](#Reading-in-data-from-arbritrary-NetCDF-files). Then, we will show how to use particles to [sample a field](#Sampling-a-Field-with-Particles) such as temperature or sea surface height. And finally, we will show how to [write a kernel that tracks the distance travelled by the particles](#calculating-distance-travelled).\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Let's start with importing the relevant packages.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import math\n", "from datetime import timedelta\n", "from operator import attrgetter\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import trajan as ta\n", "import xarray as xr\n", "from IPython.display import HTML\n", "from matplotlib.animation import FuncAnimation\n", "\n", "import parcels" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Running particles in an idealised field\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The first step to running particles with Parcels is to define a `FieldSet` object, which is simply a collection of hydrodynamic fields. In this first case, we use a simple flow of two idealised moving eddies. That field can be downloaded using the `download_example_dataset()` function that comes with Parcels. Since we know that the files are in what's called Parcels FieldSet format, we can call these files using the function `FieldSet.from_parcels()`.\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "