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

Commit 249dcc5

Browse files
committed
Merge branch 'main' into issue/torch-channels
# Conflicts: # nowcasting_dataset/data_sources/fake.py
2 parents 2dbdb7b + d823b3e commit 249dcc5

File tree

14 files changed

+3
-221
lines changed

14 files changed

+3
-221
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
commit = True
33
tag = True
4-
current_version = 2.0.0
4+
current_version = 2.0.2
55

66
[bumpversion:file:setup.py]
77
search = version="{current_version}"

nowcasting_dataset/data_sources/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
""" Various DataSources """
22
from nowcasting_dataset.data_sources.data_source import DataSource # noqa: F401
3-
from nowcasting_dataset.data_sources.datetime.datetime_data_source import ( # noqa: F401
4-
DatetimeDataSource,
5-
)
63
from nowcasting_dataset.data_sources.gsp.gsp_data_source import GSPDataSource
74
from nowcasting_dataset.data_sources.nwp.nwp_data_source import NWPDataSource
85
from nowcasting_dataset.data_sources.pv.pv_data_source import PVDataSource

nowcasting_dataset/data_sources/datetime/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

nowcasting_dataset/data_sources/datetime/datetime_data_source.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

nowcasting_dataset/data_sources/datetime/datetime_model.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

nowcasting_dataset/data_sources/fake.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import xarray as xr
88

99
from nowcasting_dataset.consts import NWP_VARIABLE_NAMES, SAT_VARIABLE_NAMES
10-
from nowcasting_dataset.data_sources.datetime.datetime_model import Datetime
1110
from nowcasting_dataset.data_sources.gsp.gsp_model import GSP
1211
from nowcasting_dataset.data_sources.metadata.metadata_model import Metadata
1312
from nowcasting_dataset.data_sources.nwp.nwp_model import NWP
@@ -22,16 +21,6 @@
2221
)
2322

2423

25-
def datetime_fake(batch_size, seq_length_5):
26-
""" Create fake data """
27-
xr_arrays = [create_datetime_dataset(seq_length=seq_length_5) for _ in range(batch_size)]
28-
29-
# make dataset
30-
xr_dataset = join_list_dataset_to_batch_dataset(xr_arrays)
31-
32-
return Datetime(xr_dataset)
33-
34-
3524
def gsp_fake(
3625
batch_size,
3726
seq_length_30,

nowcasting_dataset/dataset/batch.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from pydantic import BaseModel, Field
1212

1313
from nowcasting_dataset.config.model import Configuration
14-
from nowcasting_dataset.data_sources.datetime.datetime_model import Datetime
1514
from nowcasting_dataset.data_sources.fake import (
16-
datetime_fake,
1715
gsp_fake,
1816
metadata_fake,
1917
nwp_fake,
@@ -33,7 +31,7 @@
3331

3432
_LOG = logging.getLogger(__name__)
3533

36-
data_sources = [Metadata, Satellite, Topographic, PV, Sun, GSP, NWP, Datetime]
34+
data_sources = [Metadata, Satellite, Topographic, PV, Sun, GSP, NWP]
3735

3836

3937
class Batch(BaseModel):
@@ -62,7 +60,6 @@ class Batch(BaseModel):
6260
sun: Optional[Sun]
6361
gsp: Optional[GSP]
6462
nwp: Optional[NWP]
65-
datetime: Optional[Datetime]
6663

6764
@property
6865
def data_sources(self):
@@ -74,7 +71,6 @@ def data_sources(self):
7471
self.sun,
7572
self.gsp,
7673
self.nwp,
77-
self.datetime,
7874
self.metadata,
7975
]
8076

@@ -119,10 +115,6 @@ def fake(configuration: Configuration):
119115
topographic=topographic_fake(
120116
batch_size=batch_size, image_size_pixels=satellite_image_size_pixels
121117
),
122-
datetime=datetime_fake(
123-
batch_size=batch_size,
124-
seq_length_5=configuration.input_data.default_seq_length_5_minutes,
125-
),
126118
)
127119

128120
def save_netcdf(self, batch_i: int, path: Path):
@@ -194,7 +186,6 @@ class Example(BaseModel):
194186
sun: Optional[Sun]
195187
gsp: Optional[GSP]
196188
nwp: Optional[NWP]
197-
datetime: Optional[Datetime]
198189

