@@ -5349,9 +5349,9 @@ def healpix_increase_refinement_level(self, refinement_level, quantity):
53495349 [[72.875 72.875 72.875 72.875 73.375 73.375 73.375 73.375]]
53505350
53515351 """
5352- from .data.dask_utils import cf_healpix_increase_refinement_indices
53535352 from .healpix import (
53545353 _healpix_increase_refinement_level,
5354+ _healpix_increase_refinement_level_indices,
53555355 healpix_max_refinement_level,
53565356 )
53575357
@@ -5470,46 +5470,11 @@ def healpix_increase_refinement_level(self, refinement_level, quantity):
54705470 f.del_construct(key)
54715471
54725472 # Create the healpix_index coordinates for the new refinement
5473- # level, and put them into the Field.
5473+ # level
54745474 healpix_index = hp["healpix_index"]
5475-
5476- # Save any cached data elements
5477- data = healpix_index.data
5478- cached = data._get_cached_elements().copy()
5479-
5480- dx = data.to_dask_array(
5481- _force_mask_hardness=False, _force_to_memory=False
5482- )
5483-
5484- # Set the data type to allow for the largest possible HEALPix
5485- # index at the new refinement level
5486- dtype = cfdm.integer_dtype(12 * (4**refinement_level) - 1)
5487- if dx.dtype != dtype:
5488- dx = dx.astype(dtype, copy=False)
5489-
5490- # Each chunk is going to get larger by a factor of 'ncells'
5491- chunks = [(np.array(dx.chunks[0]) * ncells).tolist()]
5492-
5493- dx = dx.map_blocks(
5494- cf_healpix_increase_refinement_indices,
5495- chunks=tuple(chunks),
5496- dtype=dtype,
5497- meta=np.array((), dtype=dtype),
5498- ncells=ncells,
5475+ _healpix_increase_refinement_level_indices(
5476+ healpix_index, ncells, refinement_level
54995477 )
5500-
5501- healpix_index.set_data(dx, copy=False)
5502-
5503- # Set new cached data elements
5504- data = healpix_index.data
5505- if 0 in cached:
5506- x = np.array(cached[0], dtype=dtype) * ncells
5507- data._set_cached_elements({0: x, 1: x + 1})
5508-
5509- if -1 in cached:
5510- x = np.array(cached[-1], dtype=dtype) * ncells + (ncells - 1)
5511- data._set_cached_elements({-1: x})
5512-
55135478 hp_key = f.set_construct(healpix_index, axes=axis, copy=False)
55145479
55155480 # Update the healpix Coordinate Reference
@@ -9221,7 +9186,10 @@ def indices(self, *config, **kwargs):
92219186
92229187 Metadata constructs are selected by conditions specified on
92239188 their data. Indices for subspacing are then automatically
9224- inferred from where the conditions are met.
9189+ inferred from where the conditions are met. If a condition is
9190+ a callable function then if is automateically replaced with
9191+ the result of calling that function with the Field as its only
9192+ argument.
92259193
92269194 The returned tuple of indices may be used to created a
92279195 subspace by indexing the original field construct with them.
@@ -13406,10 +13374,13 @@ def subspace(self):
1340613374
1340713375 **Subspacing by metadata**
1340813376
13409- Subspacing by metadata, signified by the use of round brackets,
13410- selects metadata constructs and specifies conditions on their
13411- data. Indices for subspacing are then automatically inferred from
13412- where the conditions are met.
13377+ Subspacing by metadata, signified by the use of round
13378+ brackets, selects metadata constructs and specifies conditions
13379+ on their data. Indices for subspacing are then automatically
13380+ inferred from where the conditions are met. If a condition is
13381+ a callable function then if is automateically replaced with
13382+ the result of calling that function with the Field as its only
13383+ argument.
1341313384
1341413385 Metadata constructs and the conditions on their data are defined
1341513386 by keyword parameters.
0 commit comments