Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregate: unchunk spatial dimension before apply_ufunc #326

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ atlite.egg-info/
doc/.vscode/settings.json
.vscode/settings.json
test/*.nc
dev-scripts/
examples/*.nc
examples/*.csv
examples/*.zip
Expand Down
14 changes: 9 additions & 5 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ Release Notes



.. Upcoming Release
.. ================
Upcoming Release
================

* Fix: the wind turbine power curve is checked for a missing cut-out wind speed and an option to add a
cut-out wind speed at the end of the power curve is introduced. From the next release v0.2.13, adding
a cut-out wind speed will be the default behavior (`GH #316 <https://github.com/PyPSA/atlite/pull/316>`_)
* Compatibility with xarray >= 2023.09.: The chunked spatial dimension in `aggregate` was raising an error with the new xarray version. This is fixed now.
* Bug fix: Some wind turbine models did not include a cut-out wind speed, potentially causing overestimated power generation in windy conditions. Cut-out wind speeds were added to the following affected wind turbine models (`#316 <https://github.com/PyPSA/atlite/issues/314>`_):
* NREL_ReferenceTurbine_2016CACost_10MW_offshore
* NREL_ReferenceTurbine_2016CACost_6MW_offshore
Expand All @@ -21,9 +25,9 @@ Release Notes
* NREL_ReferenceTurbine_2020ATB_12MW_offshore
* NREL_ReferenceTurbine_2020ATB_15MW_offshore
* NREL_ReferenceTurbine_2020ATB_18MW_offshore
.. * Fix: the wind turbine power curve is checked for a missing cut-out wind speed and an option to add a
.. cut-out wind speed at the end of the power curve is introduced. From the next release v0.2.13, adding
.. a cut-out wind speed will be the default behavior (`GH #316 <https://github.com/PyPSA/atlite/pull/316>`_)
* Fix: the wind turbine power curve is checked for a missing cut-out wind speed and an option to add a
cut-out wind speed at the end of the power curve is introduced. From the next release v0.2.13, adding
a cut-out wind speed will be the default behavior (`GH #316 <https://github.com/PyPSA/atlite/pull/316>`_)


Version 0.2.11
Expand Down
1 change: 1 addition & 0 deletions atlite/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def aggregate_matrix(da, matrix, index):
index = index.rename("dim_0")
if isinstance(da.data, dask.array.core.Array):
da = da.stack(spatial=("y", "x"))
da = da.chunk(dict(spatial=-1))
return xr.apply_ufunc(
lambda da: da * matrix.T,
da,
Expand Down
6 changes: 4 additions & 2 deletions atlite/cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def __init__(self, path, **cutoutparams):
# Three cases. First, cutout exists -> take the data.
# Second, data is given -> take it. Third, else -> build a new cutout
if path.is_file():
data = xr.open_dataset(str(path), chunks=chunks)
data = xr.open_dataset(str(path))
data = data.chunk(chunks)
data.attrs.update(storable_chunks)
if cutoutparams:
warn(
Expand Down Expand Up @@ -403,7 +404,8 @@ def grid(self):
span = (coords[self.shape[1] + 1] - coords[0]) / 2
cells = [box(*c) for c in np.hstack((coords - span, coords + span))]
return gpd.GeoDataFrame(
{"x": coords[:, 0], "y": coords[:, 1], "geometry": cells}, crs=self.crs
{"x": coords[:, 0], "y": coords[:, 1], "geometry": cells},
crs=self.crs,
)

def sel(self, path=None, bounds=None, buffer=0, **kwargs):
Expand Down