Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lafferty and Sriver partition #1529

Merged
merged 29 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2dec6b6
add lafferty
juliettelavoie Nov 15, 2023
8c7a747
init and doc
juliettelavoie Nov 15, 2023
12d0849
attrs
juliettelavoie Nov 15, 2023
da003bb
remove attrs
juliettelavoie Nov 15, 2023
80d7a3d
Merge branch 'master' into add_laferty_partition
Zeitsperre Nov 16, 2023
69509fa
Merge branch 'master' into add_laferty_partition
Zeitsperre Nov 29, 2023
8e8441d
add test and weights
huard Nov 30, 2023
f44b2f8
Merge branch 'master' into add_laferty_partition
huard Nov 30, 2023
95caf97
Merge remote-tracking branch 'origin/add_laferty_partition' into add_…
huard Nov 30, 2023
a0939af
info for figanos + fraction arg
juliettelavoie Dec 11, 2023
2697210
mention xscen and figanos functions in doc
juliettelavoie Dec 12, 2023
fd4bece
Merge branch 'master' into add_laferty_partition
Zeitsperre Dec 12, 2023
5667095
Added test based on data published by Lafferty and Sriver. Added frac…
huard Dec 12, 2023
92ebcd9
keep element coord in fractional_uncertainty
juliettelavoie Dec 13, 2023
e312c8d
typo
juliettelavoie Dec 13, 2023
d4b74fa
Updated CHANGES with lafferty_sriver.
huard Dec 13, 2023
177eef5
Remove fraction argument. Add note in docstring on using fractional_u…
huard Dec 13, 2023
ed31058
replace elements coords by attrs
juliettelavoie Dec 13, 2023
c10b7a8
remove test of baseline zero
juliettelavoie Dec 13, 2023
0b80081
removed the wrong one oups
juliettelavoie Dec 13, 2023
adc89ce
remove scenario test
juliettelavoie Dec 13, 2023
04f6aaf
add test for mean uncertainty
juliettelavoie Dec 14, 2023
d6cccd3
update testdata
juliettelavoie Dec 14, 2023
02c5ad8
remove branch to tesdata
juliettelavoie Dec 14, 2023
da3527f
update xclim-testdata. Fix bug in get_file looking for master branch …
huard Dec 14, 2023
44a789a
merge
huard Dec 14, 2023
daadf07
typo in tag name
huard Dec 14, 2023
888e902
black
huard Dec 14, 2023
3eb8dd1
ensure caching is safe
Zeitsperre Dec 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
- submitted

env:
XCLIM_TESTDATA_BRANCH: v2023.12.14
XCLIM_TESTDATA_BRANCH: v2023.12.24
huard marked this conversation as resolved.
Show resolved Hide resolved

concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on master.
Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from xclim.testing import helpers
from xclim.testing.helpers import test_timeseries
from xclim.testing.utils import _default_cache_dir # noqa
from xclim.testing.utils import get_file
from xclim.testing.utils import open_dataset as _open_dataset

if not __xclim_version__.endswith("-beta") and helpers.TESTDATA_BRANCH == "main":
Expand Down Expand Up @@ -429,6 +430,24 @@ def ensemble_dataset_objects() -> dict:
return edo


@pytest.fixture(scope="session")
def lafferty_sriver_ds() -> xr.Dataset:
import pandas as pd

# Get data from Lafferty & Sriver unit test
# https://github.com/david0811/lafferty-sriver_2023_npjCliAtm/tree/main/unit_test
fn = get_file("uncertainty_partitioning/seattle_avg_tas.csv")

df = pd.read_csv(fn, parse_dates=["time"]).rename(
columns={"ssp": "scenario", "ensemble": "downscaling"}
)

# Make xarray dataset
return xr.Dataset.from_dataframe(
df.set_index(["scenario", "model", "downscaling", "time"])
)


@pytest.fixture(scope="session", autouse=True)
def gather_session_data(threadsafe_data_dir, worker_id, xdoctest_namespace):
"""Gather testing data on pytest run.
Expand Down
17 changes: 2 additions & 15 deletions tests/test_partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,9 @@ def test_lafferty_sriver_synthetic(random):
lafferty_sriver(da, sm=sm)


def test_lafferty_sriver():
import pandas as pd
def test_lafferty_sriver(lafferty_sriver_ds):
g, u = lafferty_sriver(lafferty_sriver_ds.tas)

# Get data from Lafferty & Sriver unit test
# https://github.com/david0811/lafferty-sriver_2023_npjCliAtm/tree/main/unit_test
fn = get_file("uncertainty_partitioning/seattle_avg_tas.csv")

df = pd.read_csv(fn, parse_dates=["time"]).rename(
columns={"ssp": "scenario", "ensemble": "downscaling"}
)

# Make xarray dataset
ds = xr.Dataset.from_dataframe(
df.set_index(["scenario", "model", "downscaling", "time"])
)
g, u = lafferty_sriver(ds.tas)
fu = fractional_uncertainty(u)

# Assertions based on expected results from
Expand Down
2 changes: 1 addition & 1 deletion xclim/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def file_md5_checksum(f_name):
def get_file(
name: str | os.PathLike | Sequence[str | os.PathLike],
github_url: str = "https://github.com/Ouranosinc/xclim-testdata",
branch: str = "master",
branch: str = "main",
cache_dir: Path = _default_cache_dir,
) -> Path | list[Path]:
"""Return a file from an online GitHub-like repository.
Expand Down
Loading