resqpy.olio.fine_coarse.FineCoarse

class resqpy.olio.fine_coarse.FineCoarse(fine_extent_kji, coarse_extent_kji, within_fine_box=None, within_coarse_box=None)[source]

Bases: object

Class for holding a mapping between fine and coarse grids.

Methods:

__init__(fine_extent_kji, coarse_extent_kji)

Partial initialisation function, call other methods to assign ratios and proportions.

assert_valid()

Checks consistency of everything within the fine coarse mapping; raises assertion error if not valid.

ratio(axis, c0)

Return fine:coarse ratio in given axis and coarse slice.

ratios(c_kji0)

Return find:coarse ratios triplet for coarse cell.

coarse_for_fine()

Returns triplet of numpy int vectors being the axial coarse cell indices for the axial fine cell indices.

coarse_for_fine_kji0(fine_kji0)

Returns the index of the coarse cell which the given fine cell falls within.

coarse_for_fine_axial(axis, f0)

Returns the index, for a single axis, of the coarse cell which the given fine cell falls within.

coarse_for_fine_axial_vector(axis)

Returns a numpy int vector, for a single axis, of the coarse cell index which each fine cell falls within.

fine_base_for_coarse_axial(axis, c0)

Returns the index, for a single axis, of the 'first' fine cell within the coarse cell (lowest fine index).

fine_base_for_coarse(c_kji0)

Returns a 3-tuple being the 'first' (min) k, j, i0 in fine grid for given coarse cell.

fine_box_for_coarse(c_kji0)

Return the min, max for k, j, i0 in fine grid for given coarse cell.

proportion(axis, c0)

Return the axial relative proportions of fine within coarse.

proportions_for_axis(axis)

Return the axial relative proportions as array of floats summing to one for each coarse slice.

interpolation(axis, c0)

Return a float array ready for interpoltion.

proportions(c_kji0)

Return triplet of axial proportions for refinement of coarse cell.

set_constant_ratio(axis)

Set the refinement ratio for axis based on the ratio of the fine to coarse extents.

set_ij_ratios_constant()

Set the refinement ratio for I & J axes based on the ratio of the fine to coarse extents.

set_all_ratios_constant()

Set all refinement ratios constant based on the ratio of the fine to coarse extents.

set_ratio_vector(axis, vector)

Set fine:coarse ratios for axis from numpy int vector of length matching coarse extent.

set_equal_proportions(axis)

Set proportions equal for axis.

set_all_proportions_equal()

Sets proportions equal in all 3 axes.

set_proportions_list_of_vectors(axis, ...)

Sets the proportions for given axis, with one vector for each coarse slice in the axis.

fine_for_coarse_natural_column_index(coarse_col)

Returns the fine equivalent natural (first) column index for coarse natural column index.

fine_for_coarse_natural_pillar_index(coarse_p)

Returns the fine equivalent natural (first) pillar index for coarse natural pillar index.

write_cartref(filename, lgr_name[, mode, ...])

Write Nexus ascii input format CARTREF; within_coarse_box must have been set.


__init__(fine_extent_kji, coarse_extent_kji, within_fine_box=None, within_coarse_box=None)[source]

Partial initialisation function, call other methods to assign ratios and proportions.

Parameters:
  • fine_extent_kji (triple int) – the local extent of the fine grid in k, j, i axes, ie (nk, nj, ni).

  • coarse_extent_kji (triple int) – the local extent of the coarse grid in k, j, i axes.

  • within_fine_box (numpy int array of shape (2, 3), optional) – if present, the subset of a larger fine grid that the mapping refers to; axes are min,max and k,j,i; values are zero based indices; max values are included in box (un-pythonesque); use this in the case of a local grid coarsening

  • within_coarse_box (numpy int array of shape (2, 3), optional) – if present, the subset of a larger coarse grid that the mapping refers to; axes are min,max and k,j,i; values are zero based indices; max values are included in box (un-pythonesque); use this in the case of a local grid refinement; required for write_cartref() method to work

