Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active storage #617

Merged
merged 82 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8f95bb2
dev
davidhassell Nov 16, 2022
815d933
dev
davidhassell Nov 16, 2022
1d8e39b
actify methods with @active_stage decorator
davidhassell Nov 17, 2022
24ec636
tidy
davidhassell Nov 17, 2022
d9c9c7f
refactor
davidhassell Nov 18, 2022
54bef6b
refactor
davidhassell Nov 18, 2022
eddd377
dev
davidhassell Nov 21, 2022
0825c56
dev
davidhassell Nov 22, 2022
033fed9
Merge branch 'lama-to-dask' of github.com:NCAS-CMS/cf-python into das…
davidhassell Dec 8, 2022
5d60f10
Merge branch 'dask-active-storage' of github.com:davidhassell/cf-pyth…
davidhassell Dec 8, 2022
044ccc9
dev
davidhassell Feb 8, 2023
f5d2834
dev
davidhassell Feb 9, 2023
02ce7b7
dev
davidhassell Feb 9, 2023
0d4276f
merge conflicts
davidhassell Feb 10, 2023
7dff9a0
linting
davidhassell Feb 10, 2023
ede2946
dev
davidhassell Feb 10, 2023
a32ced6
dev
davidhassell Feb 10, 2023
b24d521
dev
davidhassell Feb 11, 2023
669f3cd
dev
davidhassell Mar 2, 2023
248b67c
Merge branch 'main' of github.com:NCAS-CMS/cf-python into dask-active…
davidhassell Mar 2, 2023
b2b0c7e
dev
davidhassell Mar 2, 2023
e95a624
dev
davidhassell Mar 2, 2023
f74cf7a
dev
davidhassell Mar 3, 2023
d464a04
dev
davidhassell Mar 3, 2023
8bc3a92
dev
davidhassell Mar 3, 2023
68fb18a
dev
davidhassell Mar 17, 2023
3a5c3a2
dev
davidhassell Mar 17, 2023
bd1a1be
Merge branch 'main' of github.com:NCAS-CMS/cf-python into dask-active…
davidhassell Mar 17, 2023
9fcc737
dev
davidhassell Mar 17, 2023
a4c1267
Merge pull request #616 from davidhassell/dask-active-storage
davidhassell Mar 17, 2023
c2e7eca
move netcdf lock
davidhassell Mar 18, 2023
5ee6886
upstream merge
davidhassell Sep 25, 2023
064de91
dev
davidhassell Sep 25, 2023
1383a1d
Merge branch 'main' of github.com:davidhassell/cf-python into active-…
davidhassell Jan 18, 2024
bfbdb33
Merge branch 'main' of github.com:NCAS-CMS/cf-python into active-stor…
davidhassell Jan 22, 2024
78b7269
dev
davidhassell Jan 22, 2024
39a5a64
dev
davidhassell Jan 25, 2024
37f8b7f
dev
davidhassell Jan 25, 2024
fe429b7
dev
davidhassell Jan 26, 2024
417a297
dev
davidhassell Jan 26, 2024
5ef961c
dev
davidhassell Jan 26, 2024
2abc8c4
dev
davidhassell Jan 28, 2024
589bd16
dev
davidhassell Jan 28, 2024
92fc8e2
dev
davidhassell Jan 30, 2024
d54fc40
dev
davidhassell Feb 1, 2024
80ac2e6
dev
davidhassell Feb 2, 2024
62edeb8
dependency versions
davidhassell Feb 2, 2024
ebb94cc
dev
davidhassell Feb 2, 2024
af7c20a
dev
davidhassell Feb 4, 2024
31b2b64
dev
davidhassell Feb 5, 2024
7b6cabe
dev
davidhassell Feb 6, 2024
a038030
dev
davidhassell Feb 7, 2024
c6e94e7
dev
davidhassell Feb 8, 2024
3b8ae98
dev
davidhassell Feb 9, 2024
1f90a48
dev
davidhassell Feb 12, 2024
866ccca
dev
davidhassell Feb 13, 2024
baee889
dev
davidhassell Feb 13, 2024
8108dd6
dev
davidhassell Feb 13, 2024
28fdf10
dev
davidhassell Feb 14, 2024
4fcb960
dev
davidhassell Feb 14, 2024
96cdc8f
dev
davidhassell Feb 16, 2024
16131f8
dev
davidhassell Mar 4, 2024
1023ad0
dev
davidhassell Mar 4, 2024
4334cff
upstream merge
davidhassell Mar 5, 2024
6eef10a
dev
davidhassell Mar 5, 2024
e829e58
dev
davidhassell Mar 5, 2024
e2c892c
dev
davidhassell Mar 11, 2024
aa8d505
dev
davidhassell Mar 12, 2024
14a4de7
dev
davidhassell Mar 15, 2024
4825684
dev
davidhassell Mar 15, 2024
36f1ecc
dev
davidhassell Mar 15, 2024
df2f23b
dev
davidhassell Mar 15, 2024
d01d427
dev
davidhassell Mar 17, 2024
297f33b
dev
davidhassell Mar 17, 2024
c7a9cb9
dev
davidhassell Mar 17, 2024
d48a7cf
dev
davidhassell Mar 18, 2024
1c73b89
dev
davidhassell Mar 18, 2024
80d533d
dev
davidhassell Mar 18, 2024
4bfa673
dev
davidhassell Mar 19, 2024
82079fd
dev
davidhassell Mar 19, 2024
9e6d4a2
dev
davidhassell Mar 19, 2024
be63ec7
dev
davidhassell Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ version NEXT

