|
16 | 16 |
|
17 | 17 | 1. `gsp_name`: A string identifying the Grid Supply Point region. |
18 | 18 | 2. `forecast_date_time`: The UTC datetime when ESO ran their forecast. |
19 | | - The `forecast_date_time` will be a little time (about an hour or two?) |
| 19 | + The `forecast_date_time` will be about an hour or two |
20 | 20 | after the initialisation time of the numerical weather predictions |
21 | 21 | fed into ESO's forecasting algorithm. This script takes the floor('30T') of the |
22 | 22 | original forecast_date_time from ESO. `forecast_date_time` tells us when ESO |
23 | 23 | ran their PV forecast. The `target_date_time` (the time that each forecast is |
24 | 24 | _about_) can be calculated as the sum of `forecast_date_time` and `step`. |
| 25 | + The `step` is computed after taking the floor('30T') of the `forecast_date_time`, |
| 26 | + so the re-computed `target_date_time` should be correct. |
25 | 27 | To give a little more background: For most forecasts, any given row is identified |
26 | 28 | by _two_ datetimes: The datetime that the forecast was run (the `forecast_date_time`); |
27 | 29 | and the datetime that the forecast is _about_ (the `target_date_time`). |
28 | 30 | 3. `step`: The Timedelta between the forecast_date_time and the target_date_time. |
29 | 31 |
|
30 | 32 | It's not possible to append to NetCDF files, so this script loads everything into memory, |
31 | | -and strip away stuff we don't need, and maintain a list of xr.DataSets to be concatenated. |
| 33 | +and strips away stuff we don't need, and maintains a list of xr.DataSets to be concatenated. |
32 | 34 | """ |
33 | 35 |
|
34 | 36 | from pathlib import Path |
@@ -61,7 +63,7 @@ def filenames_and_datetime_periods(path: Path) -> pd.Series: |
61 | 63 | """Gets all CSV filenames in `path`. |
62 | 64 |
|
63 | 65 | Returns a Series where the Index is a pd.PeriodIndex at monthly frequency, |
64 | | - and the values at the full Path to the CSV file. The index is sorted. |
| 66 | + and the values are the full Path to the CSV file. The index is sorted. |
65 | 67 |
|
66 | 68 | This is the header and first line of an ESO CSVs: |
67 | 69 |
|
@@ -167,10 +169,10 @@ def convert_to_dataarray(df: pd.DataFrame) -> xr.DataArray: |
167 | 169 | df = df.drop(columns="TARGET_DATE_TIME") |
168 | 170 |
|
169 | 171 | # Make sure "step" is positive: |
170 | | - # (step can be negative for ASL forecasts, for some reasons). |
| 172 | + # (step can be negative for ASL forecasts. I don't know why!). |
171 | 173 | df = df[df.step >= pd.Timedelta(0)] |
172 | 174 |
|
173 | | - # Rename to more column names more like the ones we're used to. |
| 175 | + # Rename to column names more like the ones we're used to in OCF. |
174 | 176 | df = df.rename(columns={"SITE_ID": "gsp_name"}) |
175 | 177 |
|
176 | 178 | # Set index |
|
0 commit comments