Skip to content

Commit

Permalink
Merge pull request #4 from openclimatefix/dataloader_bug
Browse files Browse the repository at this point in the history
Dataloader bug
  • Loading branch information
dfulu authored Jul 5, 2024
2 parents fc64df9 + 35e191a commit 173c567
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sat_pred/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ def find_valid_t0_times(ds, history_mins, forecast_mins, sample_freq_mins):

valid_t0_times = []
for _, row in contiguous_t0_periods.iterrows():
start_dt = row["start_dt"]
end_dt = row["end_dt"]
valid_t0_times.append(pd.date_range(row["start_dt"], row["end_dt"], freq="5min"))
valid_t0_times.append(
pd.date_range(
row["start_dt"],
row["end_dt"],
freq=f"{sample_freq_mins}min"
)
)

valid_t0_times = pd.to_datetime(np.concatenate(valid_t0_times))

Expand Down
15 changes: 15 additions & 0 deletions tests/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def test_find_valid_t0_times(sat_zarr_path):
# Total 252

assert len(t0_times)==252

t0_times = find_valid_t0_times(
ds,
history_mins=60,
forecast_mins=120,
sample_freq_mins=15,
)

# original 15 minute timesteps 288 / 3
# forecast length buffer - (120 / 15)
# history length buffer - (60 / 15)
# ------------
# Total 84

assert len(t0_times)==84


def test_satellite_dataset(sat_zarr_path):
Expand Down

0 comments on commit 173c567

Please sign in to comment.