Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 48fe12a
Author: Carsten Ehbrecht <[email protected]>
Date:   Mon Nov 27 06:36:11 2023 +0100

    update conda env with clisops

commit f08309d
Author: Carsten Ehbrecht <[email protected]>
Date:   Fri Nov 24 19:43:51 2023 +0100

    update requirements for clisops

commit f2a2edf
Author: Carsten Ehbrecht <[email protected]>
Date:   Mon Nov 20 11:31:29 2023 +0100

    added roocs-grids conda package

commit 68fd5fa
Merge: b1deb93 a9a8ff9
Author: Pingu Carsti <[email protected]>
Date:   Fri Nov 17 15:47:04 2023 +0100

    Merge branch 'regrid-main' into regrid-main-ce

commit b1deb93
Author: Pingu Carsti <[email protected]>
Date:   Thu Nov 16 15:19:37 2023 +0100

    added dev requirements to workflow

commit b98da60
Author: Pingu Carsti <[email protected]>
Date:   Thu Nov 16 15:09:01 2023 +0100

    fix workflow

commit 962b60b
Author: Pingu Carsti <[email protected]>
Date:   Thu Nov 16 15:07:26 2023 +0100

    test with conda on github

commit 5167449
Author: Pingu Carsti <[email protected]>
Date:   Thu Nov 16 14:07:24 2023 +0100

    update regrid test

commit 733772f
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 19:54:53 2023 +0100

    skip xfail

commit 814cf37
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 18:25:10 2023 +0100

    added xesmf

commit c0d0d8d
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:58:14 2023 +0100

    use regrid branch of clisops

commit f06e440
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:37:17 2023 +0100

    xfail regrid

commit b36a0ef
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:37:04 2023 +0100

    revert to main

commit 9b4d64d
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:25:38 2023 +0100

    xfail all regrid tests

commit 14f7b3b
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:18:21 2023 +0100

    xfail regrid test

commit 08e78a3
Merge: 469427f 4b94991
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 15:13:11 2023 +0100

    Merge branch 'prepare-release-0.8.2' into regrid-main-ce

commit 4b94991
Author: Pingu Carsti <[email protected]>
Date:   Wed Nov 15 14:37:05 2023 +0100

    fix errors in docs build

commit 4095532
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 17:25:32 2023 +0100

    update rtd config

commit 81816f1
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 17:21:29 2023 +0100

    updated history

commit 2672d73
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 17:15:32 2023 +0100

    pep8

commit 5674f9b
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 17:12:14 2023 +0100

    enabled lint

commit b7d07ec
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 16:56:12 2023 +0100

    test also on python 3.10 and 3.11

commit 9e651a5
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 16:55:53 2023 +0100

    update dependency to clisops >=0.10

commit 105eb12
Merge: babe443 d662261
Author: Pingu Carsti <[email protected]>
Date:   Tue Nov 14 16:50:31 2023 +0100

    Merge branch 'master' into prepare-release-0.8.2

commit babe443
Author: Carsten Ehbrecht <[email protected]>
Date:   Wed Feb 1 16:42:41 2023 +0100

    updete dev requirements

commit 209b17f
Author: Carsten Ehbrecht <[email protected]>
Date:   Wed Feb 1 15:16:29 2023 +0100

    update history

commit 78107f5
Author: Carsten Ehbrecht <[email protected]>
Date:   Wed Feb 1 15:11:35 2023 +0100

    update pre-commit

commit 39d6d3c
Author: Carsten Ehbrecht <[email protected]>
Date:   Wed Feb 1 14:51:45 2023 +0100

    update reqs
  • Loading branch information
cehbrecht committed Nov 27, 2023
1 parent a9a8ff9 commit 2fea59b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 39 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,46 @@ on: [ push, pull_request ]
jobs:
build:

