linopy.expressions.LinearExpression.where

linopy.expressions.LinearExpression.where#

LinearExpression.where(cond, other=None, **kwargs)#

Filter variables based on a condition.

This operation call xarray.Dataset.where but sets the default fill value to -1 for variables and ensures preserving the linopy.LinearExpression type.

Parameters:
  • cond (DataArray or callable) – Locations at which to preserve this object’s values. dtype must be bool. If a callable, it must expect this object as its only parameter.

  • other (expression-like, DataArray or scalar, optional) – Data to use in place of values where cond is False. If a DataArray or a scalar is provided, it is only used to fill the missing values of constant values (const). If a DataArray, its coordinates must match this object’s.

  • **kwargs – Keyword arguments passed to xarray.Dataset.where

Returns:

linopy.LinearExpression