Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OpenDrift/opendrift into …
Browse files Browse the repository at this point in the history
…dsd_options
  • Loading branch information
GilesFearon committed Oct 2, 2022
2 parents e479ed8 + d56ae1f commit 81753ed
Show file tree
Hide file tree
Showing 34 changed files with 506 additions and 489 deletions.
83 changes: 19 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ commands:
[[ "<<parameters.mpl>>" == "true" ]] && export MPL="--mpl"
source activate opendrift
pytest --circleci-parallelize --junitxml=test-results/junit.xml --cov=opendrift --ignore=tests/benchmarks --ignore=tests/wps --run-slow $MPL --durations=50 --benchmark-disable -v --log-cli-level=debug
pytest --circleci-parallelize --junitxml=test-results/junit.xml --cov=opendrift --ignore=tests/benchmarks --ignore=tests/wps --run-slow $MPL --mpl-results-path=test-results/mpl_images --durations=50 --benchmark-disable -v --log-cli-level=debug
- store_test_results:
path: test-results
Expand All @@ -44,7 +44,7 @@ commands:
cat envconfig
- restore_cache:
key: v18-deps1-{{ checksum "environment.yml" }}-{{ checksum "envconfig" }}
key: v19-deps1-{{ checksum "environment.yml" }}-{{ checksum "envconfig" }}

- run:
name: Install requirements
Expand All @@ -54,14 +54,14 @@ commands:
if [ -v PYTHON_VERSION ]; then
echo "Pinning python: ${PYTHON_VERSION}."
# pin python
conda create -c conda-forge -n opendrift -q -y "python=${PYTHON_VERSION}"
mamba create -c conda-forge -n opendrift -q -y "python=${PYTHON_VERSION}"
echo "python ${PYTHON_VERSION}.*" > /opt/conda/envs/opendrift/conda-meta/pinned
cat /opt/conda/envs/opendrift/conda-meta/pinned
conda env update -n opendrift -q -f environment.yml
mamba env update -n opendrift -q -f environment.yml
else
conda env create -q --file environment.yml
mamba env create -q --file environment.yml
fi
source activate opendrift
Expand All @@ -70,14 +70,14 @@ commands:
fi
- save_cache:
key: v18-deps1-{{ checksum "environment.yml" }}-{{ checksum "envconfig" }}
key: v19-deps1-{{ checksum "environment.yml" }}-{{ checksum "envconfig" }}
paths:
- "/opt/conda/envs"
- run:
name: List environment
command: |
source activate opendrift
conda list
mamba list
install_cartopy_shapes:
steps:
Expand All @@ -99,7 +99,7 @@ commands:

test-template: &test-template
docker:
- image: continuumio/miniconda3
- image: condaforge/mambaforge
resource_class: medium+
steps:
- checkout
Expand All @@ -114,7 +114,7 @@ test-template: &test-template
jobs:
build_package:
docker:
- image: continuumio/miniconda3
- image: condaforge/mambaforge
environment:
- PYTHON_VERSION=3.9

Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:

publish_package:
docker:
- image: continuumio/miniconda3
- image: condaforge/mambaforge
environment:
- PYTHON_VERSION=3.9

Expand Down Expand Up @@ -184,61 +184,18 @@ jobs:
environment:
- PYTHON_VERSION=3.8

python_37:
<<: *test-template
parallelism: 5
environment:
- PYTHON_VERSION=3.7

python_310_o_l_d:
docker:
- image: continuumio/miniconda3
parallelism: 5
environment:
- PYTHON_VERSION=3.10
steps:
- checkout

- install_conda_environment

- run:
name: Install opendrift-landmask-data and remove roaring-landmask
command: |
source activate opendrift
conda install -y -c conda-forge -c opendrift opendrift-landmask-data
pip uninstall -y roaring-landmask
- restore_cache:
key: v2-landmask

- run:
name: Generate landmask
command: |
source activate opendrift
python -c 'import opendrift_landmask_data as old; old.Landmask()'
- save_cache:
key: v2-landmask
paths:
- "/tmp/landmask"

- install_cartopy_shapes

- run_tests:
mpl: false

docs-build-examples:
docker:
- image: continuumio/miniconda3
- image: condaforge/mambaforge
parallelism: 20
steps:
- checkout
- run:
name: Update packages
command: apt-get update
command: DEBIAN_FRONTEND=noninteractive apt-get -y update
- run:
name: Install packages
command: apt-get install -y build-essential jq curl
command: DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential jq curl

