Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version NEXTVERSION

**2025-??-??**

* Update CF aggregation keywords
(https://github.com/NCAS-CMS/cf-python/issues/868)
* New keyword parameter to `cf.DimensionCoordinate.create_bounds`:
``inplace`` (https://github.com/NCAS-CMS/cf-python/issues/855)
* Set new minimum version of `dask`: ``2025.5.1``
Expand Down
2 changes: 1 addition & 1 deletion cf/data/array/aggregatedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def __new__(cls, *args, **kwargs):
"""
# Override the inherited FragmentFileArray class
instance = super().__new__(cls)
instance._FragmentArray["location"] = FragmentFileArray
instance._FragmentArray["uri"] = FragmentFileArray
return instance
20 changes: 10 additions & 10 deletions cf/test/create_test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2229,11 +2229,11 @@ def _make_ugrid_2(filename):


def _make_aggregation_value(filename):
"""Create an aggregation variable with a 'value' fragment array."""
"""Create an aggregation variable with 'unique_values'."""
n = netCDF4.Dataset(filename, "w")

n.Conventions = f"CF-{VN}"
n.comment = "A netCDF file with a 'value' aggregation variable."
n.comment = "A netCDF file with a 'unique_values' aggregation variable."

n.createDimension("time", 12)
n.createDimension("level", 1)
Expand All @@ -2253,13 +2253,13 @@ def _make_aggregation_value(filename):
temperature.cell_methods = "time: mean"
temperature.ancillary_variables = "uid"
temperature.aggregated_dimensions = "time level latitude longitude"
temperature.aggregated_data = "location: fragment_location variable: fragment_variable map: fragment_map"
temperature.aggregated_data = "uris: fragment_uris identifiers: fragment_identifiers map: fragment_map"

uid = n.createVariable("uid", str, ())
uid.long_name = "Fragment dataset unique identifiers"
uid.aggregated_dimensions = "time"
uid.aggregated_data = (
"unique_value: fragment_value_uid map: fragment_map_uid"
"unique_values: fragment_value_uid map: fragment_map_uid"
)

time = n.createVariable("time", "f4", ("time",))
Expand All @@ -2280,16 +2280,16 @@ def _make_aggregation_value(filename):
longitude.units = "degrees_east"

# Fragment array variables
fragment_location = n.createVariable(
"fragment_location",
fragment_uris = n.createVariable(
"fragment_uris",
str,
("a_time", "a_level", "a_latitude", "a_longitude"),
)
fragment_location[0, 0, 0, 0] = "January-March.nc"
fragment_location[1, 0, 0, 0] = "April-December.nc"
fragment_uris[0, 0, 0, 0] = "January-March.nc"
fragment_uris[1, 0, 0, 0] = "April-December.nc"

fragment_variable = n.createVariable("fragment_variable", str, ())
fragment_variable[...] = "temperature"
fragment_identifiers = n.createVariable("fragment_identifiers", str, ())
fragment_identifiers[...] = "temperature"

fragment_map = n.createVariable(
"fragment_map", "i4", ("a_map_j4", "a_map_i2")
Expand Down
14 changes: 7 additions & 7 deletions cf/test/test_CFA.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def test_CFA_uri_0(self):
)

nc = netCDF4.Dataset(cfa_file, "r")
cfa_location = nc.variables["cfa_location"]
self.assertEqual(cfa_location[...], filename)
fragment_uris = nc.variables["fragment_uris"]
self.assertEqual(fragment_uris[...], filename)
nc.close()

g = cf.read(cfa_file)
Expand Down Expand Up @@ -168,8 +168,8 @@ def test_CFA_uri_1(self):
)

nc = netCDF4.Dataset(cfa_file2, "r")
cfa_location = nc.variables["cfa_location"]
self.assertEqual(cfa_location[...], filename)
fragment_uris = nc.variables["fragment_uris"]
self.assertEqual(fragment_uris[...], filename)
nc.close()

def test_CFA_constructs(self):
Expand Down Expand Up @@ -271,8 +271,8 @@ def test_CFA_scalar(self):
h = cf.read(cfa_file)[0]
self.assertTrue(h.equals(f))

def test_CFA_value(self):
"""Test the value fragment array variable."""
def test_CFA_unique_value(self):
"""Test the unique value fragment array variable."""
write = True
for aggregation_value_file in (self.aggregation_value, cfa_file):
f = cf.read(aggregation_value_file, cfa_write="all")
Expand All @@ -288,7 +288,7 @@ def test_CFA_value(self):
fa.data.nc_get_aggregated_data(),
{
"map": "fragment_map_uid",
"unique_value": "fragment_value_uid",
"unique_values": "fragment_value_uid",
},
)

Expand Down
Loading