Skip to content

Preparing a Forecast

After downloading the raw measurements data, the next step for Forecasters is to prepare their forecasts. This involves creating forecast submissions based on the retrieved data and any additional variables or models the Forecaster might utilize. In this example, we'll demonstrate how to prepare a simple 24-hour submission using randomly generated data. In a real-world scenario, you would replace this with your forecasting model based on the dataset retrieved in the previous step.

Note

  • Example Purpose: This example demonstrates preparing a 24-hour forecast submission with 15-minute interval samples using random data. Replace this with your forecasting model for actual use.
  • Quantiles: The example submission includes values for three variables, specifically 'quantiles' 10, 50, and 90.

Prerequisites

  • Python Environment: Ensure you have Python installed with the necessary libraries (pandas, numpy, requests).
  • Access Token: A valid access token is required for authentication. Refer to the Authentication section if needed.
  • Challenges List: A list of challenges retrieved from the Listing Challenges section.

Selecting a Challenge

First, retrieve the information about the challenge you want to submit a forecast for. In the example below, we will select a challenge for a specific market session (open_market_session_id) and target resource name (resource_name).

submit_forecast.py
# Get the session id from `/market/session/` endpoint
open_market_session_id = "your_open_market_session_id"

# Challenge resource identifier (name):
resource_name = "wind_farm_1"

# Request the challenges for the open market session:
response = requests.get(
    url='https://predico-elia.inesctec.pt/api/v1/market/challenge',
    params={'market_session': int(open_market_session_id),
            'resource_name': resource_name},
    headers=headers
)

# Check if the request was successful
if response.status_code == 200:
    challenges = response.json()
else:
    print("Failed to retrieve challenges.")
    print(f"Status code: {response.status_code}")
    exit()

# Select the first challenge of the list of challenges previous retrieved
# Note that as we're filtering by resource_name, there should be only a
# single challenge per session
selected_challenge = challenges["data"][0]

# Unpack selected challenge information
resource_id = selected_challenge["resource"]  # challenge resource UUID
challenge_id = selected_challenge["id"] # challenge UUID
start_datetime = selected_challenge["start_datetime"] # first forecast leadtime
end_datetime = selected_challenge["end_datetime"] # last forecast leadtime
print(f"""
Challenge info:
ID: {challenge_id}
Resource ID: {resource_id}
First forecast leadtime): {start_datetime}
Last forecast leadtime): {end_datetime}
""")

Preparing Forecast Submissions Time-series Data

Next, prepare the forecast data for submission.

Strict requirement!

You must submit forecasts for variables Q10, Q50 and Q90 to be selected to participate in a forecasting session. Partial submissions (e.g., missing one of the variables) will not be considered for the final evaluation / monthly payment distribuctions.

Change this submission!

In this example, our submission will be exclusively composed by random samples. However, you should prepare your model based on the raw measurements data for the challenge resource (see Downloading Raw Data section), and any external information sources you might have access to.

One variable at each time

You can only submit one forecast variable in each HTTPs request (e.g., forecasts for quantile 10 in the first request and quantile 50 in the second request). After each submission, you will receive an email confirming that the forecast was successfully submitted. This also helps you to keep track of your submissions.

submit_forecast.py
# Create a random 24h submission (random values):
# Generate datetime values for the challenge period:
datetime_range = pd.date_range(start=start_datetime,
                               end=end_datetime,
                               freq='15T')
datetime_range = [x.strftime("%Y-%m-%dT%H:%M:%SZ") for x in datetime_range]
# Generate random values for the "value" column
values = np.random.uniform(low=0.0, high=1.0, size=len(datetime_range))
values = [round(x, 3) for x in values]

# Reuse this data to prepare 3 different quantiles submissions Q10, Q50, Q90
submission_list = []
for qt in ["q50", "q10", "q90"]:
    qt_forec = pd.DataFrame({
    'datetime': datetime_range,
    'value': values,
    })
    submission_list.append({
        "variable": qt,
        "forecasts": qt_forec.to_dict(orient="records")
    })

# Your submissions:
print("Submission List:")
for i, submission in enumerate(submission_list):
    print("-"*79)
    print(f"Submission #{i+1}")
    print(json.dumps(submission, indent=3))

Download Full Example

What's next?

Learn how to submit your forecasts on the Predico platform in the Submitting a Forecast section.