generated from openclimatefix/ocf-template
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from openclimatefix/pvnet_test
add test for dataset.pvnet
- Loading branch information
Showing
5 changed files
with
110 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
import tempfile | ||
|
||
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 | ||
|
||
|
||
@pytest.fixture() | ||
def pvnet_config_filename(config_filename, nwp_ukv_zarr_path, uk_gsp_zarr_path, sat_zarr_path): | ||
|
||
# adjust config to point to the zarr file | ||
config = load_yaml_configuration(config_filename) | ||
config.input_data.nwp['ukv'].nwp_zarr_path = nwp_ukv_zarr_path | ||
config.input_data.satellite.satellite_zarr_path = sat_zarr_path | ||
config.input_data.gsp.gsp_zarr_path = uk_gsp_zarr_path | ||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
filename = f"{tmpdir}/configuration.yaml" | ||
save_yaml_configuration(config, filename) | ||
yield filename | ||
|
||
|
||
def test_pvnet(pvnet_config_filename): | ||
|
||
# Create dataset object | ||
dataset = PVNetDataset(pvnet_config_filename) | ||
|
||
# Print number of samples | ||
print(f"Found {len(dataset.valid_t0_times)} possible samples") | ||
|
||
idx = 0 | ||
t_index, loc_index = dataset.index_pairs[idx] | ||
|
||
location = dataset.locations[loc_index] | ||
t0 = dataset.valid_t0_times[t_index] | ||
|
||
# Print coords | ||
print(t0) | ||
print(location) | ||
|
||
# Generate sample - no printing since its BIG | ||
_ = dataset[idx] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
general: | ||
description: Test config for PVNet | ||
name: pvnet_test | ||
|
||
input_data: | ||
default_history_minutes: 60 | ||
default_forecast_minutes: 120 | ||
|
||
gsp: | ||
gsp_zarr_path: set_in_temp_file | ||
history_minutes: 60 | ||
forecast_minutes: 120 | ||
time_resolution_minutes: 30 | ||
dropout_timedeltas_minutes: null | ||
dropout_fraction: 0 | ||
|
||
nwp: | ||
ukv: | ||
nwp_provider: ukv | ||
nwp_zarr_path: set_in_temp_file | ||
history_minutes: 30 | ||
forecast_minutes: 15 | ||
time_resolution_minutes: 60 | ||
nwp_channels: | ||
- t # 2-metre temperature | ||
nwp_image_size_pixels_height: 2 | ||
nwp_image_size_pixels_width: 2 | ||
dropout_timedeltas_minutes: [-180] | ||
dropout_fraction: 1.0 | ||
max_staleness_minutes: null | ||
|
||
satellite: | ||
satellite_zarr_path: set_in_temp_file | ||
history_minutes: 30 | ||
forecast_minutes: 0 | ||
live_delay_minutes: 0 | ||
time_resolution_minutes: 15 | ||
satellite_channels: | ||
- IR_016 | ||
satellite_image_size_pixels_height: 2 | ||
satellite_image_size_pixels_width: 2 | ||
dropout_timedeltas_minutes: null | ||
dropout_fraction: 0 |