Skip to content

Commit 12137fc

Browse files
authored
Merge pull request #14 from cedadev/creator
CFA: Create Functionality
2 parents 0963355 + 7bfe702 commit 12137fc

40 files changed

+1418
-163
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ jobs:
1414

1515
# Firstly, checkout repo
1616
- name: Checkout repository
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
# Set up Python env
1919
- name: Setup Python
20-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v5
2121
with:
2222
python-version: 3.11
2323
# Install dependencies
2424
- name: Install Python dependencies
2525
run: |
2626
python3 -m pip install --upgrade pip
27-
pip3 install -r requirements.txt
28-
pip3 install -e .
27+
pip3 install poetry
28+
poetry install
2929
# Test with pytest
3030
- name: Run pytest
3131
run: |
32-
pytest
32+
poetry run pytest

.github/workflows/sphinx.yml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,46 @@ on:
1212

1313
jobs:
1414
build:
15-
# Linux version requirements
15+
# Specify an OS for the runner
1616
runs-on: ubuntu-latest
17+
18+
#Define steps
1719
steps:
18-
# Checkout and build the docs with sphinx
19-
- uses: actions/checkout@v2
2020

21-
- name: Set up Python 3.10
22-
uses: actions/setup-python@v2
23-
with:
24-
python-version: "3.10"
21+
# Firstly, checkout repo
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
# Set up Python env
25+
- name: Setup Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: 3.11
29+
# Install dependencies
30+
- name: Install Python dependencies
31+
run: |
32+
python3 -m pip install --upgrade pip
33+
pip3 install poetry
34+
poetry install
35+
36+
- name: Build documentation
37+
run: |
38+
mkdir gh-pages
39+
touch gh-pages/.nojekyll
40+
pushd docs/source/
41+
poetry run sphinx-build -b html . _build
42+
popd
43+
cp -r docs/source/_build/* gh-pages/
2544
26-
- name: Build HTML
27-
uses: ammaraskar/sphinx-action@master
28-
with:
29-
docs-folder: "docs/"
30-
# pre-build-command: "mkdir /tmp/sphinx-log"
31-
- name: Upload artifacts
32-
uses: actions/upload-artifact@v1
33-
with:
34-
name: html-docs
35-
path: docs/build/html/
36-
# Deploys to the gh-pages branch if the commit was made to main, the
37-
# gh-pages then takes over serving the html
38-
- name: Deploy
39-
uses: peaceiris/actions-gh-pages@v3
40-
if: github.ref == 'refs/heads/main'
41-
with:
42-
github_token: ${{ secrets.GITHUB_TOKEN }}
43-
publish_dir: docs/build/html
45+
- name: Upload artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: html-docs
49+
path: gh-pages
50+
# Deploys to the gh-pages branch if the commit was made to main, the
51+
# gh-pages then takes over serving the html
52+
- name: Deploy documentation
53+
if: ${{ github.event_name == 'push' }}
54+
uses: JamesIves/[email protected]
55+
with:
56+
branch: gh-pages
57+
folder: gh-pages

CFAPyX/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
CFA python Xarray module for using CFA files with xarray.
44

55
See the [Documentation](https://cedadev.github.io/CFAPyX/) for more details.
6-
CFAPyX on [Github](https://github.com/cedadev/CFAPyX)
6+
cfapyx on [Github](https://github.com/cedadev/CFAPyX)
77

88
For use with the Xarray module as an additional backend.
99

10+
> **_NOTE:_** The `create` functionality was added to version 2024.10.11 and is currently in alpha release. Please report any unexpected errors or issues using the GitHub Issues tab for this repository.
11+
1012
# Installation
1113

1214
```
1315
pip install xarray==2024.6.0
14-
pip install CFAPyX
16+
pip install cfapyx
1517
```
1618

17-
# Usage
19+
# Usage as Xarray Engine
1820

1921
```
2022
import xarray as xr

cfapyx/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .backend import CFANetCDFBackendEntrypoint
2+
3+
from .creator import CFANetCDF

CFAPyX/backend.py renamed to cfapyx/backend.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from xarray.core.dataset import Dataset
88
from xarray import conventions
99

10-
from CFAPyX.datastore import CFADataStore
10+
from cfapyx.datastore import CFADataStore
11+
12+
import logging
13+
14+
logger = logging.getLogger(__name__)
1115

1216
def open_cfa_dataset(
1317
filename_or_obj,
@@ -18,7 +22,7 @@ def open_cfa_dataset(
1822
decode_coords=None,
1923
use_cftime=None,
2024
decode_timedelta=None,
21-
cfa_options={},
25+
cfa_options: dict=None,
2226
group=None,
2327
):
2428
"""
@@ -42,6 +46,8 @@ def open_cfa_dataset(
4246
parameter in ``cfa_options`` is false.
4347
"""
4448

49+
cfa_options = cfa_options or {}
50+
4551
# Load the CFA datastore from the provided file (object not supported).
4652
store = CFADataStore.open(filename_or_obj, group=group)
4753

@@ -70,7 +76,7 @@ def open_cfa_dataset(
7076

7177
class CFANetCDFBackendEntrypoint(BackendEntrypoint):
7278

73-
description = "Open CFA-netCDF files (.nca) using CFA-PyX in Xarray"
79+
description = 'Open CFA-netCDF files (.nca) using "cfapyx" in Xarray'
7480
url = "https://cedadev.github.io/CFAPyX/"
7581

7682
def open_dataset(
@@ -84,7 +90,7 @@ def open_dataset(
8490
decode_coords=None,
8591
use_cftime=None,
8692
decode_timedelta=None,
87-
cfa_options={},
93+
cfa_options=None,
8894
group=None,
8995
# backend specific keyword arguments
9096
# do not use 'chunks' or 'cache' here
@@ -94,6 +100,8 @@ def open_dataset(
94100
CFA aggregated variables into proper arrays.
95101
"""
96102

103+
cfa_options = cfa_options or {}
104+
97105
return open_cfa_dataset(
98106
filename_or_obj,
99107
drop_variables=drop_variables,
@@ -113,7 +121,6 @@ class CFAStoreBackendEntrypoint(StoreBackendEntrypoint):
113121
def open_dataset(
114122
self,
115123
cfa_xarray_store,
116-
*,
117124
mask_and_scale=True,
118125
decode_times=True,
119126
concat_characters=True,

0 commit comments

Comments
 (0)