nearest_neighbor
Classes:
| Name | Description |
|---|---|
NearestNeighbor |
Saves data into the specified coordinate grid using nearest neighbor. |
Classes#
NearestNeighbor #
Bases: DataConverter
Saves data into the specified coordinate grid using nearest neighbor.
This converter is used to reindex a variable onto a new coordinate grid using the
nearest neighbor method. It is particularly useful for aligning datasets with
different time coordinates or other coordinate variables.
The coordinate axis this converter should be applied on can be specified using the
coord parameter. The default is 'time', but it can be set to any coordinate
variable present in the dataset.
The converter will preserve the original variable's data, and if requested, it will
also keep the quality control (QC) checks and transformation metrics as new data
variables in the output dataset.
Attributes:
coord (str): The coordinate axis this converter should be applied on. Defaults to 'time'.
keep_metrics (bool): If true, then transform metrics will be preserved in the output dataset.
keep_qc (bool): If true, then transform qc checks will be preserved in the output dataset.
Methods:
| Name | Description |
|---|---|
convert |
Convert the provided data using the nearest neighbor method. |
Attributes:
| Name | Type | Description |
|---|---|---|
coord |
str
|
The coordinate axis this converter should be applied on. Defaults to 'time'. |
keep_metrics |
bool
|
If true, then transform metrics will be preserved in the output dataset as data |
keep_qc |
bool
|
If true, then transform qc checks will be preserved in the output dataset as a |
Attributes#
coord
class-attribute
instance-attribute
#
The coordinate axis this converter should be applied on. Defaults to 'time'.
keep_metrics
class-attribute
instance-attribute
#
If true, then transform metrics will be preserved in the output dataset as data
variables ('
keep_qc
class-attribute
instance-attribute
#
If true, then transform qc checks will be preserved in the output dataset as a
new data variable ('qc_
Functions#
convert #
convert(
data: DataArray,
variable_name: str,
dataset_config: DatasetConfig,
retrieved_dataset: RetrievedDataset,
retriever: Optional[StorageRetriever] = None,
input_dataset: Optional[Dataset] = None,
input_key: Optional[str] = None,
**kwargs: Any
) -> Optional[xr.DataArray]
Convert the provided data using the nearest neighbor method. Args: data (xr.DataArray): The data array to be transformed. variable_name (str): The name of the variable being transformed. dataset_config (DatasetConfig): The dataset configuration object. retrieved_dataset (RetrievedDataset): The dataset containing retrieved variables. retriever (Optional[StorageRetriever]): The storage retriever object, if available. input_dataset (Optional[xr.Dataset]): The input dataset to pull variables from. input_key (Optional[str]): The key for the input dataset, if applicable. Returns: Optional[xr.DataArray]: The transformed data array, or None if the variable cannot be transformed.
Source code in tsdat/transform_v2/converters/nearest_neighbor.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |