Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 20 additions & 37 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,33 @@ on:
branches: ['main']
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Weekly “At 00:00”

# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true

# Note: This CI used to run off of the image:
# carbonplan/cmip6-downscaling-single-user:2022.06.19
- cron: '0 0 * * 0' # Weekly "At 00:00"

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/setup-pixi@v0.8.5
with:
pixi-version: v0.62.2
environments: dev
cache: true
- run: pixi run -e dev prek run --all-files

test:
name: ${{ matrix.python-version }}-build
name: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
timeout-minutes: 20
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install Conda environment from environment.yml
uses: mamba-org/setup-micromamba@v1
- uses: prefix-dev/setup-pixi@v0.8.5
with:
# environment-file is not assumed anymore
environment-file: ci/environment.yaml
create-args: >-
python=${{ matrix.python-version }}
# now called cache-environment
cache-environment: true
post-cleanup: 'none'
cache-downloads: false
pixi-version: v0.62.2
environments: dev
cache: true

- name: Install package
run: |
python -m pip install -e .[dev]
- name: Conda list information
run: |
conda env list
conda list
- name: Run tests
run: |
python -m pytest tests
run: pixi run -e dev pytest tests
4 changes: 2 additions & 2 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-python@v5.0.0
name: Install Python
with:
python-version: '3.11'
python-version: '3.13'

- name: Install dependencies
run: |
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- uses: actions/setup-python@v5.0.0
name: Install Python
with:
python-version: '3.11'
python-version: '3.13'
- uses: actions/download-artifact@v4
with:
name: releases
Expand Down
23 changes: 3 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,29 +14,12 @@ repos:
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
hooks:
- id: pyupgrade
args:
- '--py38-plus'

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.276'
rev: 'v0.11.12'
hooks:
- id: ruff
args: ['--fix']
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
Expand Down
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,31 @@ src='https://images.carbonplan.org/highlights/cmip6-downscaling-dark.png'
This repository includes our tools/scripts/models/etc for climate downscaling. This work is described in more detail in a [web article](https://carbonplan.org/research/cmip6-downscaling-explainer) with
a companion [map tool](https://carbonplan.org/research/cmip6-downscaling) to explore the data. We encourage you to reach out if you are interested in using the code or datasets by [opening an issue](https://github.com/carbonplan/cmip6-downscaling/issues/new) or [sending us an email](mailto:hello@carbonplan.org).

## install
## development

```shell
python -m pip install cmip6_downscaling
```
Requires [pixi](https://pixi.sh). Clone the repo, then:

## usage

```python
from cmip6_downscaling.methods import ...
```shell
pixi install -e dev
pixi run -e dev pytest tests
```

## data access

There are two ways to access the data using Python.
There are three ways to access the data using Python.

First, the entire collection of datasets at daily timescales is available through an `intake` catalog using the following code snippet.

```python
# /// script
# dependencies = [
# "xarray",
# "aiohttp",
# "intake-esm",
# "dask",
# ]
# ///
#
import intake
cat = intake.open_esm_datastore(
'https://rice1.osn.mghpcc.org/carbonplan/cp-cmip/version1/catalog/osn-rechunked-global-downscaled-cmip6.json'
Expand All @@ -56,6 +62,26 @@ import xarray as xr
xr.open_zarr('https://rice1.osn.mghpcc.org/carbonplan/cp-cmip/version1/data/DeepSD/ScenarioMIP.CCCma.CanESM5.ssp245.r1i1p1f1.day.DeepSD.pr.zarr',chunks={})
```

The datasets are also available as [Icechunk](https://icechunk.io) stores, which use zarr v3 sharding for efficient cloud-native access. These stores are anonymously readable and can be opened with xarray as follows:

```python
import icechunk
import xarray as xr

storage = icechunk.s3_storage(
bucket="carbonplan",
prefix="cp-cmip/version1/icechunk_data/DeepSD/ScenarioMIP.CCCma.CanESM5.ssp245.r1i1p1f1.day.DeepSD.pr.zarr",
endpoint_url="https://rice1.osn.mghpcc.org",
force_path_style=True,
anonymous=True,
)
repo = icechunk.Repository.open(storage)
session = repo.readonly_session("main")
ds = xr.open_zarr(session.store, chunks={})
```

The prefix follows the pattern `cp-cmip/version1/icechunk_data/{method}/{store_name}` where `method` and `store_name` match the values in the intake catalog.

## license

All the code in this repository is [MIT](https://choosealicense.com/licenses/mit/)-licensed. Some of the data provided by this API is sourced from content made available under a [CC-BY-4.0](https://choosealicense.com/licenses/cc-by-4.0/) license. We include attribution for this content, and we please request that you also maintain that attribution if using this data.
Expand Down
Loading
Loading