- run:
name: Get PR title
Expand All @@ -259,7 +216,7 @@ jobs:
name: Install sphinx and friends
command: |
source activate opendrift
conda install -c conda-forge sphinx sphinx-autoapi sphinx-gallery>=0.7.0
mamba install -c conda-forge sphinx sphinx-autoapi sphinx-gallery>=0.7.0
pip install sphinx-rtd-theme
- run:
Expand Down Expand Up @@ -312,7 +269,7 @@ jobs:
cd docs/
make sharded-gallery SHARDS=${CIRCLE_NODE_TOTAL} SHARD=${CIRCLE_NODE_INDEX}
ls -R source
no_output_timeout: 40m
no_output_timeout: 60m

- store_test_results:
path: docs/test-results
Expand All @@ -326,7 +283,7 @@ jobs:

docs-build:
docker:
- image: continuumio/miniconda3
- image: condaforge/mambaforge
steps:
- checkout

Expand All @@ -335,10 +292,10 @@ jobs:

- run:
name: Update packages
command: apt-get update
command: DEBIAN_FRONTEND=noninteractive apt-get -y update
- run:
name: Install packages
command: apt-get install -y build-essential gfortran libgeos-dev gdal-bin imagemagick jq curl
command: DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential gfortran libgeos-dev gdal-bin imagemagick jq curl

- run:
name: Get PR title
Expand Down Expand Up @@ -373,7 +330,7 @@ jobs:
name: Install sphinx and friends
command: |
source activate opendrift
conda install -c conda-forge sphinx sphinx-autoapi sphinx-gallery>=0.7.0
mamba install -c conda-forge sphinx sphinx-autoapi sphinx-gallery>=0.7.0
pip install sphinx-rtd-theme
- save_cache:
Expand Down Expand Up @@ -454,8 +411,6 @@ workflows:
- python_310
- python_39
- python_38
- python_37
- python_310_o_l_d
- build_package
- publish_package:
requires:
Expand Down
26 changes: 13 additions & 13 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Alternative 1: Using Miniconda and Git (recommended)

.. code-block:: bash
$ conda config --add channels conda-forge # recommended, but not necessary
$ conda config --add channels conda-forge
$ conda env create -f environment.yml
$ conda activate opendrift
$ pip install -e .
$ pip install --no-deps -e .
This installs the OpenDrift package as an editable package. You can therefore directly make changes to the repository or fetch the newest changes with :code:`git pull`. You do not need to add OpenDrift to PYTHONPATH as long as you have the :code:`opendrift` environment activated.

Expand All @@ -33,39 +33,39 @@ Alternative 2: Using Miniconda
++++++++++++++++++++++++++++++

1. Install `miniconda3 <https://docs.conda.io/en/latest/miniconda.html>`_
2. Set up a *Python 3* environment for opendrift
2. Set up a *Python 3* environment for opendrift and install opendrift

.. code-block:: bash
$ conda config --add channels conda-forge # recommended, but not necessary
$ conda create -n opendrift python=3
$ conda config --add channels conda-forge
$ conda create -n opendrift python=3 opendrift
$ conda activate opendrift
3. Install OpenDrift and dependencies

.. code-block:: bash
$ conda install -c opendrift -c conda-forge -c noaa-orr-erd opendrift
.. _source_install:

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.

4. Clone OpenDrift:
3. Clone OpenDrift:

.. code-block:: bash
$ git clone https://github.com/OpenDrift/opendrift.git
$ cd opendrift/
4. Remove original package:

.. code-block:: bash
$ conda remove opendrift
5. Install as editable:

.. code-block:: bash
$ pip install -e .
$ pip install -e --no-deps .
Building and using the Docker image
+++++++++++++++++++++++++++++++++++
Expand Down
4 changes: 4 additions & 0 deletions docs/source/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Publications

Some papers using or mentioning OpenDrift:

Rodríguez-Villegas C., Figueroa R.I, Pérez-Santos I, Molinet C., Saldías G.S., Rosales S.A, Álvarez G., Linford P., Díaz P.A., Continental shelf off northern Chilean Patagonia: A potential risk zone for the onset of Alexandrium catenella toxic bloom? Marine Pollution Bulletin 184 (2022) 114103, https://doi.org/10.1016/j.marpolbul.2022.11410

Devis Morales A.D., Rubio E.R., Martínez D.R., Numerical modeling of oil spills in the Gulf of Morrosquillo, Colombian Caribean, Ciencia, Tecnologia y Futuro Vol 12, Num 1 June 2022. pages 69 - 83, https://doi.org/10.29047/01225383.396.

