Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit d86bec8

Browse files
Merge pull request #331 from openclimatefix/issue/302-assign-pv-row-number
add pv_system_row_number
2 parents 661b9eb + 317c1c4 commit d86bec8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

nowcasting_dataset/data_sources/fake.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def create_gsp_pv_dataset(
239239
data["x_coords"] = x_coords
240240
data["y_coords"] = y_coords
241241

242+
# Add 1000 to the id numbers for the row numbers.
243+
# This is a quick way to make sure row number is different from id,
244+
data["pv_system_row_number"] = data["id"] + 1000
245+
242246
data.__setitem__("data", data.data.clip(min=0))
243247

244248
return data

nowcasting_dataset/data_sources/pv/pv_data_source.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,7 @@ def get_example(
228228

229229
selected_pv_power = selected_pv_power[all_pv_system_ids]
230230

231-
# TODO: Issue #302. pv_system_row_number is assigned to but never used.
232-
# That may indicate a bug?
233-
pv_system_row_number = np.flatnonzero( # noqa: F841
234-
self.pv_metadata.index.isin(all_pv_system_ids)
235-
)
231+
pv_system_row_number = np.flatnonzero(self.pv_metadata.index.isin(all_pv_system_ids))
236232
pv_system_x_coords = self.pv_metadata.location_x[all_pv_system_ids]
237233
pv_system_y_coords = self.pv_metadata.location_y[all_pv_system_ids]
238234

@@ -267,8 +263,16 @@ def get_example(
267263
id_index=range(len(all_pv_system_ids.values)),
268264
),
269265
)
266+
pv_system_row_number = xr.DataArray(
267+
data=pv_system_row_number,
268+
dims=["id_index"],
269+
coords=dict(
270+
id_index=range(len(all_pv_system_ids.values)),
271+
),
272+
)
270273
pv["x_coords"] = x_coords
271274
pv["y_coords"] = y_coords
275+
pv["pv_system_row_number"] = pv_system_row_number
272276

273277
# pad out so that there are always n_pv_systems_per_example, pad with zeros
274278
pad_n = self.n_pv_systems_per_example - len(pv.id_index)

nowcasting_dataset/data_sources/pv/pv_model.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ def model_validation(cls, v):
1616
assert (~isnan(v.data)).all(), "Some pv data values are NaNs"
1717
assert (~isinf(v.data)).all(), "Some pv data values are Infinite"
1818
assert (v.data >= 0).all(), "Some pv data values are below 0"
19+
20+
assert v.time is not None
21+
assert v.x_coords is not None
22+
assert v.y_coords is not None
23+
assert v.pv_system_row_number is not None
24+
25+
assert len(v.pv_system_row_number.shape) == 2
26+
1927
return v

0 commit comments

Comments
 (0)