199190
@property
200191
def data_sources(self):
@@ -206,6 +197,5 @@ def data_sources(self):
206197
self.sun,
207198
self.gsp,
208199
self.nwp,
209-
self.datetime,
210200
self.metadata,
211201
]

nowcasting_dataset/time.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import numpy as np
88
import pandas as pd
99
import pvlib
10-
import xarray as xr
1110

1211
from nowcasting_dataset import geospatial, utils
1312

@@ -211,44 +210,6 @@ def get_contiguous_time_periods(
211210
return pd.DataFrame(periods)
212211

213212

214-
# TODO: Delete this function and tests.
215-
# https://github.com/openclimatefix/nowcasting_dataset/issues/208
216-
def datetime_features(index: pd.DatetimeIndex) -> pd.DataFrame:
217-
"""
218-
Make datetime features, hour_of_day and day_of_year
219-
220-
Args:
221-
index: index of datestamps
222-
223-
Returns: Example data with datetime features
224-
225-
"""
226-
features = {}
227-
features["hour_of_day"] = index.hour + (index.minute / 60)
228-
features["day_of_year"] = index.day_of_year
229-
return pd.DataFrame(features, index=index).astype(np.float32)
230-
231-
232-
# TODO: Delete this function and tests.
233-
# https://github.com/openclimatefix/nowcasting_dataset/issues/208
234-
def datetime_features_in_example(index: pd.DatetimeIndex) -> xr.Dataset:
235-
"""
236-
Make datetime features with sin and cos
237-
238-
Args:
239-
index: index of datestamps
240-
241-
Returns: Example data with datetime features
242-
243-
"""
244-
dt_features = datetime_features(index)
245-
dt_features["hour_of_day"] /= 24
246-
dt_features["day_of_year"] /= 365
247-
dt_features = utils.sin_and_cos(dt_features)
248-
249-
return dt_features.to_xarray()
250-
251-
252213
def make_random_time_vectors(batch_size, seq_length_5_minutes, seq_length_30_minutes):
253214
"""
254215
Make random time vectors

nowcasting_dataset/utils.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -61,40 +61,6 @@ def scale_to_0_to_1(a: Array) -> Array:
6161
return a
6262

6363

64-
# TODO: Issue #170. Is this this function still used?
65-
def sin_and_cos(df: pd.DataFrame) -> pd.DataFrame:
66-
"""
67-
For every column in df, creates cols for sin and cos of that col.
68-
69-
Args:
70-
df: Input DataFrame. The values must be in the range [0, 1].
71-
72-
Raises:
73-
ValueError if any value in df is not within the range [0, 1].
74-
75-
Returns:
76-
A new DataFrame, with twice the number of columns as the input df.
77-
For each col in df, the output DataFrame will have a <col name>_sin
78-
and a <col_name>_cos.
79-
"""
80-
columns = []
81-
for col_name in df.columns:
82-
columns.append(f"{col_name}_sin")
83-
columns.append(f"{col_name}_cos")
84-
output_df = pd.DataFrame(index=df.index, columns=columns, dtype=np.float32)
85-
for col_name in df.columns:
86-
series = df[col_name]
87-
if series.min() < 0.0 or series.max() > 1.0:
88-
raise ValueError(
89-
f"{col_name} has values outside the range [0, 1]!"
90-
f" min={series.min()}; max={series.max()}"
91-
)
92-
radians = series * 2 * np.pi
93-
output_df[f"{col_name}_sin"] = np.sin(radians)
94-
output_df[f"{col_name}_cos"] = np.cos(radians)
95-
return output_df
96-
97-
9864
def get_netcdf_filename(batch_idx: int) -> str:
9965
"""Generate full filename, excluding path."""
10066
assert 0 <= batch_idx < 1e6

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="nowcasting_dataset",
13-
version="2.0.0",
13+
version="2.0.2",
1414
license="MIT",
1515
description="Nowcasting Dataset",
1616
author="Jack Kelly, Peter Dudfield, Jacob Bieker",

0 commit comments

Comments
 (0)