esmf_regrid.experimental.partition module#

Provides an interface for splitting up a large regridding task.

class esmf_regrid.experimental.partition.Partition(src, tgt, scheme, file_names, use_dask_src_chunks=False, src_chunks=None, num_src_chunks=None, explicit_src_blocks=None, auto_generate=False, saved_files=None)[source]#

Bases: object

Class for breaking down regridding into manageable chunks.

Class for breaking down regridding into manageable chunks.

Parameters:
  • src (cube) – Source cube.

  • tgt (cube) – Target cube.

  • scheme (regridding scheme) – Regridding scheme to generate regridders, either ESMFAreaWeighted or ESMFBilinear.

  • file_names (iterable of str) – A list of file names to save/load parts of the regridder to/from.

  • use_dask_src_chunks (bool, default=False) – If true, partition using the same chunks from the source cube.

  • src_chunks (numpy array, tuple of int or tuple of tuple of int, default=None) – Specify the size of blocks to use to divide up the cube. Dimensions are specified in y,x axis order. If src_chunks is a tuple of int, each integer describes the maximum size of a block in that dimension. If src_chunks is a tuple of tuples, each sub-tuple describes the size of each successive block in that dimension. The sum of these block sizes in each of the sub-tuples should add up to the total size of that dimension or else an error is raised.

  • num_src_chunks (tuple of int) – Specify the number of blocks to use to divide up the cube. Dimensions are specified in y,x axis order. Each integer describes the number of blocks that dimension will be divided into.

  • explicit_src_blocks (arraylike NxMx2) – Explicitly specify the bounds of each block in the partition. Describes N blocks along M dimensions with a pair of upper and lower bounds. The upper and lower bounds describe a slice of an array, e.g. the bounds (3, 6) describe the indices 3, 4, 5 in a particular dimension.

  • auto_generate (bool, default=False) – When true, start generating files on initialisation.

  • saved_files (iterable of str) – A list of paths to previously saved files.

Warning

This class is still experimental. While we aim to maintain backwards compatibility where possible, there is no guarantee that the structure of any generated files will remain consistent and compatible with future versions.

Note

The source is partitioned into blocks using one of the four mutually exclusive arguments, use_dask_src_chunks, src_chunks, num_src_chunks, or explicit_src_blocks. These describe a partition into a number of blocks which must equal the number of file_names.

Currently, it is only possible to divide the source grid into chunks. Meshes are not yet supported as a source.

apply_regridders(cube, allow_incomplete=False)[source]#

Apply the saved regridders to a cube.

Parameters:

allow_incomplete (bool, default=False) – If False, raise an error if not all files have been generated. If True, perform regridding using the files which have been generated.

generate_files(files_to_generate=None)[source]#

Generate files with regridding information.

Parameters:

files_to_generate (int, default=None) – Specify the number of files to generate, default behaviour is to generate all files.

property unsaved_files#

List of files not yet generated.