Skip to content

Commit

Permalink
Merge pull request #13 from OceanParcels/code_cleanup_and_standardisa…
Browse files Browse the repository at this point in the history
…tion

Code cleanup and standardisation
  • Loading branch information
michaeldenes authored May 2, 2024
2 parents d748b97 + 903d479 commit 23d4e5a
Show file tree
Hide file tree
Showing 48 changed files with 1,989 additions and 22,735 deletions.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
ignore =
# missing whitespace around arithmetic operator
E226,
# do not use bare except, specify exception instead
E722,
# line break before binary operator
W503,
# line too long (82 > 79 characters)
E501,
# ‘from module import *’ used; unable to detect undefined names
F403,
26 changes: 26 additions & 0 deletions .github/actions/install-plasticparcels/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup Conda and install plasticparcels
description: >
In-repo composite action to setup Conda and install parcels. Installation of parcels relies on
`setup.py` file being available in the root. For general setup of Anaconda environments, just use
the `mamba-org/setup-micromamba@v1` action (setting C variables as required), or the `conda-incubator/setup-miniconda` action.
inputs:
environment-file:
description: Conda environment file to use.
default: environment.yml
environment-name:
description: Name to use for the Conda environment
default: test
runs:
using: "composite"
steps:
- name: Install micromamba (${{ inputs.environment-file }})
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ inputs.environment-file }}
environment-name: ${{ inputs.environment-name }}
channels: conda-forge
cache-environment: true
cache-downloads: true
- name: Install parcels
run: pip install .
shell: bash -el {0}
4 changes: 2 additions & 2 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
paper-path: docs/paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
path: docs/paper/paper.pdf
19 changes: 19 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: linting
on:
pull_request:
push:
jobs:
linting:
name: Linting with flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Python setup
run: |
pip install wheel
pip install flake8
- name: flake8
run: |
python -m flake8 plasticparcels
python -m flake8 tests
28 changes: 28 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: unit-tests
on:
pull_request:
push:
schedule:
- cron: "0 7 * * 1" # Run every Monday at 7:00 UTC

defaults:
run:
shell: bash -el {0}

jobs:
unit-test:
name: Unittesting on ubuntu with python latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Conda and parcels
uses: ./.github/actions/install-plasticparcels
with:
environment-file: environment.yml
environment-name: py3_parcels
- name: Unit test
run: |
python -m pytest -v -s tests
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
data/
fig/
input_data/
**.code-workspace*
**.DS_store**
**.pyc**
**.nc
**.zarr
65 changes: 34 additions & 31 deletions README.md

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions docs/examples/default_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"use_3D": true,
"allow_time_extrapolation": false,
"verbose_delete": false,
"use_mixing": false,
"use_biofouling": false,
"use_stokes": false,
"use_wind": false,
"ocean": {
"modelname": "NEMO0083",
"directory": "/storage/shared/oceanparcels/input_data/MOi/",
"filename_style": "psy4v3r1/psy4v3r1-daily_",
"ocean_mesh": "domain_ORCA0083-N006/PSY4V3R1_mesh_hgr.nc",
"bathymetry_mesh": "domain_ORCA0083-N006/PSY4V3R1_mesh_zgr.nc",
"variables": {
"U": "vozocrtx",
"V": "vomecrty",
"W": "vovecrtz",
"conservative_temperature": "votemper",
"absolute_salinity": "vosaline"
},
"dimensions": {
"U": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"V": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"W": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"conservative_temperature": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"absolute_salinity": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
}
},
"indices": {},
"bathymetry_variables": {
"bathymetry": "mbathy"
},
"bathymetry_dimensions": {
"lon": "nav_lon",
"lat": "nav_lat"
},
"mixing_variables": {
"mixing_kz": "votkeavt"
},
"mixing_dimensions": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
}
},
"bgc": {
"directory": "/storage/shared/oceanparcels/input_data/MOi/",
"filename_style": "biomer4v2r1/biomer4v2r1-weekly_",
"bgc_mesh": "domain_ORCA025-N006/mesh_hgr_PSY4V3_deg.nc",
"variables": {
"pp_phyto": "nppv",
"bio_nanophy": "phy",
"bio_diatom": "phy2"
},
"dimensions": {
"pp_phyto": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"bio_nanophy": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
},
"bio_diatom": {
"lon": "glamf",
"lat": "gphif",
"depth": "depthw",
"time": "time_counter"
}
},
"indices": {},
"constants": {
"biofilm_density": 1388.0,
"algae_cell_volume": 2e-16,
"K": 1.3805834190672156e-23,
"R20": 1.1574074074074074e-06,
"Q10": 2.13,
"Gamma": 2.0,
"carbon_molecular_weight": 12.0,
"collision_probability": 1.0,
"algae_mortality_rate": 1.0,
"algae_respiration_f": 1.0
}
},
"stokes": {
"directory": "/storage/shared/oceanparcels/output_data/data_Michael/ERA5/waves/",
"filename_style": "ERA5_global_waves_monthly_",
"variables": {
"Stokes_U": "ust",
"Stokes_V": "vst",
"wave_Tp": "pp1d"
},
"dimensions": {
"lat": "latitude",
"lon": "longitude",
"time": "time"
},
"indices": {}
},
"wind": {
"directory": "/storage/shared/oceanparcels/output_data/data_Michael/ERA5/wind/",
"filename_style": "ERA5_global_wind_monthly_",
"variables": {
"Wind_U": "u10",
"Wind_V": "v10"
},
"dimensions": {
"lat": "latitude",
"lon": "longitude",
"time": "time"
},
"indices": {}
},
"unbeaching": {
"directory": "input_data/NEMO0083/",
"filename": "land_current_NEMO0083.nc",
"variables": {
"unbeach_U": "land_current_u",
"unbeach_V": "land_current_v"
},
"dimensions": {
"lat": "lat",
"lon": "lon"
}
},
"simulation": {
"start_date": null,
"runtime": null,
"dt_write": null,
"dt_timestep": null
},
"release_maps": {
"coastal": "input_data/NEMO0083/coastal_population_MPW_NEMO0083.csv",
"rivers": "input_data/NEMO0083/river_emissions_NEMO0083.csv",
"fisheries": "input_data/NEMO0083/agg_data_fisheries_info.csv",
"global_concentrations": null
}
}
Loading

0 comments on commit 23d4e5a

Please sign in to comment.