-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from cedadev/CF1.12
Version 2024.8.9 - CF-1.12 updates
- Loading branch information
Showing
68 changed files
with
1,657 additions
and
3,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Automatic Test | ||
# Specify which GitHub events will trigger a CI build | ||
|
||
on: push | ||
# Define a single job, build | ||
|
||
jobs: | ||
build: | ||
# Specify an OS for the runner | ||
runs-on: ubuntu-latest | ||
|
||
#Define steps | ||
steps: | ||
|
||
# Firstly, checkout repo | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
# Set up Python env | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
# Install dependencies | ||
- name: Install Python dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install -r requirements.txt | ||
pip3 install -e . | ||
# Test with pytest | ||
- name: Run pytest | ||
run: | | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .backendentrypoint import CFANetCDFBackendEntrypoint | ||
from .backend import CFANetCDFBackendEntrypoint |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
__author__ = "Daniel Westwood" | ||
__contact__ = "[email protected]" | ||
__copyright__ = "Copyright 2023 United Kingdom Research and Innovation" | ||
|
||
from xarray.backends import StoreBackendEntrypoint, BackendEntrypoint | ||
from xarray.backends.common import AbstractDataStore | ||
|
@@ -7,7 +10,6 @@ | |
from CFAPyX.datastore import CFADataStore | ||
|
||
from importlib.metadata import entry_points | ||
#engine = entry_points(group='xarray.backends') | ||
|
||
def open_cfa_dataset( | ||
filename_or_obj, | ||
|
@@ -19,6 +21,7 @@ def open_cfa_dataset( | |
use_cftime=None, | ||
decode_timedelta=None, | ||
cfa_options={}, | ||
active_options={}, | ||
group=None, | ||
): | ||
""" | ||
|
@@ -46,7 +49,8 @@ def open_cfa_dataset( | |
store = CFADataStore.open(filename_or_obj, group=group) | ||
|
||
# Expands cfa_options into individual kwargs for the store. | ||
store.cfa_options = cfa_options | ||
store.cfa_options = cfa_options | ||
store.active_options = active_options | ||
|
||
# Xarray makes use of StoreBackendEntrypoints to provide the Dataset 'ds' | ||
store_entrypoint = CFAStoreBackendEntrypoint() | ||
|
@@ -59,6 +63,7 @@ def open_cfa_dataset( | |
drop_variables=drop_variables, | ||
use_cftime=use_cftime, | ||
decode_timedelta=decode_timedelta, | ||
use_active=store.use_active | ||
) | ||
|
||
return ds | ||
|
@@ -80,6 +85,7 @@ def open_dataset( | |
use_cftime=None, | ||
decode_timedelta=None, | ||
cfa_options={}, | ||
active_options={}, | ||
group=None, | ||
# backend specific keyword arguments | ||
# do not use 'chunks' or 'cache' here | ||
|
@@ -99,12 +105,12 @@ def open_dataset( | |
use_cftime=use_cftime, | ||
decode_timedelta=decode_timedelta, | ||
cfa_options=cfa_options, | ||
active_options=active_options, | ||
group=group) | ||
|
||
|
||
class CFAStoreBackendEntrypoint(StoreBackendEntrypoint): | ||
description = "Open CFA-based Abstract Data Store" | ||
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.StoreBackendEntrypoint.html" | ||
url = "https://cedadev.github.io/CFAPyX/" | ||
|
||
def open_dataset( | ||
self, | ||
|
@@ -117,6 +123,7 @@ def open_dataset( | |
drop_variables=None, | ||
use_cftime=None, | ||
decode_timedelta=None, | ||
use_active=False, | ||
) -> Dataset: | ||
""" | ||
Takes cfa_xarray_store of type AbstractDataStore and creates an xarray.Dataset object. | ||
|
@@ -128,7 +135,6 @@ def open_dataset( | |
:returns: An xarray.Dataset object composed of xarray.DataArray objects representing the different | ||
NetCDF variables and dimensions. CFA aggregated variables are decoded unless the ``decode_cfa`` | ||
parameter in ``cfa_options`` is false. | ||
""" | ||
assert isinstance(cfa_xarray_store, AbstractDataStore) | ||
|
@@ -151,7 +157,18 @@ def open_dataset( | |
) | ||
|
||
# Create the xarray.Dataset object here. | ||
ds = Dataset(vars, attrs=attrs) | ||
if use_active: | ||
try: | ||
from XarrayActive import ActiveDataset | ||
|
||
ds = ActiveDataset(vars, attrs=attrs) | ||
except ImportError: | ||
raise ImportError( | ||
'"ActiveDataset" from XarrayActive failed to import - please ensure you have the XarrayActive package installed.' | ||
) | ||
else: | ||
ds = Dataset(vars, attrs=attrs) | ||
|
||
ds = ds.set_coords(coord_names.intersection(vars)) | ||
ds.set_close(cfa_xarray_store.close) | ||
ds.encoding = encoding | ||
|
Oops, something went wrong.