Forecast

Forecast

The Forecast class provides access to weather forecast data from Jua's weather prediction models. It allows you to retrieve future weather predictions with flexible spatial and temporal selection options.

Overview

The Forecast class serves as your interface to Jua's weather forecasting capabilities. It provides methods to:

  • Retrieve forecast data for global coverage or specific locations

  • Access forecasts for specific initialization times or the latest available forecast

  • Query metadata about available forecasts

  • Check forecast availability and readiness

Request forecast metadata

import json

from jua import JuaClient
from jua.weather import Models

client = JuaClient()
model = client.weather.get_model(Models.EPT1_5)

# init_time might be any valid datetime object or datetime string
metadata = model.forecast.get_metadata(init_time="latest")
print(json.dumps(metadata.model_dump(), indent=4, default=str))

Check if the forecasted data is available

from jua import JuaClient
from jua.weather import Models

client = JuaClient()
model = client.weather.get_model(Models.EPT1_5)

# init_time might be any valid datetime object or datetime string
if model.forecast.is_ready(forecasted_hours=480, init_time="latest"):
    print(f"{model.name} has at least 480 hours of forecast data available")
else:
    print(f"{model.name} does not yet have 480 hours of forecast data available")

Requesting the forecast data

from jua import JuaClient
from jua.types.geo import LatLon
from jua.weather import Models, Variables

# Setup JuaClient
client = JuaClient()
# Choose the model
model = client.weather.get_model(Models.EPT1_5)

# Defining the sites that we are interested in
sites = [
    # label is optional
    LatLon(55.06, 13.00, label="Kriegers Flak"),
    LatLon(54.04, 5.96, label="Gemini Wind Farm"),
    LatLon(51.71, 2.91, label="Borssele III & IV"),
    LatLon(53.89, 1.79, label="Hornsea Two"),
]

# Define the variables we are interested in
# If set to `None` all available variables will be loaded
variables = [
    Variables.WIND_SPEED_AT_HEIGHT_LEVEL_100M,
]

site_forecasts = model.forecast.get_forecast(
    init_time="latest", # or any valid datetime / datetime string
    points=sites,
    # The below parameters are optional
    variables=variables,
    min_lead_time=0, # hours
    max_lead_time=72, # hours
)

# Convert the response to an xarray dataset
print(site_forecasts.to_xarray()) 
<xarray.Dataset> Size: 3kB
Dimensions:                          (point: 4, time: 1,
                                      prediction_timedelta: 73)
Coordinates:
  * time                             (time) object 8B 2025-05-14T06:00:00+00:00
  * prediction_timedelta             (prediction_timedelta) timedelta64[ns] 584B ...
    latitude                         (point) float64 32B 55.07 54.02 51.75 53.85
    longitude                        (point) float64 32B 12.97 6.0 2.919 1.784
Dimensions without coordinates: point
Data variables:
    wind_speed_at_height_level_100m  (point, time, prediction_timedelta) float64 2kB ...
Attributes:
    model:                    ept1_5
    id:                       2025-05-14_06
    name:                     /v1/forecasting/ept1_5/forecasts/2025-05-14_06
    init_time:                2025-05-14 06:00:00+00:00
    max_available_lead_time:  480

⚠️ Only the models EPT-2, EPT-1.5, EPT-1.5 Early currently support requesting data from past forecasts

⚠️ Requesting forecast data older than 36 hours will take longer to load.

Last updated