Skip to content

Commit 74b2a8d

Browse files
authored
Merge pull request #345 from British-Oceanographic-Data-Centre/develop
Develop
2 parents d4dcba4 + b7947bd commit 74b2a8d

File tree

92 files changed

+13890
-5905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+13890
-5905
lines changed

.github/workflows/build_package.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.7, 3.8]
13+
python-version: [ 3.7, 3.8, 3.9 ]
1414

1515
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v1
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip virtualenv
24-
python -m pip install -r requirements.txt
25-
- name: Shell Script Permissions
26-
run: |
27-
chmod +x *.sh
28-
- name: Setup Environment
29-
run: |
30-
./setup_environment.sh
31-
- name: Build Package
32-
run: |
33-
./build.sh
34-
- name: Test Package Install
35-
run: |
36-
python -m pip install dist/COAsT-*.tar.gz
37-
- name: Generate Conda Metadata
38-
run: |
39-
./generate_conda_meta.sh
40-
cat conda/meta.yaml
16+
- uses: actions/checkout@v2
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip virtualenv
24+
python -m pip install -r requirements.txt
25+
- name: Shell Script Permissions
26+
run: |
27+
chmod +x *.sh
28+
- name: Setup Environment
29+
run: |
30+
./setup_environment.sh
31+
- name: Build Package
32+
run: |
33+
./build.sh
34+
- name: Test Package Install
35+
run: |
36+
python -m pip install dist/COAsT-*.tar.gz
37+
- name: Generate Conda Metadata
38+
run: |
39+
./generate_conda_meta.sh
40+
cat conda/meta.yaml

.github/workflows/formatting.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Black
2+
on: pull_request
3+
jobs:
4+
formatting:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: [ 3.9 ]
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: Set up Python ${{ matrix.python-version }} for Black
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: ${{ matrix.python-version }}
15+
- name: Install Black
16+
run: pip install black
17+
- name: Check Formatting
18+
run: black --check . # Only check the formatting, don't make any changes
19+
- name: Apply Formatting
20+
if: failure() # Only run if Black suggests changes
21+
run: |
22+
black .
23+
git config --global user.name "BlackBot"
24+
git config --global author.name "BlackBot"
25+
git config --global user.email "bodcsoft@bodc.ac.uk"
26+
git config --global author.email "bodcsoft@bodc.ac.uk"
27+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
28+
git checkout $GITHUB_HEAD_REF
29+
git commit -am "Apply Black formatting to Python code."
30+
git push

.github/workflows/publish_package.yml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [3.7]
13+
python-version: [ 3.7 ]
1414

1515
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v1
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip virtualenv
24-
python -m pip install -r requirements.txt
25-
- name: Shell Script Permissions
26-
run: |
27-
chmod +x *.sh
28-
- name: Setup Environment
29-
run: |
30-
./setup_environment.sh
31-
- name: Build Package
32-
run: |
33-
./build.sh
34-
- name: Test Package Install
35-
run: |
36-
python -m pip install dist/COAsT-*.tar.gz
37-
- name: Publish Package to PyPi
38-
shell: bash
39-
env:
40-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
41-
run: |
42-
./publish.sh "https://upload.pypi.org/legacy/" "$PYPI_TOKEN"
43-
- name: Generate Conda Metadata
44-
run: |
45-
./generate_conda_meta.sh
46-
cat conda/meta.yaml
47-
- name: Publish Package to Anaconda
48-
uses: fcakyon/conda-publish-action@v1.3
49-
with:
50-
subdir: "conda"
51-
anacondatoken: ${{ secrets.ANACONDA_TOKEN }}
52-
platforms: 'win osx linux'
16+
- uses: actions/checkout@v2
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip virtualenv
24+
python -m pip install -r requirements.txt
25+
- name: Shell Script Permissions
26+
run: |
27+
chmod +x *.sh
28+
- name: Setup Environment
29+
run: |
30+
./setup_environment.sh
31+
- name: Build Package
32+
run: |
33+
./build.sh
34+
- name: Test Package Install
35+
run: |
36+
python -m pip install dist/COAsT-*.tar.gz
37+
- name: Publish Package to PyPi
38+
shell: bash
39+
env:
40+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
41+
run: |
42+
./publish.sh "https://upload.pypi.org/legacy/" "$PYPI_TOKEN"
43+
- name: Generate Conda Metadata
44+
run: |
45+
./generate_conda_meta.sh
46+
cat conda/meta.yaml
47+
- name: Publish Package to Anaconda
48+
uses: fcakyon/conda-publish-action@v1.3
49+
with:
50+
subdir: "conda"
51+
anacondatoken: ${{ secrets.ANACONDA_TOKEN }}
52+
platforms: 'win osx linux'

.github/workflows/verify_package.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
name: Test Python Package
22

