Skip to content

Commit

Permalink
Add docstring and change func name
Browse files Browse the repository at this point in the history
  • Loading branch information
AUdaltsova authored Aug 30, 2024
1 parent 76008ca commit 2745f7b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ocf_data_sampler/load/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ def make_spatial_coords_increasing(ds: xr.Dataset, x_coord: str, y_coord: str) -
return ds


def underlying_array(ds: xr.Dataset, datavar: str | None = None) -> xr.DataArray:
def get_xr_data_array_from_xr_dataset(ds: xr.Dataset, datavar: str | None = None) -> xr.DataArray:
"""Return underlying xr.DataArray from passed xr.Dataset. If davar provided, returns specified variable.
If datavar not provided, checks only one variable is present and returns it as an xr.DataArray.
Args:
ds: xr.Dataset to extract xr.DataArray from
datavar: (if provided) return specific variable from ds
"""

if datavar:
return ds[datavar]
datavars = list(ds.var())
Expand Down

0 comments on commit 2745f7b

Please sign in to comment.