Skip to content

Commit

Permalink
fix channel selection and update tests to catch this
Browse files Browse the repository at this point in the history
  • Loading branch information
dfulu committed Aug 12, 2024
1 parent b781e37 commit b3aa1ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ocf_data_sampler/datasets/pvnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_dataset_dict(config: Configuration) -> dict[xr.DataArray, dict[xr.DataAr

da_sat = open_sat_data(sat_config.satellite_zarr_path)

da_sat.sel(channel=list(sat_config.satellite_channels))
da_sat = da_sat.sel(channel=list(sat_config.satellite_channels))

datasets["sat"] = da_sat

Expand Down
11 changes: 10 additions & 1 deletion tests/dataset/test_pvnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ocf_data_sampler.datasets.pvnet import PVNetDataset
from ocf_datapipes.config.load import load_yaml_configuration
from ocf_datapipes.config.save import save_yaml_configuration
from ocf_datapipes.batch import BatchKey
from ocf_datapipes.batch import BatchKey, NWPBatchKey


@pytest.fixture()
Expand Down Expand Up @@ -37,3 +37,12 @@ def test_pvnet(pvnet_config_filename):
for key in [BatchKey.nwp, BatchKey.satellite_actual, BatchKey.gsp]:
assert key in sample

for nwp_source in ["ukv"]:
assert nwp_source in sample[BatchKey.nwp]

assert sample[BatchKey.satellite_actual].shape == (7, 1, 2, 2)
assert sample[BatchKey.nwp]["ukv"][NWPBatchKey.nwp].shape == (4, 1, 2, 2)
assert sample[BatchKey.gsp].shape == (7,)



6 changes: 3 additions & 3 deletions tests/test_data/pvnet_test_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ input_data:
ukv:
nwp_provider: ukv
nwp_zarr_path: set_in_temp_file
history_minutes: 30
forecast_minutes: 15
history_minutes: 60
forecast_minutes: 120
time_resolution_minutes: 60
nwp_channels:
- t # 2-metre temperature
Expand All @@ -34,7 +34,7 @@ input_data:
history_minutes: 30
forecast_minutes: 0
live_delay_minutes: 0
time_resolution_minutes: 15
time_resolution_minutes: 5
satellite_channels:
- IR_016
satellite_image_size_pixels_height: 2
Expand Down

0 comments on commit b3aa1ab

Please sign in to comment.