Skip to content

Commit ac1f8c2

Browse files
authored
Merge pull request #869 from davidhassell/main
Update CF aggregation keywords
2 parents a06275a + 73161d8 commit ac1f8c2

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

Changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ version NEXTVERSION
33

44
**2025-??-??**
55

6+
* Update CF aggregation keywords
7+
(https://github.com/NCAS-CMS/cf-python/issues/868)
68
* New keyword parameter to `cf.DimensionCoordinate.create_bounds`:
79
``inplace`` (https://github.com/NCAS-CMS/cf-python/issues/855)
810
* Set new minimum version of `dask`: ``2025.5.1``

cf/data/array/aggregatedarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def __new__(cls, *args, **kwargs):
1919
"""
2020
# Override the inherited FragmentFileArray class
2121
instance = super().__new__(cls)
22-
instance._FragmentArray["location"] = FragmentFileArray
22+
instance._FragmentArray["uri"] = FragmentFileArray
2323
return instance

cf/test/create_test_files.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,11 +2229,11 @@ def _make_ugrid_2(filename):
22292229

22302230

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

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

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

22582258
uid = n.createVariable("uid", str, ())
22592259
uid.long_name = "Fragment dataset unique identifiers"
22602260
uid.aggregated_dimensions = "time"
22612261
uid.aggregated_data = (
2262-
"unique_value: fragment_value_uid map: fragment_map_uid"
2262+
"unique_values: fragment_value_uid map: fragment_map_uid"
22632263
)
22642264

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

22822282
# Fragment array variables
2283-
fragment_location = n.createVariable(
2284-
"fragment_location",
2283+
fragment_uris = n.createVariable(
2284+
"fragment_uris",
22852285
str,
22862286
("a_time", "a_level", "a_latitude", "a_longitude"),
22872287
)
2288-
fragment_location[0, 0, 0, 0] = "January-March.nc"
2289-
fragment_location[1, 0, 0, 0] = "April-December.nc"
2288+
fragment_uris[0, 0, 0, 0] = "January-March.nc"
2289+
fragment_uris[1, 0, 0, 0] = "April-December.nc"
22902290

2291-
fragment_variable = n.createVariable("fragment_variable", str, ())
2292-
fragment_variable[...] = "temperature"
2291+
fragment_identifiers = n.createVariable("fragment_identifiers", str, ())
2292+
fragment_identifiers[...] = "temperature"
22932293

22942294
fragment_map = n.createVariable(
22952295
"fragment_map", "i4", ("a_map_j4", "a_map_i2")

cf/test/test_CFA.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def test_CFA_uri_0(self):
130130
)
131131

132132
nc = netCDF4.Dataset(cfa_file, "r")
133-
cfa_location = nc.variables["cfa_location"]
134-
self.assertEqual(cfa_location[...], filename)
133+
fragment_uris = nc.variables["fragment_uris"]
134+
self.assertEqual(fragment_uris[...], filename)
135135
nc.close()
136136

137137
g = cf.read(cfa_file)
@@ -168,8 +168,8 @@ def test_CFA_uri_1(self):
168168
)
169169

170170
nc = netCDF4.Dataset(cfa_file2, "r")
171-
cfa_location = nc.variables["cfa_location"]
172-
self.assertEqual(cfa_location[...], filename)
171+
fragment_uris = nc.variables["fragment_uris"]
172+
self.assertEqual(fragment_uris[...], filename)
173173
nc.close()
174174

175175
def test_CFA_constructs(self):
@@ -271,8 +271,8 @@ def test_CFA_scalar(self):
271271
h = cf.read(cfa_file)[0]
272272
self.assertTrue(h.equals(f))
273273

274-
def test_CFA_value(self):
275-
"""Test the value fragment array variable."""
274+
def test_CFA_unique_value(self):
275+
"""Test the unique value fragment array variable."""
276276
write = True
277277
for aggregation_value_file in (self.aggregation_value, cfa_file):
278278
f = cf.read(aggregation_value_file, cfa_write="all")
@@ -288,7 +288,7 @@ def test_CFA_value(self):
288288
fa.data.nc_get_aggregated_data(),
289289
{
290290
"map": "fragment_map_uid",
291-
"unique_value": "fragment_value_uid",
291+
"unique_values": "fragment_value_uid",
292292
},
293293
)
294294

0 commit comments

Comments
 (0)