Skip to content

Commit fa73507

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

File tree

5 files changed

+65
-50
lines changed

5 files changed

+65
-50
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OCF Datapipes
22

3-
OCF's DataPipes for training and inference in Pytorch.
3+
OCF's DataPipes for training and inference in Pytorch.
44

55
## Usage
66

ocf_datapipes/training/common.py

+44-29
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
from ocf_datapipes.load import OpenPVFromDB, OpenTopography, OpenGSP, OpenConfiguration, OpenNWP, OpenSatellite, OpenPVFromNetCDF
1+
import logging
2+
from datetime import timedelta
3+
from typing import List
4+
25
import xarray as xr
36
from torchdata.datapipes.iter import IterDataPipe
7+
48
from ocf_datapipes.config.model import Configuration
5-
from typing import List
6-
import logging
7-
from datetime import timedelta
9+
from ocf_datapipes.load import (
10+
OpenConfiguration,
11+
OpenGSP,
12+
OpenNWP,
13+
OpenPVFromDB,
14+
OpenPVFromNetCDF,
15+
OpenSatellite,
16+
OpenTopography,
17+
)
818

919
logger = logging.getLogger(__name__)
1020

1121

12-
def open_and_return_datapipes(configuration_filename: str, use_gsp: bool = True, use_nwp: bool = True, use_pv: bool = True, use_sat: bool = True, use_hrv: bool = True, use_topo: bool = True) -> dict[IterDataPipe]:
22+
def open_and_return_datapipes(
23+
configuration_filename: str,
24+
use_gsp: bool = True,
25+
use_nwp: bool = True,
26+
use_pv: bool = True,
27+
use_sat: bool = True,
28+
use_hrv: bool = True,
29+
use_topo: bool = True,
30+
) -> dict[IterDataPipe]:
1331
"""
1432
Open data sources given a configuration and return the list of datapipes
1533
@@ -45,10 +63,10 @@ def open_and_return_datapipes(configuration_filename: str, use_gsp: bool = True,
4563
True if configuration.input_data.topographic.topographic_filename != "" else False
4664
)
4765
if use_gsp:
48-
use_gsp = (
49-
True if configuration.input_data.gsp.gsp_zarr_path != "" else False
50-
)
51-
logger.debug(f"GSP: {use_gsp} NWP: {use_nwp} Sat: {use_sat}, HRV: {use_hrv} PV: {use_pv} Topo: {use_topo}")
66+
use_gsp = True if configuration.input_data.gsp.gsp_zarr_path != "" else False
67+
logger.debug(
68+
f"GSP: {use_gsp} NWP: {use_nwp} Sat: {use_sat}, HRV: {use_hrv} PV: {use_pv} Topo: {use_topo}"
69+
)
5270

5371
used_datapipes = {}
5472

@@ -58,9 +76,9 @@ def open_and_return_datapipes(configuration_filename: str, use_gsp: bool = True,
5876
gsp_datapipe = OpenGSP(
5977
gsp_pv_power_zarr_path=configuration.input_data.gsp.gsp_zarr_path
6078
).add_t0_idx_and_sample_period_duration(
61-
sample_period_duration=timedelta(minutes=30),
62-
history_duration=timedelta(minutes=configuration.input_data.gsp.history_minutes),
63-
)
79+
sample_period_duration=timedelta(minutes=30),
80+
history_duration=timedelta(minutes=configuration.input_data.gsp.history_minutes),
81+
)
6482

6583
used_datapipes["gsp"] = gsp_datapipe
6684

@@ -95,34 +113,31 @@ def open_and_return_datapipes(configuration_filename: str, use_gsp: bool = True,
95113

96114
if use_hrv:
97115
logger.debug("Opening HRV Satellite Data")
98-
sat_hrv_datapipe = (
99-
OpenSatellite(configuration.input_data.hrvsatellite.hrvsatellite_zarr_path)
100-
.add_t0_idx_and_sample_period_duration(
101-
sample_period_duration=timedelta(minutes=5),
102-
history_duration=timedelta(
103-
minutes=configuration.input_data.hrvsatellite.history_minutes
104-
),
105-
)
116+
sat_hrv_datapipe = OpenSatellite(
117+
configuration.input_data.hrvsatellite.hrvsatellite_zarr_path
118+
).add_t0_idx_and_sample_period_duration(
119+
sample_period_duration=timedelta(minutes=5),
120+
history_duration=timedelta(
121+
minutes=configuration.input_data.hrvsatellite.history_minutes
122+
),
106123
)
107124

108125
used_datapipes["hrv"] = sat_hrv_datapipe
109126

110127
if use_pv:
111128
logger.debug("Opening PV")
112-
pv_datapipe = (
113-
OpenPVFromNetCDF(pv=configuration.input_data.pv)
114-
.add_t0_idx_and_sample_period_duration(
115-
sample_period_duration=timedelta(minutes=5),
116-
history_duration=timedelta(minutes=configuration.input_data.pv.history_minutes),
117-
))
129+
pv_datapipe = OpenPVFromNetCDF(
130+
pv=configuration.input_data.pv
131+
).add_t0_idx_and_sample_period_duration(
132+
sample_period_duration=timedelta(minutes=5),
133+
history_duration=timedelta(minutes=configuration.input_data.pv.history_minutes),
134+
)
118135

119136
used_datapipes["pv"] = pv_datapipe
120137

121138
if use_topo:
122139
logger.debug("Opening Topographic Data")
123-
topo_datapipe = OpenTopography(
124-
configuration.input_data.topographic.topographic_filename
125-
)
140+
topo_datapipe = OpenTopography(configuration.input_data.topographic.topographic_filename)
126141

127142
used_datapipes["topo"] = topo_datapipe
128143

ocf_datapipes/training/nwp_pv.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# NWP PV
1+
# NWP PV
22

3-
nwp_pv.py is a training pipeline for loading NWP and PV data.
3+
nwp_pv.py is a training pipeline for loading NWP and PV data.
44

5-
The location is chosen using the PV data, PV and NWP location data is made.
6-
Then a time is chosen, and PV and NWP examples are made.
7-
These examples are then made into batches and put together into one Batch.
5+
The location is chosen using the PV data, PV and NWP location data is made.
6+
Then a time is chosen, and PV and NWP examples are made.
7+
These examples are then made into batches and put together into one Batch.
88

99
```mermaid
1010
graph TD;
@@ -26,4 +26,4 @@ These examples are then made into batches and put together into one Batch.
2626
F[PV batch] --> G;
2727
F1[NWP batch] --> G;
2828
G[Batch];
29-
```
29+
```

ocf_datapipes/training/simple_pv.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Simple PV
1+
# Simple PV
22

3-
simple_pv.py has a training pipeline for just loading PV data.
3+
simple_pv.py has a training pipeline for just loading PV data.
44

5-
The location is chosen using the PV data, PV location data is made.
6-
Then a time is chosen, and PV examples are made.
7-
These examples are then made into batches.
5+
The location is chosen using the PV data, PV location data is made.
6+
Then a time is chosen, and PV examples are made.
7+
These examples are then made into batches.
88

99
```mermaid
1010
graph TD;
@@ -16,4 +16,4 @@ These examples are then made into batches.
1616
C-->D[Choose time]-->E;
1717
E[PV example]-->F;
1818
F[PV batch];
19-
```
19+
```

pydoc-markdown.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ renderer:
1919
- title: Convert
2020
contents: [convert]
2121
- title: Experimental
22-
contents: [ experimental ]
22+
contents: [experimental]
2323
- title: Fake Data
24-
contents: [ fake ]
24+
contents: [fake]
2525
- title: Loading Data
26-
contents: [ load ]
26+
contents: [load]
2727
- title: Production Datapipes
28-
contents: [ production ]
28+
contents: [production]
2929
- title: Training Datapipes
30-
contents: [ training ]
30+
contents: [training]
3131
- title: Selecting Data
32-
contents: [ select ]
32+
contents: [select]
3333
- title: Transforms
34-
contents: [ transform ]
34+
contents: [transform]
3535
- title: Validation
36-
contents: [ validation ]
36+
contents: [validation]
3737
- title: Utils
3838
contents: [utils]
3939
mkdocs_config:

0 commit comments

Comments
 (0)