Returns:

newly formed FineCoarse object awaiting determination of ratios and proportions by axes.

Notes

at most one of within_fine_box and within_coarse_box may be passed; this information is not really used internally by the FineCoarse class but is noted in order to support local grid refinement and local grid coarsening applications; after intialisation, set_* methods should be called to establish the mapping

fine_extent_kji

fine extent

coarse_extent_kji

coarse extent

within_fine_box

if not None, a box within an unidentified larger fine grid

within_coarse_box

if not None, a box within an unidentified larger coarse grid

constant_ratios

list for 3 axes kji, each None or int

vector_ratios

list for 3 axes kji, each numpy vector of int or None

equal_proportions

list for 3 axes kji, each boolean defaulting to equal proportions

vector_proportions

list for 3 axes kji, each None or list of numpy vectors of float summing to 1.0

assert_valid()[source]

Checks consistency of everything within the fine coarse mapping; raises assertion error if not valid.

ratio(axis, c0)[source]

Return fine:coarse ratio in given axis and coarse slice.

ratios(c_kji0)[source]

Return find:coarse ratios triplet for coarse cell.

coarse_for_fine()[source]

Returns triplet of numpy int vectors being the axial coarse cell indices for the axial fine cell indices.

coarse_for_fine_kji0(fine_kji0)[source]

Returns the index of the coarse cell which the given fine cell falls within.

coarse_for_fine_axial(axis, f0)[source]

Returns the index, for a single axis, of the coarse cell which the given fine cell falls within.

coarse_for_fine_axial_vector(axis)[source]

Returns a numpy int vector, for a single axis, of the coarse cell index which each fine cell falls within.

fine_base_for_coarse_axial(axis, c0)[source]

Returns the index, for a single axis, of the ‘first’ fine cell within the coarse cell (lowest fine index).

fine_base_for_coarse(c_kji0)[source]

Returns a 3-tuple being the ‘first’ (min) k, j, i0 in fine grid for given coarse cell.

fine_box_for_coarse(c_kji0)[source]

Return the min, max for k, j, i0 in fine grid for given coarse cell.

Returns:

Numpy int array of shape (2, 3) being the min, max for k, j, i0

proportion(axis, c0)[source]

Return the axial relative proportions of fine within coarse.

Returns:

numpy vector of floats, summing to one

proportions_for_axis(axis)[source]

Return the axial relative proportions as array of floats summing to one for each coarse slice.

interpolation(axis, c0)[source]

Return a float array ready for interpoltion.

Returns floats starting at zero and increasing monotonically to less than one.

proportions(c_kji0)[source]

Return triplet of axial proportions for refinement of coarse cell.

set_constant_ratio(axis)[source]

Set the refinement ratio for axis based on the ratio of the fine to coarse extents.

set_ij_ratios_constant()[source]

Set the refinement ratio for I & J axes based on the ratio of the fine to coarse extents.

set_all_ratios_constant()[source]

Set all refinement ratios constant based on the ratio of the fine to coarse extents.

set_ratio_vector(axis, vector)[source]

Set fine:coarse ratios for axis from numpy int vector of length matching coarse extent.

set_equal_proportions(axis)[source]

Set proportions equal for axis.

set_all_proportions_equal()[source]

Sets proportions equal in all 3 axes.

set_proportions_list_of_vectors(axis, list_of_vectors)[source]

Sets the proportions for given axis, with one vector for each coarse slice in the axis.

fine_for_coarse_natural_column_index(coarse_col)[source]

Returns the fine equivalent natural (first) column index for coarse natural column index.

fine_for_coarse_natural_pillar_index(coarse_p)[source]

Returns the fine equivalent natural (first) pillar index for coarse natural pillar index.

write_cartref(filename, lgr_name, mode='a', root_name=None, preceeding_blank_lines=0, trailing_blank_lines=0)[source]

Write Nexus ascii input format CARTREF; within_coarse_box must have been set.