Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit c2836a6

Browse files
committed
Allow import of OCF datapipes without PVLive
1 parent 02b74a1 commit c2836a6

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

ocf_datapipes/load/gsp/database.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
from torchdata.datapipes.iter import IterDataPipe
1717

1818
from ocf_datapipes.load.gsp.utils import put_gsp_data_into_an_xr_dataarray
19-
from ocf_datapipes.utils.eso import get_gsp_shape_from_eso
19+
try:
20+
from ocf_datapipes.utils.eso import get_gsp_shape_from_eso
21+
22+
_has_pvlive = True
23+
except ImportError:
24+
print("Unable to import PVLive utils, please provide filenames with OpenGSP")
25+
_has_pvlive = False
2026

2127
logger = logging.getLogger(__name__)
2228

ocf_datapipes/utils/consts.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -186,35 +186,6 @@ class BatchKey(Enum):
186186
hrvsatellite_time_utc_fourier = auto()
187187
hrvsatellite_time_utc_fourier_t0 = auto()
188188

189-
# -------------- SATELLITE -----------------------------------
190-
# shape: (batch_size, time, channels, y, x)
191-
#
192-
# Or, if the imagery has been patched,
193-
# shape: (batch_size, time, channels, y, x, n_pixels_per_patch) where n_pixels_per_patch
194-
# is the *total* number of pixels,
195-
# i.e. n_pixels_per_patch_along_height * n_pixels_per_patch_along_width.
196-
satellite_actual = auto()
197-
satellite_predicted = auto() # shape: batch_size, time, y, x
198-
satellite_t0_idx = auto() # shape: scalar
199-
200-
# HRV satellite coordinates:
201-
satellite_y_osgb = auto() # shape: (batch_size, y, x)
202-
satellite_x_osgb = auto() # shape: (batch_size, y, x)
203-
satellite_y_geostationary = auto() # shape: (batch_size, y)
204-
satellite_x_geostationary = auto() # shape: (batch_size, x)
205-
#: Time is seconds since UNIX epoch (1970-01-01). Shape: (batch_size, n_timesteps)
206-
satellite_time_utc = auto()
207-
# Added by np_batch_processor.Topography:
208-
satellite_surface_height = auto() # The surface height at each pixel. (batch_size, y, x)
209-
210-
# HRV satellite Fourier coordinates:
211-
# Spatial coordinates. Shape: (batch_size, y, x, n_fourier_features_per_dim)
212-
satellite_y_osgb_fourier = auto()
213-
satellite_x_osgb_fourier = auto()
214-
#: Time shape: (batch_size, n_timesteps, n_fourier_features_per_dim)
215-
satellite_time_utc_fourier = auto()
216-
satellite_time_utc_fourier_t0 = auto()
217-
218189
# -------------- NWP --------------------------------------------
219190
nwp = auto() # shape: (batch_size, target_time_utc, channel, y_osgb, x_osgb)
220191
nwp_t0_idx = auto() # shape: scalar
@@ -316,6 +287,35 @@ class BatchKey(Enum):
316287
# Not used in the Raw data pipeline.
317288
requested_timesteps = auto() # shape: (n_requested_timesteps)
318289

290+
# -------------- SATELLITE -----------------------------------
291+
# shape: (batch_size, time, channels, y, x)
292+
#
293+
# Or, if the imagery has been patched,
294+
# shape: (batch_size, time, channels, y, x, n_pixels_per_patch) where n_pixels_per_patch
295+
# is the *total* number of pixels,
296+
# i.e. n_pixels_per_patch_along_height * n_pixels_per_patch_along_width.
297+
satellite_actual = auto()
298+
satellite_predicted = auto() # shape: batch_size, time, y, x
299+
satellite_t0_idx = auto() # shape: scalar
300+
301+
# HRV satellite coordinates:
302+
satellite_y_osgb = auto() # shape: (batch_size, y, x)
303+
satellite_x_osgb = auto() # shape: (batch_size, y, x)
304+
satellite_y_geostationary = auto() # shape: (batch_size, y)
305+
satellite_x_geostationary = auto() # shape: (batch_size, x)
306+
#: Time is seconds since UNIX epoch (1970-01-01). Shape: (batch_size, n_timesteps)
307+
satellite_time_utc = auto()
308+
# Added by np_batch_processor.Topography:
309+
satellite_surface_height = auto() # The surface height at each pixel. (batch_size, y, x)
310+
311+
# HRV satellite Fourier coordinates:
312+
# Spatial coordinates. Shape: (batch_size, y, x, n_fourier_features_per_dim)
313+
satellite_y_osgb_fourier = auto()
314+
satellite_x_osgb_fourier = auto()
315+
#: Time shape: (batch_size, n_timesteps, n_fourier_features_per_dim)
316+
satellite_time_utc_fourier = auto()
317+
satellite_time_utc_fourier_t0 = auto()
318+
319319

320320
NumpyBatch = dict[BatchKey, np.ndarray]
321321

0 commit comments

Comments
 (0)