core.grid.grid_antialiasing

Grid antialiasing module

class gridr.core.grid.grid_antialiasing.ComputeAntialiasingFilterStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enum class to represent compute_antialiasing_filter_from_grid status

gridr.core.grid.grid_antialiasing.compute_antialiasing_filter_from_grid(grid_row, grid_col, grid_resolution, filter_nrow, filter_ncol, filter_cutoff_tanh_slope=10.0, filter_cutoff_shift=0.0, win=None, grid_mask=None, grid_mask_valid_value=1, grid_nodata=None)[source]

Create an antialiasing filter adapted to the grid geometric transformation. The filter will be well adapted to regular grid.

Parameters:
  • grid_row (np.ndarray) – A 2D array representing the row coordinates of the target grid, with the same shape as grid_col. The coordinates target row positions in an input array.

  • grid_col (np.ndarray) – A 2D array representing the column coordinates of the target grid, with the same shape as grid_row. The coordinates target column positions in an input array.

  • grid_resolution (Tuple[int, int]) – A tuple specifying the oversampling factor for the grid for rows and columns. The resolution value of 1 represents full resolution, and higher values indicate lower resolution grids.

  • filter_nrow (int) – The output filter number of rows

  • filter_ncol (int) – The output filter number of columns

  • filter_cutoff_tanh_slope (Optional[float], default 10.) – The slope parameter for the hyperbolic tangent function applied to the frequency cutoff, controlling the sharpness of the transition

  • filter_cutoff_shift (float, default = 0.) – The shift parameter for the frequency cutoff, allowing adjustment of the cutoff position in the frequency domain

  • win (Optional[np.ndarray], default None) – A window (or sub-region) of the full resolution grid to limit the resampling to a specific target region. The window is defined as a list of tuples containing the first and last indices for each dimension. If None, the entire grid is processed.

  • grid_mask (Optional[np.ndarray], default None) – An optional integer mask array for the grid. Grid cells corresponding to grid_mask_valid_value are considered valid; all other values indicate invalid cells and will result in nodata_out in the output array. If not provided, the entire grid is considered valid. The grid mask must have the same shape as grid_row and grid_col.

  • grid_mask_valid_value (Optional[int], default 1) – The value in grid_mask that designates a valid grid cell. All values in grid_mask that differ from this will be treated as invalid. This parameter is required if grid_mask is provided.

  • grid_nodata (Optional[float], default None) – The value in grid_row and grid_col to consider as invalid cells. Please note this option is exclusive with grid_mask. The exclusivity is managed within the bound core method.

Returns:

A tuple containing :

  • The computing status

  • The spatial kernel corresponding to the filter as a bi-dimensional numpy array

Return type:

Tuple[ComputeAntialiasingFilterStatus, np.ndarray]