3-
on: [push]
3+
on: [ push ]
44

55
jobs:
66
build:
77

88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.7, 3.8]
11+
python-version: [ 3.7, 3.8, 3.9 ]
1212

1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v1
17-
with:
18-
python-version: ${{ matrix.python-version }}
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23-
- name: Lint with flake8
24-
run: |
25-
pip install flake8
26-
# stop the build if there are Python syntax errors or undefined names
27-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
30-
- name: Test with pytest
31-
run: |
32-
pip install dask[complete]
33-
pip install -r requirements.txt
34-
pytest tests
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt
23+
- name: Lint with flake8
24+
run: |
25+
pip install flake8
26+
# stop the build if there are Python syntax errors or undefined names
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
30+
- name: Test with pytest
31+
run: |
32+
pip install dask[complete]
33+
pip install -r requirements.txt
34+
pytest tests

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ unit_testing/*log
2020
*.pyc
2121

2222
*.DS_Store
23+
24+
.vscode
25+
# development ignores
26+
sandbox.py
27+
28+
config/nemo_tst_gridded.json
29+

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ ________________________________________________________________________________
1010
`.____ .' `.___.'|____| |____|[\__) )|_____|
1111
1212
Coastal Ocean Assessment Toolbox
13-
https://www.nemo-ocean.eu/
1413
1514
__________________________________________________________________________________________
1615
```
@@ -24,33 +23,35 @@ Documentation can be found [here](https://british-oceanographic-data-centre.gith
2423

2524
COAsT is an object-orientated package, meaning that data is stored within Python object
2625
structures. In addition to data storage, these objects contain methods (subroutines)
27-
which allow for manipulation of this data. An example of such an object is the NEMO
28-
object, which allows for the storage and manipulation of NEMO output and domain data. It
26+
which allow for manipulation of this data. An example of such an object is the Gridded
27+
object, which allows for the storage and manipulation of (e.g.) NEMO output and domain data. It
2928
is important to understand how to load data using COAsT and the structure of the resulting
3029
objects.
3130

32-
A NEMO object is created and initialised by passing it the paths of the domain and data
31+
A Gridded object is created and initialised by passing it the paths of the domain and data
3332
files. Ideally, the grid type should also be specified (T, U, V or F in the case of NEMO).
3433
For example, to load in data from a file containing data on a NEMO T-grid:
3534

3635
```
3736
import coast
3837
39-
fn_data = '<path to T-grid data file(s)>'
40-
fn_domain = '<path to domain file>'
41-
42-
data = coast.NEMO(fn_data, fn_domain, grid_ref='t-grid')
38+
fn_data = "<path to T-grid data file(s)>"
39+
fn_domain = "<path to domain file>"
40+
fn_config = "<path to JSON config file>"
41+
data = coast.Gridded(fn_data, fn_domain, fn_config)
4342
```
4443

45-
Ideally, NEMO output data should be in grid-specific files, i.e. containing output
46-
variables situated on a NEMO T, U, V or F grid. The whole domain file is supplied,
47-
however only grid specific variables are placed into the NEMO object. A NEMO object
48-
therefore contains grid-specific data and all corresponding grid variables. One of the
49-
file names can be omitted (to get a data-only or grid only object), however functionality
50-
in this case will be limited.
44+
Ideally, Gridded model output data should be in grid-specific files, i.e.
45+
containing output variables situated on a NEMO T, U, V or F grid, whereas the
46+
grid variables are in a single domain file. On loading into COAsT, only the
47+
grid specific variables appropriate for the paired data are placed into the
48+
Gridded object. A Gridded object therefore contains grid-specific data and all
49+
corresponding grid variables. One of the file names can be omitted (to get a
50+
data-only or grid only object), however functionality in this case will be
51+
limited.
5152

52-
Once loaded, data is stored inside the object using an xarray.dataset object. Following
53-
on from the previous code example, this can be viewed by calling:
53+
Once loaded, data is stored inside the object using an xarray.dataset object.
54+
Following on from the previous code example, this can be viewed by calling:
5455

5556
```
5657
data.dataset
@@ -90,8 +91,9 @@ that indexing will preserve lazy loading, however and direct access or modifying
9091
data will not. For this reason, if you require a subset of the data, it is best to
9192
index first.
9293

93-
The names of common grid variables are standardised within the COAsT package for
94-
consistency and ease of use. Along with their original NEMO names, these are:
94+
The names of common grid variables are standardised within the COAsT package
95+
using JSON configuration files. For example, the following lists COAsT internal
96+
variable followed by the typical NEMO variable names:
9597

9698
1. longitude [glamt / glamu / glamv / glamf]
9799
2. latitude [gphit / gphiu / gphiv / gphif]

coast/CLIMATOLOGY.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)