Wakatools accessors#
Wakatools extends Pandas
and Xarray
with the waka accessor for common DataFrame and raster operations associated with
interpolation. The waka accessor is activated by importing wakatools like so:
import wakatools
DataFrameAccessor#
Once wakatools is imported you can access the waka accessor on any Pandas DataFrame.
import pandas as pd
# create a DataFrame with x and y coordinates
df = pd.DataFrame({"y": [1.2, 2.3, 3.4], "x": [0.8, 1.9, 2.0]})
bounding_box = df.waka.bounds() # get the bounding box from the coordinates
print(bounding_box)
# Output:
# (0.8, 1.2, 2.0, 3.4)
|
Waka DataFrame accessor .waka for pandas.DataFrame instances holding wakatools functionalities for DataFrames. |
Get the bounding box from the coordinates of the DataFrame as xmin, ymin, xmax, ymax. |
|
|
Calculate residuals between the values in the DataFrame and the raster values at the DataFrame coordinates. |
Get an array of all coordinates in the DataFrame in the shape (N, 2). |
|
Get an array of all coordinates in the DataFrame in the shape (N, 2), scaled to between 0 and 1 based on the bounding box of the DataFrame (xmin, ymin, xmax, ymax) or on a specified bounding box. |
|
Read raster values from a given xarray DataArray nearest to the "x" and "y" coordinates in the DataFrame. |
DataArrayAccessor#
Once wakatools is imported you can access the waka accessor on any xarray DataArray.
This accessor provides useful methods for working with gridded data, for instances to get
all grid_coordinates of arrays as input for interpolation. Like so:
import xarray as xr
da = xr.DataArray(
[[1, 2], [3, 4]], coords={"y": [1, 0], "x": [0, 1]}, dims=("y", "x")
)
coords = da.waka.grid_coordinates()
print(coords)
# Output:
# array([[0, 1],
# [1, 1],
# [0, 0],
# [1, 0]])
|
Waka DataArray accessor .waka for xarray.DataArray instances holding wakatools functionalities for DataArrays. |
Get an array of all grid coordinates in the DataArray in the shape (N, 2). |
|
Get an array of all grid coordinates in the DataArray in the shape (N, 2), scaled to between 0 and 1 based on the bounding box of the grid (xmin, ymin, xmax, ymax) or on a specified bounding box. |