Skip to content

Commit d99bfd5

Browse files
Merge branch 'main' into student-recipes-4
2 parents 87a1932 + b5c40da commit d99bfd5

File tree

93 files changed

+4539
-1507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4539
-1507
lines changed

Changelog.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ version NEXTVERSION
1414
* New keyword parameter to `cf.Field.derivative`:
1515
``ignore_coordinate_units``
1616
(https://github.com/NCAS-CMS/cf-python/issues/807)
17+
* Allow access to netCDF-4 files in S3 object stores
18+
(https://github.com/NCAS-CMS/cf-python/issues/712)
19+
* New class `cf.H5netcdfArray`
20+
* New class `cf.NetCDF4Array`
21+
* New class `cf.CFAH5netcdfArray`
22+
* New class `cf.CFANetCDF4Array`
1723
* Fix bug that sometimes puts an incorrect ``radian-1`` or
1824
``radian-2`` in the returned units of the differential operator
1925
methods and functions
@@ -27,6 +33,12 @@ version NEXTVERSION
2733
* Fix bug where `cf.normalize_slice` doesn't correctly
2834
handle certain cyclic slices
2935
(https://github.com/NCAS-CMS/cf-python/issues/774)
36+
* New dependency: ``h5netcdf>=1.3.0``
37+
* New dependency: ``h5py>=3.10.0``
38+
* New dependency: ``s3fs>=2024.2.0``
39+
* Changed dependency: ``1.11.2.0<=cfdm<1.11.3.0``
40+
* Changed dependency: ``cfunits>=3.3.7``
41+
3042

3143
----
3244

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

156+
----
157+
144158
version 3.15.4
145159
--------------
146160

@@ -279,7 +293,7 @@ version 3.14.1
279293

280294
----
281295

282-
version 3.14.0 (*first Dask release*)
296+
version 3.14.0 (*first Dask version*)
283297
-------------------------------------
284298

285299
**2023-01-31**
@@ -314,7 +328,7 @@ version 3.14.0 (*first Dask release*)
314328

315329
----
316330

317-
version 3.13.1 (*last LAMA release*)
331+
version 3.13.1 (*last LAMA version*)
318332
------------------------------------
319333

320334
**2022-10-17**

cf/__init__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
1414
* read field constructs from netCDF, CDL, PP and UM datasets,
1515
16+
* read field constructs and domain constructs from netCDF, CDL, PP and
17+
UM datasets with a choice of netCDF backends,
18+
19+
* read files from OPeNDAP servers and S3 object stores,
20+
1621
* create new field constructs in memory,
1722
1823
* write and append field constructs to netCDF datasets on disk,
1924
25+
* read, write, and manipulate UGRID mesh topologies,
26+
2027
* read, write, and create coordinates defined by geometry cells,
2128
2229
* read netCDF and CDL datasets containing hierarchical groups,
@@ -74,8 +81,8 @@
7481
"""
7582

7683
__Conventions__ = "CF-1.11"
77-
__date__ = "2024-04-26"
78-
__version__ = "3.16.2"
84+
__date__ = "2024-??-??"
85+
__version__ = "3.17.0"
7986

8087
_requires = (
8188
"numpy",
@@ -199,8 +206,8 @@
199206
)
200207

201208
# Check the version of cfdm
202-
_minimum_vn = "1.11.1.0"
203-
_maximum_vn = "1.11.2.0"
209+
_minimum_vn = "1.11.2.0"
210+
_maximum_vn = "1.11.3.0"
204211
_cfdm_version = Version(cfdm.__version__)
205212
if not Version(_minimum_vn) <= _cfdm_version < Version(_maximum_vn):
206213
raise RuntimeError(
@@ -209,12 +216,6 @@
209216
)
210217

211218
# Check the version of dask
212-
_minimum_vn = "2022.12.1"
213-
if Version(dask.__version__) < Version(_minimum_vn):
214-
raise RuntimeError(
215-
f"Bad dask version: cf requires dask>={_minimum_vn}. "
216-
f"Got {dask.__version__} at {dask.__file__}"
217-
)
218219

219220
# Check the version of Python
220221
_minimum_vn = "3.8.0"
@@ -274,15 +275,19 @@
274275
from .data.array import (
275276
BoundsFromNodesArray,
276277
CellConnectivityArray,
277-
CFANetCDFArray,
278+
CFAH5netcdfArray,
279+
CFANetCDF4Array,
278280
FullArray,
279281
GatheredArray,
282+
H5netcdfArray,
280283
NetCDFArray,
284+
NetCDF4Array,
281285
PointTopologyArray,
282286
RaggedContiguousArray,
283287
RaggedIndexedArray,
284288
RaggedIndexedContiguousArray,
285289
SubsampledArray,
290+
UMArray,
286291
)
287292

288293
from .data.fragment import (

cf/cellmethod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CellMethod(cfdm.CellMethod):
5656
def __new__(cls, *args, **kwargs):
5757
"""This must be overridden in subclasses.
5858
59-
.. versionadded:: (cfdm) 3.7.0
59+
.. versionadded:: 3.7.0
6060
6161
"""
6262
instance = super().__new__(cls)

cf/cfimplementation.py

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
TiePointIndex,
2727
)
2828
from .data import Data
29+
2930
from .data.array import (
3031
BoundsFromNodesArray,
3132
CellConnectivityArray,
32-
CFANetCDFArray,
33+
CFAH5netcdfArray,
34+
CFANetCDF4Array,
3335
GatheredArray,
34-
NetCDFArray,
36+
H5netcdfArray,
37+
NetCDF4Array,
3538
PointTopologyArray,
3639
RaggedContiguousArray,
3740
RaggedIndexedArray,
@@ -112,65 +115,39 @@ def set_construct(self, parent, construct, axes=None, copy=True, **kwargs):
112115
parent, construct, axes=axes, copy=copy, **kwargs
113116
)
114117

115-
def initialise_CFANetCDFArray(
116-
self,
117-
filename=None,
118-
address=None,
119-
dtype=None,
120-
mask=True,
121-
units=False,
122-
calendar=False,
123-
instructions=None,
124-
substitutions=None,
125-
term=None,
126-
x=None,
127-
**kwargs,
128-
):
129-
"""Return a `CFANetCDFArray` instance.
118+
def initialise_CFANetCDF4Array(self, **kwargs):
119+
"""Return a `CFANetCDF4Array` instance.
130120
131121
:Parameters:
132122
133-
filename: `str`
134-
135-
address: (sequence of) `str` or `int`
136-
137-
dytpe: `numpy.dtype`
138-
139-
mask: `bool`, optional
123+
kwargs: optional
124+
Initialisation parameters to pass to the new instance.
140125
141-
units: `str` or `None`, optional
126+
:Returns:
142127
143-
calendar: `str` or `None`, optional
128+
`CFANetCDF4Array`
144129
145-
instructions: `str`, optional
130+
"""
131+
cls = self.get_class("CFANetCDF4Array")
132+
return cls(**kwargs)
146133

147-
substitutions: `dict`, optional
134+
def initialise_CFAH5netcdfArray(self, **kwargs):
135+
"""Return a `CFAH5netcdfArray` instance.
148136
149-
term: `str`, optional
137+
.. versionadded:: NEXTVERSION
150138
151-
x: `dict`, optional
139+
:Parameters:
152140
153141
kwargs: optional
154-
Ignored.
142+
Initialisation parameters to pass to the new instance.
155143
156144
:Returns:
157145
158-
`CFANetCDFArray`
146+
`CFAH5netcdfArray`
159147
160148
"""
161-
cls = self.get_class("CFANetCDFArray")
162-
return cls(
163-
filename=filename,
164-
address=address,
165-
dtype=dtype,
166-
mask=mask,
167-
units=units,
168-
calendar=calendar,
169-
instructions=instructions,
170-
substitutions=substitutions,
171-
term=term,
172-
x=x,
173-
)
149+
cls = self.get_class("CFAH5netcdfArray")
150+
return cls(**kwargs)
174151

175152

176153
_implementation = CFImplementation(
@@ -179,7 +156,8 @@ def initialise_CFANetCDFArray(
179156
CellConnectivity=CellConnectivity,
180157
CellMeasure=CellMeasure,
181158
CellMethod=CellMethod,
182-
CFANetCDFArray=CFANetCDFArray,
159+
CFAH5netcdfArray=CFAH5netcdfArray,
160+
CFANetCDF4Array=CFANetCDF4Array,
183161
CoordinateReference=CoordinateReference,
184162
DimensionCoordinate=DimensionCoordinate,
185163
Domain=Domain,
@@ -202,7 +180,8 @@ def initialise_CFANetCDFArray(
202180
BoundsFromNodesArray=BoundsFromNodesArray,
203181
CellConnectivityArray=CellConnectivityArray,
204182
GatheredArray=GatheredArray,
205-
NetCDFArray=NetCDFArray,
183+
H5netcdfArray=H5netcdfArray,
184+
NetCDF4Array=NetCDF4Array,
206185
PointTopologyArray=PointTopologyArray,
207186
RaggedContiguousArray=RaggedContiguousArray,
208187
RaggedIndexedArray=RaggedIndexedArray,
@@ -236,7 +215,8 @@ def implementation():
236215
'CellConnectivityArray': cf.data.array.cellconnectivityarray.CellConnectivityArray,
237216
'CellMeasure': cf.cellmeasure.CellMeasure,
238217
'CellMethod': cf.cellmethod.CellMethod,
239-
'CFANetCDFArray': cf.data.array.cfanetcdfarray.CFANetCDFArray,
218+
'CFAH5netcdfArray': cf.data.array.cfah5netcdfarray.CFAH5netcdfArray,
219+
'CFANetCDF4Array': cf.data.array.cfanetcdf4array.CFANetCDF4Array,
240220
'CoordinateReference': cf.coordinatereference.CoordinateReference,
241221
'DimensionCoordinate': cf.dimensioncoordinate.DimensionCoordinate,
242222
'Domain': cf.domain.Domain,
@@ -257,7 +237,8 @@ def implementation():
257237
'PartNodeCountProperties': cf.partnodecountproperties.PartNodeCountProperties,
258238
'Data': cf.data.data.Data,
259239
'GatheredArray': cf.data.array.gatheredarray.GatheredArray,
260-
'NetCDFArray': cf.data.array.netcdfarray.NetCDFArray,
240+
'H5netcdfArray': cf.data.array.h5netcdfarray.H5netcdfArray,
241+
'NetCDF4Array': cf.data.array.netcdf4array.NetCDF4Array,
261242
'PointTopologyArray': <class 'cf.data.array.pointtopologyarray.PointTopologyArray'>,
262243
'RaggedContiguousArray': cf.data.array.raggedcontiguousarray.RaggedContiguousArray,
263244
'RaggedIndexedArray': cf.data.array.raggedindexedarray.RaggedIndexedArray,

cf/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
"LOG_LEVEL": logging.getLevelName(logging.getLogger().level),
6464
"BOUNDS_COMBINATION_MODE": "AND",
6565
"CHUNKSIZE": parse_bytes(_CHUNKSIZE),
66+
"active_storage": False,
67+
"active_storage_url": None,
68+
"active_storage_max_requests": 100,
6669
}
6770

6871
masked = np.ma.masked

cf/data/array/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from .boundsfromnodesarray import BoundsFromNodesArray
22
from .cellconnectivityarray import CellConnectivityArray
3-
from .cfanetcdfarray import CFANetCDFArray
3+
from .cfah5netcdfarray import CFAH5netcdfArray
4+
from .cfanetcdf4array import CFANetCDF4Array
45
from .fullarray import FullArray
56
from .gatheredarray import GatheredArray
7+
from .h5netcdfarray import H5netcdfArray
68
from .netcdfarray import NetCDFArray
9+
from .netcdf4array import NetCDF4Array
710
from .pointtopologyarray import PointTopologyArray
811
from .raggedcontiguousarray import RaggedContiguousArray
912
from .raggedindexedarray import RaggedIndexedArray

cf/data/array/cfah5netcdfarray.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .h5netcdfarray import H5netcdfArray
2+
from .mixin import CFAMixin
3+
4+
5+
class CFAH5netcdfArray(CFAMixin, H5netcdfArray):
6+
"""A CFA-netCDF array accessed with `h5netcdf`
7+
8+
.. versionadded:: NEXTVERSION
9+
10+
"""

cf/data/array/cfanetcdf4array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .mixin import CFAMixin
2+
from .netcdf4array import NetCDF4Array
3+
4+
5+
class CFANetCDF4Array(CFAMixin, NetCDF4Array):
6+
"""A CFA-netCDF array accessed with `netCDF4`.
7+
8+
.. versionadded:: NEXTVERSION
9+
10+
"""

0 commit comments

Comments
 (0)