Skip to content

Commit c96283c

Browse files
committed
Docstring/comments
1 parent 7cd2d44 commit c96283c

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

src/muse/utilities.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ def broadcast_techs(
183183
technologies: xr.Dataset | xr.DataArray,
184184
template: xr.DataArray | xr.Dataset,
185185
dimension: str = "asset",
186-
interpolation: str = "linear",
187-
installed_as_year: bool = True,
188-
**kwargs,
189186
) -> xr.Dataset | xr.DataArray:
190187
"""Broadcasts technologies to the shape of template in given dimension.
191188
@@ -209,30 +206,23 @@ def broadcast_techs(
209206
template: the dataset or data-array to use as a template
210207
dimension: the name of the dimensiom from `template` over which to
211208
broadcast
212-
interpolation: interpolation method used across `year`
213-
installed_as_year: if the coordinate `installed` exists, then it is
214-
applied to the `year` dimension of the technologies dataset
215209
kwargs: further arguments are used initial filters over the
216210
`technologies` dataset.
217211
"""
218212
assert "year" not in technologies.dims
219-
220-
# this assert will trigger if 'year' is changed to 'installed' in
221-
# technologies, because then this function should be modified.
222213
assert "installed" not in technologies.dims
214+
215+
# Attributes of `dimension` (e.g. "technology", "region", "installed")
223216
names = [u for u in template.coords if template[u].dims == (dimension,)]
224-
# the first selection reduces the size of technologies without affecting the
225-
# dimensions.
217+
218+
# Select technologies only present in the template
226219
first_sel = {
227-
n: technologies[n].isin(template[n])
228-
for n in names
229-
if n in technologies.dims and n != "year"
220+
n: technologies[n].isin(template[n]) for n in names if n in technologies.dims
230221
}
231-
first_sel.update({k: v for k, v in kwargs.items() if k != "year"})
232222
techs = technologies.sel(first_sel)
233223

224+
# Restructure the technology dataset to match the template
234225
second_sel = {n: template[n] for n in template.coords if n in techs.dims}
235-
236226
return techs.sel(second_sel)
237227

238228

@@ -313,7 +303,7 @@ def filter_with_template(
313303
`data` transformed to match the form of `template`
314304
"""
315305
if asset_dimension in template.dims:
316-
return broadcast_techs(data, template, dimension=asset_dimension, **kwargs)
306+
return broadcast_techs(data, template, dimension=asset_dimension)
317307

318308
match_indices = set(data.dims).intersection(template.dims) - set(kwargs)
319309
match = {d: template[d].isin(data[d]).values for d in match_indices if d != "year"}

0 commit comments

Comments
 (0)