name: Conda Build with Python${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install packages
run: |
sudo apt-get -y install pandoc
if: matrix.python-version == 3.8
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
if: matrix.python-version == 3.9
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
python-version: ${{ matrix.python-version }}
cache-downloads: true
cache-environment: true
environment-file: environment.yml
create-args: >-
conda
python=${{ matrix.python-version }}
- name: Conda and Mamba versions
run: |
conda --version
echo "micromamba: $(micromamba --version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# pip install flake8 black pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install --no-user --editable "."
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
# pip install the package, command-line unit tests work
pip install --no-deps -e .
- name: Lint with flake8
run: make lint
if: matrix.python-version == 3.8
if: matrix.python-version == 3.9
# - name: Check formatting with black
# run: black --check --target-version py38 daops tests
# if: matrix.python-version == 3.8
# run: black --check --target-version py39 daops tests
# if: matrix.python-version == 3.9
- name: Test with pytest
run: |
python -m pytest -v tests
- name: Build docs 🏗️
run: make docs
if: matrix.python-version == 3.8
if: matrix.python-version == 3.9
2 changes: 1 addition & 1 deletion daops/ops/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def average_over_dims(
apply_fixes=True,
):
"""
Average input dataset over indicated dimensions.
Average input dataset according over indicated dimensions.
Can be averaged over multiple dimensions.
Parameters
Expand Down
10 changes: 6 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ channels:
- defaults
dependencies:
- pip
- numpy>=1.16
- xarray>=0.15
- numpy >=1.16
- xarray >=0.21,<2023.3.0 # https://github.com/pydata/xarray/issues/7794
- dask
- netcdf4
- clisops>=0.10.0
- clisops >=0.12.0
- roocs-grids >=0.1.2
- xesmf >=0.8.2
- elasticsearch>=7.9.1
- roocs-utils>=0.6.2
# logging
- loguru>=0.5.3
- loguru >=0.5.3
# catalog
- intake
- fsspec
Expand Down
9 changes: 6 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
numpy>=1.16
xarray>=0.19
xarray>=0.21
xesmf>=0.8.2
dask[complete]
cftime
netcdf4
elasticsearch>=8.0.1
clisops>=0.10.0
roocs-utils>=0.6.2
clisops>=0.12.0
## clisops @ git+https://github.com/roocs/clisops.git@master#egg=clisops
roocs-utils>=0.6.4
roocs_grids>=0.1.2
# logging
loguru>=0.5.3
# catalog
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ def load_esgf_test_data():
repo = Repo(target)
repo.git.checkout(branch)
repo.remotes[0].pull()

8 changes: 4 additions & 4 deletions tests/test_operations/test_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_average_dims_time(tmpdir):


@pytest.mark.online
def test_average_time_lat(tmpdir, load_esgf_test_data):
def test_average_time_lat(tmpdir):
result = average_over_dims(
CMIP5_IDS[1],
dims=["latitude", "time"],
Expand All @@ -51,7 +51,7 @@ def test_average_time_lat(tmpdir, load_esgf_test_data):


@pytest.mark.online
def test_average_time_lon(tmpdir, load_esgf_test_data):
def test_average_time_lon(tmpdir):
result = average_over_dims(
CMIP5_IDS[1],
dims=["time", "longitude"],
Expand All @@ -66,7 +66,7 @@ def test_average_time_lon(tmpdir, load_esgf_test_data):


@pytest.mark.online
def test_average_none(tmpdir, load_esgf_test_data):
def test_average_none(tmpdir):
with pytest.raises(InvalidParameterValue) as exc:
average_over_dims(
CMIP5_IDS[1],
Expand All @@ -79,7 +79,7 @@ def test_average_none(tmpdir, load_esgf_test_data):


@pytest.mark.online
def test_average_level(tmpdir, load_esgf_test_data):
def test_average_level(tmpdir):
with pytest.raises(InvalidParameterValue) as exc:
average_over_dims(
CMIP5_IDS[1],
Expand Down
22 changes: 11 additions & 11 deletions tests/test_operations/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

import pytest
import xarray as xr
from roocs_utils.exceptions import InvalidParameterValue

from daops import CONFIG
from daops.ops.regrid import regrid

CMIP5_IDS = [
"cmip5.output1.INM.inmcm4.rcp45.mon.ocean.Omon.r1i1p1.latest.zostoga",
"cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas",
"cmip5.output1.MOHC.HadGEM2-ES.historical.mon.land.Lmon.r1i1p1.latest.rh",
]
CMIP5_MRSOS_ID = "cmip5.output1.MOHC.HadGEM2-ES.rcp85.day.land.day.r1i1p1.latest.mrsos"
# from daops.ops.regrid import regrid

# TODO: remove when upgraded to new clisops version
# pytestmark = pytest.mark.xfail(reason="needs clisops>=0.12 with regrid operator")

CMIP6_IDS = ["CMIP6.CMIP.MPI-M.MPI-ESM1-2-HR.historical.r1i1p1f1.Omon.tos.gn.v20190710"]


def _check_output_nc(result, fname="output_001.nc"):
Expand All @@ -21,8 +18,10 @@ def _check_output_nc(result, fname="output_001.nc"):

@pytest.mark.online
def test_regrid(tmpdir, load_esgf_test_data):
from daops.ops.regrid import regrid

result = regrid(
CMIP5_MRSOS_ID,
CMIP6_IDS[0],
method="conservative",
adaptive_masking_threshold=0.5,
grid="1deg",
Expand All @@ -33,4 +32,5 @@ def test_regrid(tmpdir, load_esgf_test_data):

_check_output_nc(result)
ds = xr.open_dataset(result.file_uris[0], use_cftime=True)

assert "time" in ds.dims
assert "tos" in ds

0 comments on commit 2fea59b

Please sign in to comment.