Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nowcasting_dataset/data_sources/gsp/eso.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def get_gsp_metadata_from_eso(calculate_centroid: bool = True) -> pd.DataFrame:
"https://data.nationalgrideso.com/api/3/action/datastore_search?"
"resource_id=bbe2cc72-a6c6-46e6-8f4e-48b879467368&limit=400"
)
fileobj = urllib.request.urlopen(url)
d = json.loads(fileobj.read())
with urllib.request.urlopen(url) as fileobj:
d = json.loads(fileobj.read())

# make dataframe
results = d["result"]["records"]
Expand Down
38 changes: 24 additions & 14 deletions tests/data_sources/gsp/test_gsp_pvlive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""" Test for PV live data """
from datetime import datetime

import pandas as pd
import pytest
import pytz

from nowcasting_dataset.data_sources.gsp.pvlive import (
Expand All @@ -9,13 +11,14 @@
)


@pytest.mark.skip("Skip due to PVlive server issues: #395")
def test_load_gsp_raw_data_from_pvlive_one_gsp_one_day():
"""
Test that one gsp system data can be loaded, just for one day
"""

start = datetime(2019, 1, 1, tzinfo=pytz.utc)
end = datetime(2019, 1, 2, tzinfo=pytz.utc)
start = datetime(2021, 1, 1, tzinfo=pytz.utc)
end = datetime(2021, 1, 2, tzinfo=pytz.utc)

gsp_pv_df = load_pv_gsp_raw_data_from_pvlive(start=start, end=end, number_of_gsp=1)

Expand All @@ -25,14 +28,15 @@ def test_load_gsp_raw_data_from_pvlive_one_gsp_one_day():
assert "generation_mw" in gsp_pv_df.columns


@pytest.mark.skip("Skip due to PVlive server issues: #395")
def test_load_gsp_raw_data_from_pvlive_one_gsp_one_day_not_normalised():
"""
Test that one gsp system data can be loaded, just for one day, and is normalized correctly
"""

# pick a summer day
start = datetime(2019, 6, 21, tzinfo=pytz.utc)
end = datetime(2019, 6, 22, tzinfo=pytz.utc)
start = datetime(2021, 6, 21, tzinfo=pytz.utc)
end = datetime(2021, 6, 22, tzinfo=pytz.utc)

gsp_pv_df = load_pv_gsp_raw_data_from_pvlive(
start=start, end=end, number_of_gsp=1, normalize_data=False
Expand All @@ -45,13 +49,14 @@ def test_load_gsp_raw_data_from_pvlive_one_gsp_one_day_not_normalised():
assert gsp_pv_df["generation_mw"].max() <= 1


@pytest.mark.skip("Skip due to PVlive server issues: #395")
def test_load_gsp_raw_data_from_pvlive_one_gsp():
"""a
"""
Test that one gsp system data can be loaded
"""

start = datetime(2019, 1, 1, tzinfo=pytz.utc)
end = datetime(2019, 3, 1, tzinfo=pytz.utc)
start = datetime(2021, 1, 1, tzinfo=pytz.utc)
end = datetime(2021, 3, 1, tzinfo=pytz.utc)

gsp_pv_df = load_pv_gsp_raw_data_from_pvlive(start=start, end=end, number_of_gsp=1)

Expand All @@ -62,27 +67,32 @@ def test_load_gsp_raw_data_from_pvlive_one_gsp():
assert "generation_mw" in gsp_pv_df.columns


@pytest.mark.skip("Skip due to PVlive server issues: #395")
def test_load_gsp_raw_data_from_pvlive_many_gsp():
"""
Test that one gsp system data can be loaded
"""

start = datetime(2019, 1, 1, tzinfo=pytz.utc)
end = datetime(2019, 1, 2, tzinfo=pytz.utc)
start = datetime(2021, 1, 1, tzinfo=pytz.utc)
end = datetime(2021, 1, 2, tzinfo=pytz.utc)

gsp_pv_df = load_pv_gsp_raw_data_from_pvlive(start=start, end=end, number_of_gsp=10)
gsp_pv_df = load_pv_gsp_raw_data_from_pvlive(start=start, end=end, number_of_gsp=3)

assert isinstance(gsp_pv_df, pd.DataFrame)
assert len(gsp_pv_df) == (48 + 1) * 10
assert len(gsp_pv_df) == (48 + 1) * 3
assert "datetime_gmt" in gsp_pv_df.columns
assert "generation_mw" in gsp_pv_df.columns


@pytest.mark.skip("Skip due to PVlive server issues: #395")
def test_get_installed_capacity():
"""
Test thhat we can get installed capacity
"""

installed_capacity = get_installed_capacity(maximum_number_of_gsp=10)
installed_capacity = get_installed_capacity(maximum_number_of_gsp=3)

assert len(installed_capacity) == 10
assert len(installed_capacity) == 3
assert "installedcapacity_mwp" == installed_capacity.name
assert installed_capacity.iloc[0] == 342.02623
assert installed_capacity.iloc[9] == 308.00432
assert installed_capacity.iloc[2] == 308.00432