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

Commit f8c7e35

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 77ff450 commit f8c7e35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+14
-124
lines changed

notebooks/2021-08/2021-08-25/video.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import cv2
44
import numpy as np
55
import pandas as pd
6-
import plotly
76
import plotly.graph_objects as go
87

98
from nowcasting_dataset.dataset import SAT_MEAN, SAT_STD, NetCDFDataset
@@ -69,7 +68,6 @@
6968
channel_indexes = [1, 8, 9]
7069
satellite_data = []
7170
for channel_index in channel_indexes:
72-
7371
# renormalize
7472
satellite_data.append(
7573
data["sat_data"][batch_index, :, :, :, channel_index] * SAT_STD.values[channel_index]

notebooks/2021-08/2021-08-26/video.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import cv2
44
import numpy as np
55
import pandas as pd
6-
import plotly
7-
import plotly.express as px
86
import plotly.graph_objects as go
97

108
# get satellite image, currently from https://github.com/openclimatefix/py-staticmaps
@@ -90,7 +88,6 @@
9088
channel_indexes = [1, 9, 8]
9189
satellite_data = []
9290
for channel_index in channel_indexes:
93-
9491
# renormalize
9592
satellite_data.append(
9693
data["sat_data"][batch_index, :, :, :, channel_index] * SAT_STD.values[channel_index]

notebooks/2021-09/2021-09-06/gsp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
# find out if point is in gsp
39-
from shapely.geometry import Point, Polygon
39+
from shapely.geometry import Point
4040

4141
_pnts = [Point(3, 3), Point(8, 8), Point(0, 51.38)]
4242
pnts = gpd.GeoDataFrame(geometry=_pnts, index=["A", "B", "C"])

notebooks/2021-09/2021-09-07/gsp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
# find out if point is in gsp
41-
from shapely.geometry import Point, Polygon
41+
from shapely.geometry import Point
4242

4343
_pnts = [Point(3, 3), Point(8, 8), Point(0, 51.38)]
4444
pnts = gpd.GeoDataFrame(geometry=_pnts, index=["A", "B", "C"])

notebooks/2021-09/2021-09-08/dan.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import gcsfs
21
import xarray as xr
32

43
filename = "gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/OSGB36/all_zarr_int16_single_timestep.zarr/"

notebooks/2021-09/2021-09-13/remove_hash.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
for filenames in [train_filenames, validation_filenames]:
2222
for file in train_filenames:
23-
2423
print(file)
2524

2625
filename = file.split("/")[-1]
@@ -30,7 +29,7 @@
3029

3130
try:
3231
rename_file(remote_file=file, new_filename=new_filename)
33-
except Exception as e:
32+
except Exception:
3433
pass
3534
else:
3635
print(f"Skipping {filename}")

notebooks/2021-09/2021-09-14/gsp_centroid.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from nowcasting_dataset.data_sources.gsp.eso import (
66
get_gsp_metadata_from_eso,
7-
get_gsp_shape_from_eso,
87
)
98
from nowcasting_dataset.geospatial import WGS84_CRS
109

@@ -16,7 +15,6 @@
1615

1716
# for index in range(0, len(shape_data_raw)):
1817
for index in range(140, 150):
19-
2018
# just select the first one
2119
shape_data = shape_data_raw.iloc[index : index + 1]
2220
shapes_dict = json.loads(shape_data["geometry"].to_json())

notebooks/2021-09/2021-09-14/gsp_duplicated.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import plotly.graph_objects as go
44

55
from nowcasting_dataset.data_sources.gsp.eso import (
6-
get_gsp_metadata_from_eso,
76
get_gsp_shape_from_eso,
87
)
98

@@ -13,7 +12,6 @@
1312
duplicated_raw["Amount"] = range(0, len(duplicated_raw))
1413

1514
for i in range(0, 8, 2):
16-
1715
# just select the first one
1816
duplicated = duplicated_raw.iloc[i : i + 2]
1917
shapes_dict = json.loads(duplicated["geometry"].to_json())

notebooks/2021-09/2021-09-28/get_raw_sun_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from nowcasting_dataset.data_sources.gsp.eso import get_gsp_metadata_from_eso
2424
from nowcasting_dataset.data_sources.sun.raw_data_load_save import (
2525
get_azimuth_and_elevation,
26-
save_to_zarr,
2726
)
2827

2928
# set up

notebooks/2021-09/2021-09-29/gsp_duplicated.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import plotly.graph_objects as go
44

55
from nowcasting_dataset.data_sources.gsp.eso import (
6-
get_gsp_metadata_from_eso,
76
get_gsp_shape_from_eso,
87
)
98
from nowcasting_dataset.geospatial import WGS84_CRS
@@ -15,7 +14,6 @@
1514
duplicated_raw["Amount"] = range(0, len(duplicated_raw))
1615

1716
for i in range(0, 8, 2):
18-
1917
# just select the first one
2018
duplicated = duplicated_raw.iloc[i : i + 2]
2119
shapes_dict = json.loads(duplicated["geometry"].to_json())

notebooks/2021-09/2021-09-29/video.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242

4343
def get_trace(dt):
44-
4544
# plot to check it looks right
4645
return go.Choroplethmapbox(
4746
geojson=shapes_dict,
@@ -54,7 +53,6 @@ def get_trace(dt):
5453

5554

5655
def get_frame(dt):
57-
5856
# plot to check it looks right
5957
return go.Choroplethmapbox(
6058
z=gps_data[dt],
@@ -71,8 +69,8 @@ def get_frame(dt):
7169
fig.update_layout(title="Midday")
7270

7371
# fig.show(renderer="browser")
74-
fig.write_html(f"midday_fix.html")
75-
fig.write_image(f"midday_fix.png")
72+
fig.write_html("midday_fix.html")
73+
fig.write_image("midday_fix.png")
7674

7775
# make annimation
7876
frames = []
@@ -147,4 +145,4 @@ def get_frame(dt):
147145
)
148146

149147
fig.show(renderer="browser")
150-
fig.write_html(f"video.html")
148+
fig.write_html("video.html")

notebooks/2021-10/2021-10-01/pydantic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import numpy as np
44
import torch
55
import xarray as xr
6-
from pydantic import BaseModel, Field, validator
6+
from pydantic import BaseModel, Field
77

88
from nowcasting_dataset.config.model import Configuration
99

1010
Array = Union[xr.DataArray, np.ndarray, torch.Tensor]
1111

1212

1313
class Satellite(BaseModel):
14-
1514
# width: int = Field(..., g=0, description="The width of the satellite image")
1615
# height: int = Field(..., g=0, description="The width of the satellite image")
1716
# num_channels: int = Field(..., g=0, description="The width of the satellite image")
@@ -49,7 +48,6 @@ class Config:
4948

5049

5150
class Batch(BaseModel):
52-
5351
batch_size: int = Field(
5452
...,
5553
g=0,

notebooks/2021-10/2021-10-08/xr_compression.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
def get_satellite_xrarray_data_array(
1010
batch_size, seq_length_5, satellite_image_size_pixels, number_sat_channels=10
1111
):
12-
1312
r = np.random.randn(
1413
# self.batch_size,
1514
seq_length_5,
@@ -53,9 +52,9 @@ def sat_data_array_to_dataset(sat_xr):
5352
ds = coord_to_range(ds, dim, prefix="sat")
5453
ds = ds.rename(
5554
{
56-
"channels": f"sat_channels",
57-
"x": f"sat_x",
58-
"y": f"sat_y",
55+
"channels": "sat_channels",
56+
"x": "sat_x",
57+
"y": "sat_y",
5958
}
6059
)
6160

notebooks/2021-10/2021-10-08/xr_pydantic.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from typing import List, Union
1+
from typing import Union
22

33
import numpy as np
44
import torch
55
import xarray as xr
66
from pydantic import BaseModel, Field, validator
77

8-
from nowcasting_dataset.config.model import Configuration
9-
108
Array = Union[xr.DataArray, np.ndarray, torch.Tensor]
119

1210

@@ -27,7 +25,6 @@ def v_image_data(cls, v):
2725

2826

2927
class Batch(BaseModel):
30-
3128
batch_size: int = 0
3229
satellite: Satellite
3330

nowcasting_dataset/data_sources/data_source.py

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def __post_init__(self):
8282
def _get_start_dt(
8383
self, t0_datetime_utc: Union[pd.Timestamp, pd.DatetimeIndex]
8484
) -> Union[pd.Timestamp, pd.DatetimeIndex]:
85-
8685
return t0_datetime_utc - self.history_duration
8786

8887
def _get_end_dt(

nowcasting_dataset/data_sources/fake/batch.py

-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ def topographic_fake(
504504
# make batch of arrays
505505
xr_arrays = []
506506
for i in range(batch_size):
507-
508507
x, y = make_image_coords_osgb(
509508
size_x=image_size_pixels_width,
510509
size_y=image_size_pixels_height,

nowcasting_dataset/data_sources/gsp/eso.py

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def get_gsp_shape_from_eso(
164164
shape_gpd["RegionID"] = range(1, len(shape_gpd) + 1)
165165

166166
if save_local_file:
167-
168167
# rename the columns to less than 10 characters
169168
shape_gpd_to_save = shape_gpd.copy()
170169
shape_gpd_to_save.rename(columns=rename_save_columns, inplace=True)

nowcasting_dataset/data_sources/gsp/gsp_data_source.py

-5
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def get_all_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTim
173173
if total_gsp_nan_count > 0:
174174
assert Exception("There are nans in the GSP data. Can't get locations for all GSPs")
175175
else:
176-
177176
t0_datetimes_utc.name = "t0_datetime_utc"
178177

179178
# get all locations
@@ -236,7 +235,6 @@ def get_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTimeLoc
236235

237236
total_gsp_nan_count = self.gsp_power.isna().sum().sum()
238237
if total_gsp_nan_count == 0:
239-
240238
# get random GSP metadata
241239
indexes = sorted(
242240
list(self.rng.integers(low=0, high=len(self.metadata), size=len(t0_datetimes_utc)))
@@ -249,7 +247,6 @@ def get_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTimeLoc
249247
ids = list(metadata.index)
250248

251249
else:
252-
253250
logger.warning(
254251
"There are some nans in the gsp data, "
255252
"so to get x,y locations we have to do a big loop"
@@ -262,7 +259,6 @@ def get_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTimeLoc
262259
ids = []
263260

264261
for t0_dt in t0_datetimes_utc:
265-
266262
# Choose start and end times
267263
start_dt = self._get_start_dt(t0_dt)
268264
end_dt = self._get_end_dt(t0_dt)
@@ -290,7 +286,6 @@ def get_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTimeLoc
290286

291287
locations = []
292288
for i in range(len(x_centers_osgb)):
293-
294289
locations.append(
295290
SpaceTimeLocation(
296291
t0_datetime_utc=t0_datetimes_utc[i],

nowcasting_dataset/data_sources/gsp/pvlive.py

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def load_pv_gsp_raw_data_from_pvlive(
8989
future_tasks = []
9090
with futures.ThreadPoolExecutor(max_workers=4) as executor:
9191
for gsp_id in gsp_ids:
92-
9392
# set the first chunk start and end times
9493
start_chunk = first_start_chunk
9594
end_chunk = first_end_chunk

nowcasting_dataset/data_sources/metadata/metadata_model.py

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def save_to_csv(self, path):
114114
metadata_df = pd.DataFrame(metadata_dict)
115115

116116
else:
117-
118117
metadata_df = pd.read_csv(filename)
119118

120119
metadata_df_extra = pd.DataFrame(metadata_dict)

nowcasting_dataset/data_sources/pv/live.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def get_metadata_from_database(providers: List[str] = None) -> pd.DataFrame:
4343

4444
pv_system_all_df = []
4545
for provider in providers:
46-
4746
logger.debug(f"Get PV systems from database for {provider}")
4847

4948
with db_connection.get_session() as session:
@@ -132,7 +131,6 @@ def get_pv_power_from_database(
132131
logger.debug(f"Found {len(pv_yields_df)} pv yields")
133132

134133
if len(pv_yields_df) == 0:
135-
136134
data = create_empty_pv_data(end_utc=now, providers=providers, start_utc=start_utc)
137135

138136
return data

nowcasting_dataset/data_sources/pv/pv_data_source.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def get_data_model_for_batch():
9898
return PV
9999

100100
def _load_metadata(self):
101-
102101
logger.debug(f"Loading PV metadata from {self.files_groups}")
103102

104103
# collect all metadata together
@@ -155,7 +154,6 @@ def _load_metadata(self):
155154
logger.debug(f"Found {len(pv_metadata)} pv systems")
156155

157156
def _load_pv_power(self):
158-
159157
logger.debug(f"Loading PV Power data from {self.files_groups}")
160158

161159
if not self.is_live:
@@ -452,6 +450,7 @@ def get_locations(self, t0_datetimes_utc: pd.DatetimeIndex) -> List[SpaceTimeLoc
452450
Returns: x_locations, y_locations. Each has one entry per t0_datetime.
453451
Locations are in OSGB coordinates.
454452
"""
453+
455454
# Set this up as a separate function, so we can cache the result!
456455
@functools.cache # functools.cache requires Python >= 3.9
457456
def _get_pv_system_ids(t0_datetime: pd.Timestamp) -> pd.Int64Index:

nowcasting_dataset/data_sources/sun/raw_data_load_save.py

-3
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,13 @@ def get_azimuth_and_elevation(
4949
names = []
5050
# loop over locations and find azimuth and elevation angles,
5151
with futures.ThreadPoolExecutor() as executor:
52-
5352
logger.debug("Setting up jobs")
5453

5554
# Submit tasks to the executor.
5655
future_azimuth_and_elevation_per_location = []
5756
for i in tqdm(range(len(x_centers))):
58-
5957
name = x_y_to_name(x_centers[i], y_centers[i])
6058
if name not in names:
61-
6259
lat, lon = geospatial.osgb_to_lat_lon(x=x_centers[i], y=y_centers[i])
6360

6461
future_azimuth_and_elevation = executor.submit(

nowcasting_dataset/data_sources/sun/sun_data_source.py

-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
6969
end_dt = self._get_end_dt(t0_datetime_utc)
7070

7171
if not self.load_live:
72-
7372
# The names of the columns get truncated when saving, therefore we need to look for the
7473
# name of the columns near the location we are looking for
7574
locations = np.array(
@@ -96,7 +95,6 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
9695
elevation = self.elevation.loc[start_dt:end_dt][name]
9796

9897
else:
99-
10098
latitude, longitude = osgb_to_lat_lon(x=x_center_osgb, y=y_center_osgb)
10199

102100
datestamps = pd.date_range(start=start_dt, end=end_dt, freq="5T").tolist()
@@ -115,7 +113,6 @@ def get_example(self, location: SpaceTimeLocation) -> xr.Dataset:
115113
return sun
116114

117115
def _load(self):
118-
119116
logger.info(f"Loading Sun data from {self.zarr_path}")
120117

121118
if not self.load_live:

0 commit comments

Comments
 (0)