Aggregated Queries

Daily Min & Max for a location

query = {
    "models": ["ept2"],
    "geo": {
        "type": "point",
        "value": [47.3784, 8.5387],  # [longitude, latitude] - Zurich
        "method": "nearest",
    },
    "variables": [
        "air_temperature_at_height_level_2m",
        "wind_speed_at_height_level_100m",
    ],
    "init_time": "latest",
    "prediction_timedelta": {"start": 0, "end": 72},  # 0-72 hours ahead
}

# Estimate cost before executing
cost_response = requests.post(cost_url, headers=headers, json=query)
cost_response.raise_for_status()
cost_info = cost_response.json()
print(f"Estimated cost: {cost_info['total_credits_needed']:.4f} credits")
print(f"Rows to return: {cost_info['total_rows_returned']}")
print(f"Rows to access: {cost_info['total_rows_accessed']}")

response = requests.post(url, headers=headers, json=query)
response.raise_for_status()

data = response.json()
df = pd.DataFrame(data)
print(f"✅ Retrieved {len(df)} rows")
print(df.head())

Hourly Wind Statistics in Germany

query = {
    "models": ["ept2"],
    "geo": {
        "type": "market_zone",
        "value": "DE",  # Germany
    },
    "variables": ["wind_speed_at_height_level_100m"],
    "init_time": "latest",
    "prediction_timedelta": {"start": 0, "end": 72},  # 3 days
    "group_by": [
        {
            # Explicit use of the "to_start_of" transformation
            "field": "time",
            "transformation": "to_start_of",
            "parameters_list": ["hour"],
        }
    ],
    "aggregation": [
        {"aggregation": "max"},
        "min",
        "avg",
        "std",
        "quantile_(0.05)",
        "quantile_(0.95)",
    ],
    "include_time": True,
    "order_by": ["time"],
}

# Estimate cost before executing
cost_response = requests.post(cost_url, headers=headers, json=query)
cost_response.raise_for_status()
cost_info = cost_response.json()
print(f"Estimated cost: {cost_info['total_credits_needed']:.4f} credits")
print(f"Rows to return: {cost_info['total_rows_returned']}")
print(f"Rows to access: {cost_info['total_rows_accessed']}")

response = requests.post(url, headers=headers, json=query)
response.raise_for_status()

data = response.json()
df = pd.DataFrame(data)
print(f"Retrieved {len(df)} rows")
print(df.head(20))

return df

Capacity Weighted Average Wind Speed in Germany

 query = {
    "models": ["ept2"],
    "geo": {
        "type": "market_zone",
        "value": "DE",  # Germany
    },
    "variables": ["wind_speed_at_height_level_100m"],
    "init_time": "latest",
    "prediction_timedelta": {"start": 0, "end": 72},  # 3 days
    "weighting": {"type": "wind_capacity"},
    "group_by": [
        {
            "field": "time",
            "transformation": "to_start_of",
            "parameters_list": ["hour"],
        }
    ],
    "aggregation": [{"aggregation": "avg"}],
    "include_time": True,
    "order_by": ["time"],
}

# Estimate cost before executing
cost_response = requests.post(cost_url, headers=headers, json=query)
cost_response.raise_for_status()
cost_info = cost_response.json()
print(f"Estimated cost: {cost_info['total_credits_needed']:.4f} credits")
print(f"Rows to return: {cost_info['total_rows_returned']}")
print(f"Rows to access: {cost_info['total_rows_accessed']}")

response = requests.post(url, headers=headers, json=query)
response.raise_for_status()

data = response.json()
df = pd.DataFrame(data)
print(f"Retrieved {len(df)} rows")
print(df.head(20))

Capacity Weighted Average in a Polygon

query = {
    "models": ["ept2"],
    "geo": {
        "type": "polygon",
        "value": [
            [
                [53.0, 8.0],
                [53.0, 12.0],
                [55.0, 12.0],
                [55.0, 8.0],
                [53.0, 8.0],
            ]
        ],
    },
    "variables": ["wind_speed_at_height_level_100m"],
    "init_time": "latest",
    "prediction_timedelta": {"start": 0, "end": 48},  # 2 days
    "weighting": {"type": "wind_capacity"},
    "group_by": [
        {
            "field": "time",
            "transformation": "to_start_of",
            "parameters_list": ["hour"],
        }
    ],
    "aggregation": [{"aggregation": "avg"}],
    "include_time": True,
    "order_by": ["time"],
}

# Estimate cost before executing
cost_response = requests.post(cost_url, headers=headers, json=query)
cost_response.raise_for_status()
cost_info = cost_response.json()
print(f"Estimated cost: {cost_info['total_credits_needed']:.4f} credits")
print(f"Rows to return: {cost_info['total_rows_returned']}")
print(f"Rows to access: {cost_info['total_rows_accessed']}")

response = requests.post(url, headers=headers, json=query)
response.raise_for_status()

data = response.json()
df = pd.DataFrame(data)
print(f"Retrieved {len(df)} rows")
print(df.head(20))

Last updated