Skip to content

Commit 5ccc4c4

Browse files
committed
add example
1 parent cab4c21 commit 5ccc4c4

File tree

4 files changed

+84
-66
lines changed

4 files changed

+84
-66
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: check-json
1010
exclude: ^.devcontainer/devcontainer.json
1111
- id: pretty-format-json
12-
exclude: ^.devcontainer/devcontainer.json
12+
exclude: (^.devcontainer/devcontainer.json|\.ipynb$)
1313
args: [--autofix, --no-sort-keys]
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
@@ -20,3 +20,8 @@ repos:
2020
- id: ruff-check
2121
args: [ --exit-non-zero-on-fix ]
2222
- id: ruff-format
23+
24+
- repo: https://github.com/kynan/nbstripout
25+
rev: 0.8.1
26+
hooks:
27+
- id: nbstripout

README.md

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,26 @@
11
# xarray-esgf
22

3-
[![Release](https://img.shields.io/github/v/release/bopen/xarray-esgf)](https://img.shields.io/github/v/release/bopen/xarray-esgf)
4-
[![Build status](https://img.shields.io/github/actions/workflow/status/bopen/xarray-esgf/main.yml?branch=main)](https://github.com/bopen/xarray-esgf/actions/workflows/main.yml?query=branch%3Amain)
5-
[![codecov](https://codecov.io/gh/bopen/xarray-esgf/branch/main/graph/badge.svg)](https://codecov.io/gh/bopen/xarray-esgf)
6-
[![Commit activity](https://img.shields.io/github/commit-activity/m/bopen/xarray-esgf)](https://img.shields.io/github/commit-activity/m/bopen/xarray-esgf)
7-
[![License](https://img.shields.io/github/license/bopen/xarray-esgf)](https://img.shields.io/github/license/bopen/xarray-esgf)
8-
93
Xarray backend for ESGF data
104

11-
- **Github repository**: <https://github.com/bopen/xarray-esgf/>
12-
- **Documentation** <https://bopen.github.io/xarray-esgf/>
13-
14-
## Getting started with your project
15-
16-
### 1. Create a New Repository
17-
18-
First, create a repository on GitHub with the same name as this project, and then run the following commands:
19-
20-
```bash
21-
git init -b main
22-
git add .
23-
git commit -m "init commit"
24-
git remote add origin git@github.com:bopen/xarray-esgf.git
25-
git push -u origin main
5+
## Quick start
6+
7+
```python
8+
import xarray as xr
9+
10+
ESGPULL_PATH = # Set path to download data
11+
12+
ds = xr.open_dataset(
13+
{
14+
"project": "CMIP6",
15+
"experiment_id": "ssp*",
16+
"source_id": "EC-Earth3-CC",
17+
"frequency": "mon",
18+
"variable_id": ["tas", "pr"],
19+
"variant_label": "r1i1p1f1",
20+
},
21+
concat_dims="experiment_id",
22+
esgpull_path=ESGPULL_PATH,
23+
index_node="esgf.ceda.ac.uk",
24+
engine="esgf",
25+
)
2626
```
27-
28-
### 2. Set Up Your Development Environment
29-
30-
Then, install the environment and the pre-commit hooks with
31-
32-
```bash
33-
make install
34-
```
35-
36-
This will also generate your `uv.lock` file
37-
38-
### 3. Run the pre-commit hooks
39-
40-
Initially, the CI/CD pipeline might be failing due to formatting issues. To resolve those run:
41-
42-
```bash
43-
uv run pre-commit run -a
44-
```
45-
46-
### 4. Commit the changes
47-
48-
Lastly, commit the changes made by the two steps above to your repository.
49-
50-
```bash
51-
git add .
52-
git commit -m 'Fix formatting issues'
53-
git push origin main
54-
```
55-
56-
You are now ready to start development on your project!
57-
The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
58-
59-
To finalize the set-up for publishing to PyPI, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/publishing/#set-up-for-pypi).
60-
For activating the automatic documentation with MkDocs, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/mkdocs/#enabling-the-documentation-on-github).
61-
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/codecov/).
62-
63-
## Releasing a new version
64-
65-
66-
67-
---
68-
69-
Repository initiated with [fpgmaas/cookiecutter-uv](https://github.com/fpgmaas/cookiecutter-uv).

notebooks/quick_start.ipynb

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "0",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import xarray as xr\n",
11+
"\n",
12+
"ESGPULL_PATH = None # Set path to download data\n",
13+
"if ESGPULL_PATH is None:\n",
14+
" msg = \"Please set path to download data, otherwise it will use ~/.esgpull\"\n",
15+
" raise ValueError(msg)\n",
16+
"\n",
17+
"ds = xr.open_dataset(\n",
18+
" {\n",
19+
" \"project\": \"CMIP6\",\n",
20+
" \"experiment_id\": \"ssp*\",\n",
21+
" \"source_id\": \"EC-Earth3-CC\",\n",
22+
" \"frequency\": \"mon\",\n",
23+
" \"variable_id\": [\"tas\", \"pr\"],\n",
24+
" \"variant_label\": \"r1i1p1f1\",\n",
25+
" },\n",
26+
" concat_dims=\"experiment_id\",\n",
27+
" esgpull_path=ESGPULL_PATH,\n",
28+
" index_node=\"esgf.ceda.ac.uk\",\n",
29+
" engine=\"esgf\",\n",
30+
")"
31+
]
32+
}
33+
],
34+
"metadata": {
35+
"kernelspec": {
36+
"display_name": "Python 3 (ipykernel)",
37+
"language": "python",
38+
"name": "python3"
39+
},
40+
"language_info": {
41+
"codemirror_mode": {
42+
"name": "ipython",
43+
"version": 3
44+
},
45+
"file_extension": ".py",
46+
"mimetype": "text/x-python",
47+
"name": "python",
48+
"nbconvert_exporter": "python",
49+
"pygments_lexer": "ipython3",
50+
"version": "3.12.11"
51+
}
52+
},
53+
"nbformat": 4,
54+
"nbformat_minor": 5
55+
}

xarray_esgf/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def download(self) -> None:
8181
if isinstance(err, Exception):
8282
exceptions.append(err)
8383
if exceptions:
84-
raise ExceptionGroup("Errors", exceptions)
84+
msg = "Download errors"
85+
raise ExceptionGroup(msg, exceptions)
8586

8687
@use_new_combine_kwarg_defaults
8788
def open_dataset(

0 commit comments

Comments
 (0)