xarray_regrid.methods.flox_reduce ================================= .. py:module:: xarray_regrid.methods.flox_reduce .. autoapi-nested-parse:: Implementation of flox reduction based regridding methods. Functions --------- .. autoapisummary:: xarray_regrid.methods.flox_reduce.statistic_reduce xarray_regrid.methods.flox_reduce.find_matching_int_dtype xarray_regrid.methods.flox_reduce.compute_mode Module Contents --------------- .. py:function:: statistic_reduce(data: xarray.DataArray, target_ds: xarray.Dataset, time_dim: str | None, method: str, skipna: bool = False, fill_value: None | Any = None) -> xarray.DataArray statistic_reduce(data: xarray.Dataset, target_ds: xarray.Dataset, time_dim: str | None, method: str, skipna: bool = False, fill_value: None | Any = None) -> xarray.Dataset Upsampling of data using statistical methods (e.g. the mean or variance). We use flox Aggregations to perform a "groupby" over multiple dimensions, which we reduce using the specified method. https://flox.readthedocs.io/en/latest/aggregations.html :param data: Input dataset. It is assumed that the coordinates of this data are sorted. :param target_ds: Dataset which coordinates the input dataset should be regrid to. :param time_dim: Name of the time dimension. Defaults to "time". Use `None` to force regridding over the time dimension. :param method: One of the following reduction methods: "sum", "mean", "var", "std", or "median. :param skipna: If NaN values should be ignored. :param fill_value: What value to fill uncovered parts of the target grid. By default this will be NaN, and integer type data will be cast to float to accomodate this. :returns: xarray.dataset with regridded land cover categorical data. .. py:function:: find_matching_int_dtype(a: numpy.ndarray) -> type[numpy.signedinteger] | type[numpy.unsignedinteger] Find the smallest integer datatype that can cover the given array. .. py:function:: compute_mode(data: xarray.DataArray, target_ds: xarray.Dataset, values: numpy.ndarray, time_dim: str | None, fill_value: None | Any = None, anti_mode: bool = False) -> xarray.DataArray Upsample the input data using a "most common label" (mode) approach. :param data: Input DataArray, with an integer data type. If your data does not consist of integer type values, you will have to encode them to integer types. It is assumed that the coordinates of this data are sorted. :param target_ds: Dataset which coordinates the input dataset should be regrid to. :param values: Numpy array containing all labels expected to be in the input data. For example, `np.array([0, 2, 4])`, if the data only contains the values 0, 2 and 4. :param time_dim: Name of the time dimension. Defaults to "time". Use `None` to force regridding over the time dimension. :param fill_value: What value to fill uncovered parts of the target grid. By default this will be NaN, and integer type data will be cast to float to accomodate this. :param anti_mode: Find the least-common-value (anti-mode). :raises ValueError: if the input data is not of an integer dtype. :returns: xarray.DataArray with regridded categorical data.