Installing OpenDrift

Alternative 2: Using Mambaforge (or Miniforge)

  1. Install miniforge

  2. Set up a Python 3 environment for opendrift and install opendrift

$ mamba create -n opendrift python=3 opendrift
$ conda activate opendrift

Modify install to use Git version

If you later want to edit the OpenDrift source code, or be able to update from repository with git pull, the following two steps are necessary. This yields the same as Alternative 1.

  1. Clone OpenDrift:

$ git clone https://github.com/OpenDrift/opendrift.git
$ cd opendrift/
  1. Remove original package:

$ mamba remove --force opendrift
  1. Install as editable:

$ pip install --no-deps -e .

Install and use on WEkEO and EDITO

To install and use OpenDrift in the JupyterHub workspace on https://wekeo.copernicus.eu or https://datalab.dive.edito.eu, type the following in a workspace terminal window

$ mamba install opendrift

By installing in the base environment, you can use the default Python kernel for notebooks, and there is no risk of conflict with existing environment.

If you want to use copernicus products as forcing, you can set your credentials as environment variables from the same terminal.

$ export COPERNICUSMARINE_SERVICE_USERNAME=<your CMEMS username>
$ export COPERNICUSMARINE_SERVICE_PASSWORD=<your CMEMS password>

Alternatively, you can store your credentials in a file .env in the same folder as your notebooks:

COPERNICUSMARINE_SERVICE_USERNAME=<your CMEMS username>
COPERNICUSMARINE_SERVICE_PASSWORD=<your CMEMS password>

OpenDrift can now be imported and used in the JupyterHub notebooks.

Building and using the Docker image

It is also possible to run OpenDrift in a docker container. You can either use the pre-built images (each release or latest master):

$ docker run -it --rm opendrift/opendrift:latest

or if you want to re-build the image using your local version of opendrift, check out opendrift and make your changes, then:

$ git clone https://github.com/OpenDrift/opendrift.git
$ cd opendrift/

re-build the image:

$ docker build -t opendrift .

and run it:

$ docker run -it --rm opendrift