**2024-??-??**

* 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`
* Added spherical regridding to discrete sampling geometry destination
grids (https://github.com/NCAS-CMS/cf-python/issues/716)
* Added 3-d spherical regridding to `cf.Field.regrids`, and the option
Expand All @@ -15,6 +21,11 @@ version NEXT
* Fix bug in `cf.read` when reading UM files that caused LBPROC value
131072 (Mean over an ensemble of parallel runs) to be ignored
(https://github.com/NCAS-CMS/cf-python/issues/737)
* 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 @@ -75,6 +86,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 @@ -213,7 +226,11 @@ version 3.14.1

----

<<<<<<< HEAD
version 3.14.0 (*first Dask version*)
=======
version 3.14.0 (*first Dask release*)
>>>>>>> cafeee513aa48788978d65a96d57212d25549a55
-------------------------------------

**2023-01-31**
Expand Down Expand Up @@ -248,7 +265,11 @@ version 3.14.0 (*first Dask release*)

----

<<<<<<< HEAD
version 3.13.1 (*last LAMA version*)
=======
version 3.13.1 (*last LAMA release*)
>>>>>>> cafeee513aa48788978d65a96d57212d25549a55
------------------------------------

**2022-10-17**
Expand Down
23 changes: 17 additions & 6 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__ = "2023-03-01"
__version__ = "3.16.1"
__date__ = "2024-??-??"
__version__ = "3.17.0"

_requires = (
"numpy",
Expand Down Expand Up @@ -191,16 +198,16 @@
)

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

# 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 Down Expand Up @@ -274,15 +281,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
4 changes: 2 additions & 2 deletions cf/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,7 @@ def aggregate(
#
# 0.0012 , 0.019 , 0.55 , 2.1
#
# compared with current method timings of
# compared with new timings of
#
# 0.00035, 0.0012, 0.013, 0.064
# ------------------------------------------------
Expand Down Expand Up @@ -4817,7 +4817,7 @@ def _aggregate_2_fields(

# Ensure that the axis orders are the same in both fields
transpose_axes1 = [dim0_name_map[axis0] for axis0 in data_axes0]
if transpose_axes1 != data_axes1:
if transpose_axes1 != list(data_axes1):
parent1.transpose(transpose_axes1, inplace=True)

construct_type = parent0.construct_type
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
78 changes: 29 additions & 49 deletions cf/cfimplementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
from .data.array import (
BoundsFromNodesArray,
CellConnectivityArray,
CFANetCDFArray,
CFAH5netcdfArray,
CFANetCDF4Array,
GatheredArray,
NetCDFArray,
H5netcdfArray,
NetCDF4Array,
PointTopologyArray,
RaggedContiguousArray,
RaggedIndexedArray,
Expand Down Expand Up @@ -85,65 +87,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 @@ -152,7 +128,8 @@ def initialise_CFANetCDFArray(
CellConnectivity=CellConnectivity,
CellMeasure=CellMeasure,
CellMethod=CellMethod,
CFANetCDFArray=CFANetCDFArray,
CFAH5netcdfArray=CFAH5netcdfArray,
CFANetCDF4Array=CFANetCDF4Array,
CoordinateReference=CoordinateReference,
DimensionCoordinate=DimensionCoordinate,
Domain=Domain,
Expand All @@ -175,7 +152,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 @@ -209,7 +187,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 @@ -230,7 +209,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,
"netcdf_lock": True,
}

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
Loading