xarray_compare package

Submodules

xarray_compare.compare module

xarray_compare.compare.isbetween(dataarray: xarray.core.dataarray.DataArray, lower: Any, upper: Any, interval: str = '[]') → xarray.core.dataarray.DataArray[source]

Test whether each value in a DataArray falls within an interval.

An interval is defined by lower, upper, and interval. For example, if interval is given as '[)', the interval of [lower, upper) will be used for the evaluation. Then the function returns (dataarray >= lower) & (dataarray < upper).

Parameters
  • dataarray – DataArray to be compared.

  • lower – Lower endpoint of the interval. If None is given, then the lower end is not evaluated.

  • upper – Upper endpoint of the interval. If None is given, then the upper end is not evaluated.

  • interval – String which determine the type of the interval. Either '[]' (closed; default), '[)' (L-closed, R-open), '(]' (L-open, R-closed), or '()' (open) is accepted.

Returns

Boolean DataArray each value of which is True where it falls within the interval and False otherwise.

Raises

ValueError – Raised if interval is not correct.

xarray_compare.compare.isin(dataarray: xarray.core.dataarray.DataArray, values: Any) → xarray.core.dataarray.DataArray[source]

Equivalent to dataarray.isin().

Parameters
  • dataarray – DataArray to be compared.

  • values – Scalar value or sequence of values.

Returns

Boolean DataArray each value of which is True where it is equivalent to values or in values and False otherwise.

xarray_compare.compare.ismatch(dataarray: xarray.core.dataarray.DataArray, pattern: Union[Pattern, str], flags: re.RegexFlag = 0) → xarray.core.dataarray.DataArray[source]

Test whether each string in a DataArray matches a regex pattern.

Parameters
  • dataarray – String DataArray to be compared.

  • pattern – String or compiled regex pattern.

  • flags – Regex flags to control the matching behavior.

Returns

Boolean DataArray each value of which is True where it matches the pattern and False otherwise.

Raises

TypeError – Raised if dataarray.dtype is not string-like.

xarray_compare.compare.isnotbetween(dataarray: xarray.core.dataarray.DataArray, lower: Any, upper: Any, interval: str = '[]') → xarray.core.dataarray.DataArray[source]

Equivalent to ~isbetween().

Parameters
  • dataarray – DataArray to be compared.

  • lower – Lower endpoint of the interval. If None is given, then the lower end is not evaluated.

  • upper – Upper endpoint of the interval. If None is given, then the upper end is not evaluated.

  • interval – String which determine the type of the interval. Either '[]' (closed; default), '[)' (L-closed, R-open), '(]' (L-open, R-closed), or '()' (open) is accepted.

Returns

Boolean DataArray each value of which is True where it does not fall within the interval and True otherwise.

Raises

ValueError – Raised if interval is not correct.

xarray_compare.compare.isnotin(dataarray: xarray.core.dataarray.DataArray, values: Any) → xarray.core.dataarray.DataArray[source]

Equivalent to ~isin().

Parameters
  • dataarray – DataArray to be compared.

  • values – Scalar value or sequence of values.

Returns

Boolean DataArray each value of which is True where it is not equivalent to values or not in values and False otherwise.

xarray_compare.compare.isnotmatch(dataarray: xarray.core.dataarray.DataArray, pattern: Union[Pattern, str], flags: re.RegexFlag = 0) → xarray.core.dataarray.DataArray[source]

Equivalent to ~ismatch().

Parameters
  • dataarray – String DataArray to be compared.

  • pattern – String or compiled regex pattern.

  • flags – Regex flags to control the matching behavior.

Returns

Boolean DataArray each value of which is True where it does not match the pattern and False otherwise.

Raises

TypeError – Raised if dataarray.dtype is not string-like.

xarray_compare.utils module

xarray_compare.utils.dataarray_method(func: Callable) → Callable[source]

Decorator to make a DataArray function available as a method.

Module contents