Skip to content

Commit

Permalink
remove data file, and use temp files instead
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Aug 2, 2024
1 parent f864e37 commit 14dc676
Show file tree
Hide file tree
Showing 150 changed files with 33 additions and 1,118 deletions.
15 changes: 11 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ def sat_zarr_path():
# Transpose to variables, time, y, x (just in case)
ds = ds.transpose("variable", "time", "y_geostationary", "x_geostationary")

# add 100,000 to x_geostationary, this to make sure the fix index is within the satellite image
ds["x_geostationary"] = ds["x_geostationary"] - 200_000

# Add some NaNs
ds["data"].values[:, :, 0, 0] = np.nan

# make sure channel values are strings
ds["variable"] = ds["variable"].astype(str)

# add data attrs area
ds["data"].attrs["area"] = 'msg_seviri_rss_3km:\n description: MSG SEVIRI Rapid Scanning Service area definition with 3 km resolution\n projection:\n proj: geos\n lon_0: 9.5\n h: 35785831\n x_0: 0\n y_0: 0\n a: 6378169\n rf: 295.488065897014\n no_defs: null\n type: crs\n shape:\n height: 298\n width: 615\n area_extent:\n lower_left_xy: [28503.830075263977, 5090183.970808983]\n upper_right_xy: [-1816744.1169023514, 4196063.827395439]\n units: m\n'

# Specifiy chunking
ds = ds.chunk({"time": 10, "variable": -1, "y_geostationary": -1, "x_geostationary": -1})

Expand All @@ -48,10 +57,9 @@ def sat_zarr_path():

@pytest.fixture(scope="session")
def ds_nwp_ukv():
init_times = pd.date_range(start="2022-09-01 00:00", freq="180min", periods=24 * 7)
init_times = pd.date_range(start="2023-01-01 00:00", freq="180min", periods=24 * 7)
steps = pd.timedelta_range("0h", "10h", freq="1h")


# This is much faster:
x = np.linspace(-239_000, 857_000, 100)
y = np.linspace(-183_000, 1225_000, 100)[::-1] # UKV data must run top to bottom
Expand Down Expand Up @@ -92,7 +100,7 @@ def nwp_ukv_zarr_path(ds_nwp_ukv):

@pytest.fixture(scope="session")
def ds_uk_gsp():
times = pd.date_range("2022-09-01 00:00", "2022-09-02 00:00", freq="30min")
times = pd.date_range("2023-01-01 00:00", "2023-01-02 00:00", freq="30min")
gsp_ids = np.arange(0, 318)
capacity = np.ones((len(times), len(gsp_ids)))
generation = np.random.uniform(0, 200, size=(len(times), len(gsp_ids)))
Expand All @@ -102,7 +110,6 @@ def ds_uk_gsp():
("gsp_id", gsp_ids),
)


da_cap = xr.DataArray(
capacity,
coords=coords,
Expand Down
25 changes: 22 additions & 3 deletions tests/dataset/test_pvnet.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
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(config_filename):
# ------------------ basic usage ---------------------
def test_pvnet(pvnet_config_filename):

# Create dataset object
dataset = PVNetDataset(config_filename)
dataset = PVNetDataset(pvnet_config_filename)

# Print number of samples
print(f"Found {len(dataset.valid_t0_times)} possible samples")
Expand Down
1 change: 0 additions & 1 deletion tests/test_data/gsp/test.zarr/.zattrs

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test_data/gsp/test.zarr/.zgroup

This file was deleted.

145 changes: 0 additions & 145 deletions tests/test_data/gsp/test.zarr/.zmetadata

This file was deleted.

22 changes: 0 additions & 22 deletions tests/test_data/gsp/test.zarr/capacity_mwp/.zarray

This file was deleted.

6 changes: 0 additions & 6 deletions tests/test_data/gsp/test.zarr/capacity_mwp/.zattrs

This file was deleted.

Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/0.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/1.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/2.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/3.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/4.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/5.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/6.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/7.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/8.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/capacity_mwp/9.0
Binary file not shown.
20 changes: 0 additions & 20 deletions tests/test_data/gsp/test.zarr/datetime_gmt/.zarray

This file was deleted.

7 changes: 0 additions & 7 deletions tests/test_data/gsp/test.zarr/datetime_gmt/.zattrs

This file was deleted.

Binary file removed tests/test_data/gsp/test.zarr/datetime_gmt/0
Binary file not shown.
22 changes: 0 additions & 22 deletions tests/test_data/gsp/test.zarr/generation_mw/.zarray

This file was deleted.

6 changes: 0 additions & 6 deletions tests/test_data/gsp/test.zarr/generation_mw/.zattrs

This file was deleted.

Binary file removed tests/test_data/gsp/test.zarr/generation_mw/0.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/1.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/2.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/3.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/4.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/5.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/6.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/7.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/8.0
Binary file not shown.
Binary file removed tests/test_data/gsp/test.zarr/generation_mw/9.0
Binary file not shown.
20 changes: 0 additions & 20 deletions tests/test_data/gsp/test.zarr/gsp_id/.zarray

This file was deleted.

5 changes: 0 additions & 5 deletions tests/test_data/gsp/test.zarr/gsp_id/.zattrs

This file was deleted.

Binary file removed tests/test_data/gsp/test.zarr/gsp_id/0
Binary file not shown.
22 changes: 0 additions & 22 deletions tests/test_data/gsp/test.zarr/installedcapacity_mwp/.zarray

This file was deleted.

6 changes: 0 additions & 6 deletions tests/test_data/gsp/test.zarr/installedcapacity_mwp/.zattrs

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion tests/test_data/nwp_data/test.zarr/.zattrs

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test_data/nwp_data/test.zarr/.zgroup

This file was deleted.

Loading

0 comments on commit 14dc676

Please sign in to comment.