# Depth detection must be done on the selected variables dataset (not the full dataset)
dataset_has_depth = "depth" in selected_variables_dataset.dims
dataframe_has_depth = "DEPTH" in input_points_dataframe.columns and input_points_dataframe["DEPTH"].notna().any()
# Download data for 3D variables
if dataset_has_depth:
if dataframe_has_depth:
depth_points = xr.DataArray(input_points_dataframe["DEPTH"].to_numpy(dtype=float), dims="points")
selection_indexers["depth"] = depth_points
selected_points_dataset = selected_variables_dataset.sel(**selection_indexers, method="nearest")
else:
selected_points_dataset = selected_variables_dataset.isel(depth=0).sel(**selection_indexers, method="nearest")
else:
# Download data for 2D variables
selected_points_dataset = selected_variables_dataset.sel(**selection_indexers, method="nearest")
https://help.marine.copernicus.eu/en/articles/7970637-how-to-download-data-for-multiple-points-from-a-csv
For Copernicus and depth