imod.prepare.create_partition_labels#
- imod.prepare.create_partition_labels(idomain: DataArray | UgridDataArray, npartitions: int, weights: DataArray | UgridDataArray | None = None) DataArray | UgridDataArray [source]#
Returns a label array: a 2d array with a similar size to the top layer of idomain. Every array element is the partition number to which the column of gridblocks of idomain at that location belong. This is provided to
imod.mf6.Modflow6Simulation.split()
to partition the model.- Parameters:
idomain (GridDataArray) – idomain-like integer array. >0 sets cells to active, 0 sets cells to inactive, <0 sets cells to vertical passthrough.
npartitions (int) – The number of partitions to create.
weights (xarray.DataArray, xugrid.UgridDataArray, optional) – The weights to use for partitioning. The weights should be a 2d array with the same size as the top layer of idomain. The weights are used to determine the size of each partition. The weights should be positive integers. If not provided, active cells (idomain > 0) are summed across layers and passed on as weights. If None, the idomain is used to compute weights.
- Returns:
A label array with the same size as the top layer of idomain, where each element is the partition number to which the column of gridblocks at that location belongs.
- Return type:
xr.DataArray or xugrid.UgridDataArray
Examples
Create partition labels for a simulation:
>>> partition_labels = create_partition_labels(idomain, npartitions=4)
You can provide these labels to the
imod.mf6.Modflow6Simulation.split()
method>>> mf6_splitted = mf6_sim.split(label_array)
You can also provide weights to the partitioning, which will influence the size of each partition. For example, if you want to create a uniform partitioning, you can use:
>>> weights = xr.ones_like(idomain) >>> label_array = create_partition_labels(idomain, n_partitions=4, weights=weights)