Kotnik, J.; Žagar, D.; Novak, G.; Ličer, M.; Horvat, M. Dissolved Gaseous Mercury (DGM) in the Gulf of Trieste, Northern Adriatic Sea. J. Mar. Sci. Eng. 2022, 10, 587. https://doi.org/10.3390/jmse10050587

Keramea P, Kokkos N, Gikas GD, Sylaios G. Operational Modeling of North Aegean Oil Spills Forced by Real-Time Met-Ocean Forecasts. Journal of Marine Science and Engineering. 2022; 10(3):411. https://doi.org/10.3390/jmse10030411
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- opendrift
- conda-forge
dependencies:
- matplotlib>=3.1
- matplotlib>=3.5
- numpy>=1.17
- scipy>=1.6
- netcdf4
Expand All @@ -29,7 +29,7 @@ dependencies:
- coloredlogs
- cmocean
- utm
- roaring-landmask>=0.7
- pip
- pip:
- motuclient
- roaring-landmask
2 changes: 1 addition & 1 deletion examples/example_compare_oilbudgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
b[ot] = o.get_oil_budget()
# Get viscosity and density
kin_viscosity = o.history['viscosity']
dyn_viscosity = kin_viscosity * o.history['density']
dyn_viscosity = kin_viscosity * o.history['density'] * 1000 # mPas
viscosities[ot] = dyn_viscosity.mean(axis=0)
densities[ot] = o.history['density'].mean(axis=0)
water_fractions[ot] = o.history['water_fraction'].mean(axis=0)
Expand Down
3 changes: 1 addition & 2 deletions examples/example_grid_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#%%
# Landmask
reader_landmask = reader_global_landmask.Reader(
extent=[4.0, 5.5, 59.9, 61.2])
reader_landmask = reader_global_landmask.Reader()

o.add_reader([reader_landmask, reader_norkyst])

Expand Down
3 changes: 1 addition & 2 deletions examples/example_rungekutta_norkyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
'16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')
time = reader_norkyst.start_time

reader_landmask = reader_global_landmask.Reader(
extent=[4, 5.5, 59.9, 61.5])
reader_landmask = reader_global_landmask.Reader()

o.add_reader([reader_norkyst, reader_landmask])
lon = 4.5; lat = 60.0;
Expand Down
12 changes: 5 additions & 7 deletions examples/example_schism_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
###############################
# Creating and adding reader using a native SCHISM netcdf output file
# SCHISM reader
reader_landmask = reader_global_landmask.Reader(
llcrnrlon=171.5, llcrnrlat=-43.5,
urcrnrlon=177.0, urcrnrlat=-38.0)
reader_landmask = reader_global_landmask.Reader()

# NZTM proj4 string found at https://spatialreference.org/ref/epsg/nzgd2000-new-zealand-transverse-mercator-2000/
proj4str_nztm = '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs'
schism_native = reader_schism_native.Reader(
filename = 'https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc',
proj4 = proj4str_nztm,
filename = 'https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/schism_marl20080101_00z_3D.nc',
proj4 = proj4str_nztm,
use_3d = True)
# schism_native.plot_mesh(variable = ['sea_floor_depth_below_sea_level']) # check reader was correctly loaded

Expand All @@ -48,12 +46,12 @@
o.disable_vertical_motion() #Deactivate any vertical processes/advection"""
#%%
# Running model
o.run(time_step=900,
o.run(time_step=900,
end_time = schism_native.start_time+timedelta(days=0.1))
# outfile='schism_native_output.nc')

# Print and plot results
print(o)
o.plot(fast=True)
o.animation()
o.animation_profile()
o.animation_profile()
4 changes: 2 additions & 2 deletions examples/example_sediments.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from datetime import timedelta, datetime
from opendrift.models.sedimentdrift import SedimentDrift

o = SedimentDrift(loglevel=50) # 0 for debug output
o = SedimentDrift(loglevel=0) # 0 for debug output

#%%
# Source of sediments at Glomma river outlet
lat=59.169194
lon=10.962920
o.seed_elements(lon=lon, lat=lat, number=10000,
o.seed_elements(lon=lon, lat=lat, number=10000,
time=[datetime.utcnow(), datetime.utcnow()+timedelta(hours=48)],
terminal_velocity=-.001) # 1 mm/s settling speed

Expand Down
Loading

0 comments on commit 81753ed

Please sign in to comment.