Skip to content

Commit

Permalink
Merge branch 'main' into student-recipes-4
Browse files Browse the repository at this point in the history
  • Loading branch information
sadielbartholomew authored Nov 8, 2024
2 parents 87a1932 + b5c40da commit d99bfd5
Show file tree
Hide file tree
Showing 93 changed files with 4,539 additions and 1,507 deletions.
18 changes: 16 additions & 2 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ version NEXTVERSION
* New keyword parameter to `cf.Field.derivative`:
``ignore_coordinate_units``
(https://github.com/NCAS-CMS/cf-python/issues/807)
* Allow access to netCDF-4 files in S3 object stores
(https://github.com/NCAS-CMS/cf-python/issues/712)
* New class `cf.H5netcdfArray`
* New class `cf.NetCDF4Array`
* New class `cf.CFAH5netcdfArray`
* New class `cf.CFANetCDF4Array`
* Fix bug that sometimes puts an incorrect ``radian-1`` or
``radian-2`` in the returned units of the differential operator
methods and functions
Expand All @@ -27,6 +33,12 @@ version NEXTVERSION
* Fix bug where `cf.normalize_slice` doesn't correctly
handle certain cyclic slices
(https://github.com/NCAS-CMS/cf-python/issues/774)
* New dependency: ``h5netcdf>=1.3.0``
* New dependency: ``h5py>=3.10.0``
* New dependency: ``s3fs>=2024.2.0``
* Changed dependency: ``1.11.2.0<=cfdm<1.11.3.0``
* Changed dependency: ``cfunits>=3.3.7``


----

Expand Down Expand Up @@ -141,6 +153,8 @@ version 3.16.0
* Changed dependency: ``1.11.0.0<=cfdm<1.11.1.0``
* New dependency: ``scipy>=1.10.0``

----

version 3.15.4
--------------

Expand Down Expand Up @@ -279,7 +293,7 @@ version 3.14.1

----

version 3.14.0 (*first Dask release*)
version 3.14.0 (*first Dask version*)
-------------------------------------

**2023-01-31**
Expand Down Expand Up @@ -314,7 +328,7 @@ version 3.14.0 (*first Dask release*)

----

version 3.13.1 (*last LAMA release*)
version 3.13.1 (*last LAMA version*)
------------------------------------

**2022-10-17**
Expand Down
27 changes: 16 additions & 11 deletions cf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
* read field constructs from netCDF, CDL, PP and UM datasets,
* read field constructs and domain constructs from netCDF, CDL, PP and
UM datasets with a choice of netCDF backends,
* read files from OPeNDAP servers and S3 object stores,
* create new field constructs in memory,
* write and append field constructs to netCDF datasets on disk,
* read, write, and manipulate UGRID mesh topologies,
* read, write, and create coordinates defined by geometry cells,
* read netCDF and CDL datasets containing hierarchical groups,
Expand Down Expand Up @@ -74,8 +81,8 @@
"""

__Conventions__ = "CF-1.11"
__date__ = "2024-04-26"
__version__ = "3.16.2"
__date__ = "2024-??-??"
__version__ = "3.17.0"

_requires = (
"numpy",
Expand Down Expand Up @@ -199,8 +206,8 @@
)

# Check the version of cfdm
_minimum_vn = "1.11.1.0"
_maximum_vn = "1.11.2.0"
_minimum_vn = "1.11.2.0"
_maximum_vn = "1.11.3.0"
_cfdm_version = Version(cfdm.__version__)
if not Version(_minimum_vn) <= _cfdm_version < Version(_maximum_vn):
raise RuntimeError(
Expand All @@ -209,12 +216,6 @@
)

# Check the version of dask
_minimum_vn = "2022.12.1"
if Version(dask.__version__) < Version(_minimum_vn):
raise RuntimeError(
f"Bad dask version: cf requires dask>={_minimum_vn}. "
f"Got {dask.__version__} at {dask.__file__}"
)

# Check the version of Python
_minimum_vn = "3.8.0"
Expand Down Expand Up @@ -274,15 +275,19 @@
from .data.array import (
BoundsFromNodesArray,
CellConnectivityArray,
CFANetCDFArray,
CFAH5netcdfArray,
CFANetCDF4Array,
FullArray,
GatheredArray,
H5netcdfArray,
NetCDFArray,
NetCDF4Array,
PointTopologyArray,
RaggedContiguousArray,
RaggedIndexedArray,
RaggedIndexedContiguousArray,
SubsampledArray,
UMArray,
)

from .data.fragment import (
Expand Down
2 changes: 1 addition & 1 deletion cf/cellmethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CellMethod(cfdm.CellMethod):
def __new__(cls, *args, **kwargs):
"""This must be overridden in subclasses.
.. versionadded:: (cfdm) 3.7.0
.. versionadded:: 3.7.0
"""
instance = super().__new__(cls)
Expand Down
79 changes: 30 additions & 49 deletions cf/cfimplementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
TiePointIndex,
)
from .data import Data

from .data.array import (
BoundsFromNodesArray,
CellConnectivityArray,
CFANetCDFArray,
CFAH5netcdfArray,
CFANetCDF4Array,
GatheredArray,
NetCDFArray,
H5netcdfArray,
NetCDF4Array,
PointTopologyArray,
RaggedContiguousArray,
RaggedIndexedArray,
Expand Down Expand Up @@ -112,65 +115,39 @@ def set_construct(self, parent, construct, axes=None, copy=True, **kwargs):
parent, construct, axes=axes, copy=copy, **kwargs
)

def initialise_CFANetCDFArray(
self,
filename=None,
address=None,
dtype=None,
mask=True,
units=False,
calendar=False,
instructions=None,
substitutions=None,
term=None,
x=None,
**kwargs,
):
"""Return a `CFANetCDFArray` instance.
def initialise_CFANetCDF4Array(self, **kwargs):
"""Return a `CFANetCDF4Array` instance.
:Parameters:
filename: `str`
address: (sequence of) `str` or `int`
dytpe: `numpy.dtype`
mask: `bool`, optional
kwargs: optional
Initialisation parameters to pass to the new instance.
units: `str` or `None`, optional
:Returns:
calendar: `str` or `None`, optional
`CFANetCDF4Array`
instructions: `str`, optional
"""
cls = self.get_class("CFANetCDF4Array")
return cls(**kwargs)

substitutions: `dict`, optional
def initialise_CFAH5netcdfArray(self, **kwargs):
"""Return a `CFAH5netcdfArray` instance.
term: `str`, optional
.. versionadded:: NEXTVERSION
x: `dict`, optional
:Parameters:
kwargs: optional
Ignored.
Initialisation parameters to pass to the new instance.
:Returns:
`CFANetCDFArray`
`CFAH5netcdfArray`
"""
cls = self.get_class("CFANetCDFArray")
return cls(
filename=filename,
address=address,
dtype=dtype,
mask=mask,
units=units,
calendar=calendar,
instructions=instructions,
substitutions=substitutions,
term=term,
x=x,
)
cls = self.get_class("CFAH5netcdfArray")
return cls(**kwargs)


_implementation = CFImplementation(
Expand All @@ -179,7 +156,8 @@ def initialise_CFANetCDFArray(
CellConnectivity=CellConnectivity,
CellMeasure=CellMeasure,
CellMethod=CellMethod,
CFANetCDFArray=CFANetCDFArray,
CFAH5netcdfArray=CFAH5netcdfArray,
CFANetCDF4Array=CFANetCDF4Array,
CoordinateReference=CoordinateReference,
DimensionCoordinate=DimensionCoordinate,
Domain=Domain,
Expand All @@ -202,7 +180,8 @@ def initialise_CFANetCDFArray(
BoundsFromNodesArray=BoundsFromNodesArray,
CellConnectivityArray=CellConnectivityArray,
GatheredArray=GatheredArray,
NetCDFArray=NetCDFArray,
H5netcdfArray=H5netcdfArray,
NetCDF4Array=NetCDF4Array,
PointTopologyArray=PointTopologyArray,
RaggedContiguousArray=RaggedContiguousArray,
RaggedIndexedArray=RaggedIndexedArray,
Expand Down Expand Up @@ -236,7 +215,8 @@ def implementation():
'CellConnectivityArray': cf.data.array.cellconnectivityarray.CellConnectivityArray,
'CellMeasure': cf.cellmeasure.CellMeasure,
'CellMethod': cf.cellmethod.CellMethod,
'CFANetCDFArray': cf.data.array.cfanetcdfarray.CFANetCDFArray,
'CFAH5netcdfArray': cf.data.array.cfah5netcdfarray.CFAH5netcdfArray,
'CFANetCDF4Array': cf.data.array.cfanetcdf4array.CFANetCDF4Array,
'CoordinateReference': cf.coordinatereference.CoordinateReference,
'DimensionCoordinate': cf.dimensioncoordinate.DimensionCoordinate,
'Domain': cf.domain.Domain,
Expand All @@ -257,7 +237,8 @@ def implementation():
'PartNodeCountProperties': cf.partnodecountproperties.PartNodeCountProperties,
'Data': cf.data.data.Data,
'GatheredArray': cf.data.array.gatheredarray.GatheredArray,
'NetCDFArray': cf.data.array.netcdfarray.NetCDFArray,
'H5netcdfArray': cf.data.array.h5netcdfarray.H5netcdfArray,
'NetCDF4Array': cf.data.array.netcdf4array.NetCDF4Array,
'PointTopologyArray': <class 'cf.data.array.pointtopologyarray.PointTopologyArray'>,
'RaggedContiguousArray': cf.data.array.raggedcontiguousarray.RaggedContiguousArray,
'RaggedIndexedArray': cf.data.array.raggedindexedarray.RaggedIndexedArray,
Expand Down
3 changes: 3 additions & 0 deletions cf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
"LOG_LEVEL": logging.getLevelName(logging.getLogger().level),
"BOUNDS_COMBINATION_MODE": "AND",
"CHUNKSIZE": parse_bytes(_CHUNKSIZE),
"active_storage": False,
"active_storage_url": None,
"active_storage_max_requests": 100,
}

masked = np.ma.masked
Expand Down
5 changes: 4 additions & 1 deletion cf/data/array/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from .boundsfromnodesarray import BoundsFromNodesArray
from .cellconnectivityarray import CellConnectivityArray
from .cfanetcdfarray import CFANetCDFArray
from .cfah5netcdfarray import CFAH5netcdfArray
from .cfanetcdf4array import CFANetCDF4Array
from .fullarray import FullArray
from .gatheredarray import GatheredArray
from .h5netcdfarray import H5netcdfArray
from .netcdfarray import NetCDFArray
from .netcdf4array import NetCDF4Array
from .pointtopologyarray import PointTopologyArray
from .raggedcontiguousarray import RaggedContiguousArray
from .raggedindexedarray import RaggedIndexedArray
Expand Down
10 changes: 10 additions & 0 deletions cf/data/array/cfah5netcdfarray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .h5netcdfarray import H5netcdfArray
from .mixin import CFAMixin


class CFAH5netcdfArray(CFAMixin, H5netcdfArray):
"""A CFA-netCDF array accessed with `h5netcdf`
.. versionadded:: NEXTVERSION
"""
10 changes: 10 additions & 0 deletions cf/data/array/cfanetcdf4array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .mixin import CFAMixin
from .netcdf4array import NetCDF4Array


class CFANetCDF4Array(CFAMixin, NetCDF4Array):
"""A CFA-netCDF array accessed with `netCDF4`.
.. versionadded:: NEXTVERSION
"""
Loading

0 comments on commit d99bfd5

Please sign in to comment.