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

Commit 10a78a8

Browse files
committed
add tests
1 parent 8c0dedf commit 10a78a8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

nowcasting_dataset/data_sources/sun/sun_data_source.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,16 @@ def get_locations(
127127
def datetime_index(self) -> pd.DatetimeIndex:
128128
"""Get datetimes where elevation >= 10"""
129129

130-
if not self.load_live:
131-
# get the lat and lon from london
132-
latitude = 51
133-
longitude = 0
130+
# get the lat and lon from london
131+
latitude = 51
132+
longitude = 0
134133

134+
if not self.load_live:
135135
datestamps = self.elevation.index
136136
else:
137-
datestamps = pd.date_range(datetime(2019, 1, 1), datetime(2020, 1, 1), frew="5T")
137+
datestamps = pd.date_range(
138+
datetime(2019, 1, 1), datetime(2019, 12, 31, 23, 55), freq="5T"
139+
)
138140

139141
# get elevation for all datetimes
140142
azimuth_elevation = calculate_azimuth_and_elevation_angle(
@@ -152,7 +154,7 @@ def datetime_index(self) -> pd.DatetimeIndex:
152154
f"out of {len(azimuth_elevation)} as elevation is < 10"
153155
)
154156

155-
datetimes = self.elevation[mask].index
157+
datetimes = datestamps[mask]
156158

157159
# Sun data is only for 2019, so to expand on these by
158160
# repeating data from 2014 to 2023

tests/data_sources/sun/test_sun_data_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
def test_init(test_data_folder): # noqa 103
99
zarr_path = test_data_folder + "/sun/test.zarr"
1010

11-
_ = SunDataSource(zarr_path=zarr_path, history_minutes=30, forecast_minutes=60)
11+
sun = SunDataSource(zarr_path=zarr_path, history_minutes=30, forecast_minutes=60)
12+
_ = sun.datetime_index()
1213

1314

1415
def test_get_example(test_data_folder): # noqa 103
@@ -50,6 +51,7 @@ def test_get_load_live(): # noqa 103
5051
sun_data_source = SunDataSource(
5152
zarr_path="", history_minutes=30, forecast_minutes=60, load_live=True
5253
)
54+
_ = sun_data_source.datetime_index()
5355

5456
x = 256895.63164759654
5557
y = 666180.3018829626

0 commit comments

Comments
 (0)