tsdat.qc.base

Classes

QualityChecker

Base class for code that checks the dataset / data variable quality.

QualityHandler

Base class for code that handles the dataset / data variable quality.

QualityManagement

Main class for orchestrating the dispatch of QualityCheckers and QualityHandlers.

QualityManager

Groups a QualityChecker and one or more QualityHandlers together.

class tsdat.qc.base.QualityChecker[source]

Bases: tsdat.utils.ParameterizedClass, abc.ABC

Base class for code that checks the dataset / data variable quality.

Class Methods

run

Identifies and flags quality problems with the data.

Method Descriptions

abstract run(self, dataset: xarray.Dataset, variable_name: str) numpy.typing.NDArray[numpy.bool8][source]

Identifies and flags quality problems with the data.

Checks the quality of a specific variable in the dataset and returns the results of the check as a boolean array where True values represent quality problems and False values represent data that passes the quality check.

QualityCheckers should not modify dataset variables; changes to the dataset should be made by QualityHandler(s), which receive the results of a QualityChecker as input.

Parameters
  • dataset (xr.Dataset) – The dataset containing the variable to check.

  • variable_name (str) – The name of the variable to check.

Returns

NDArray[np.bool8] – The results of the quality check, where True values indicate a quality problem.

class tsdat.qc.base.QualityHandler[source]

Bases: tsdat.utils.ParameterizedClass, abc.ABC

Base class for code that handles the dataset / data variable quality.

Class Methods

run

Takes some action on data that has had quality issues identified.

Method Descriptions

abstract run(self, dataset: xarray.Dataset, variable_name: str, failures: numpy.typing.NDArray[numpy.bool8]) xarray.Dataset[source]

Takes some action on data that has had quality issues identified.

Handles the quality of a variable in the dataset and returns the dataset after any corrections have been applied.

Parameters
  • dataset (xr.Dataset) – The dataset containing the variable to handle.

  • variable_name (str) – The name of the variable whose quality should be handled.

  • failures (NDArray[np.bool8]) – The results of the QualityChecker for the provided variable, where True values indicate a quality problem.

Returns

xr.Dataset – The dataset after the QualityHandler has been run.

class tsdat.qc.base.QualityManagement[source]

Bases: pydantic.BaseModel

Main class for orchestrating the dispatch of QualityCheckers and QualityHandlers.

Parameters

managers (List[QualityManager]) – The list of QualityManagers that should be run.

managers :List[QualityManager][source]

Class Methods

manage

Runs the registered QualityManagers on the dataset.

Method Descriptions

manage(self, dataset: xarray.Dataset) xarray.Dataset[source]

Runs the registered QualityManagers on the dataset.

Parameters

dataset (xr.Dataset) – The dataset to apply quality checks and controls to.

Returns

xr.Dataset – The quality-checked dataset.

class tsdat.qc.base.QualityManager[source]

Bases: pydantic.BaseModel

Groups a QualityChecker and one or more QualityHandlers together.

Parameters
  • name (str) – The name of the quality manager.

  • checker (QualityChecker) – The quality check that should be run.

  • handlers (QualityHandler) – One or more QualityHandlers that should be run given the results of the checker.

  • apply_to (List[str]) – A list of variables that the check should run for. Accepts keywords of ‘COORDS’ or ‘DATA_VARS’, or any number of specific variables that should be run.

  • exclude (List[str]) – A list of variables that the check should exclude. Accepts the same keywords as apply_to.

apply_to :List[str][source]
checker :QualityChecker[source]
exclude :List[str] = [][source]
handlers :List[QualityHandler][source]
name :str[source]

Class Methods

run

Runs the quality manager on the dataset.

Method Descriptions

run(self, dataset: xarray.Dataset) xarray.Dataset[source]

Runs the quality manager on the dataset.

Parameters

dataset (xr.Dataset) – The dataset to apply quality checks / controls to.

Returns

xr.Dataset – The dataset after the quality check and controls have been applied.