Calculate the slope of the terrain surface from an ArcticDEM Dataset.
Parameters:
-
arcticdem_ds
(xarray.Dataset
)
–
The ArcticDEM Dataset containing the 'dem' variable.
Returns:
-
xarray.Dataset
–
xr.Dataset: The input Dataset with the calculated slope added as a new variable 'slope'.
Source code in darts-preprocessing/src/darts_preprocessing/engineering/arcticdem.py
| @stopuhr.funkuhr("Calculating slope", printer=logger.debug)
def calculate_slope(arcticdem_ds: xr.Dataset) -> xr.Dataset:
"""Calculate the slope of the terrain surface from an ArcticDEM Dataset.
Args:
arcticdem_ds (xr.Dataset): The ArcticDEM Dataset containing the 'dem' variable.
Returns:
xr.Dataset: The input Dataset with the calculated slope added as a new variable 'slope'.
"""
slope_deg = slope(arcticdem_ds.dem)
slope_deg.attrs = {
"long_name": "Slope",
"units": "degrees",
"description": "The slope of the terrain surface in degrees.",
"source": "ArcticDEM",
"_FillValue": float("nan"),
}
arcticdem_ds["slope"] = slope_deg.compute()
return arcticdem_ds
|