Regional Queries

Countries & Market Zones

Country

query = {
    "models": ["ept2"],
    "geo": {
        "type": "country_key",
        "value": "CH",  # Switzerland
    },
    "variables": ["air_temperature_at_height_level_2m"],
    "init_time": "latest",
    "prediction_timedelta": [0, 24, 48],  # 0, 1 day, 2 days
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# 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']}")

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for Switzerland")
print(df.head())

Market Zone

query = {
    "models": ["ept2"],
    "geo": {
        "type": "market_zone",
        "value": ["GB-NIR"],  # Ireland and Northern Ireland
    },
    "variables": ["wind_speed_at_height_level_100m"],
    "init_time": "latest",
    "prediction_timedelta": [0, 24],  # 0 and 1 day ahead
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# 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']}")

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for Ireland and Northern Ireland")
print(df.head())
return df

Bounding Boxes

query = {
    "models": ["ept2"],
    "geo": {
        "type": "bounding_box",
        "value": [
            [
                [45.8, 5.9],  # [lat_min, lon_min] - Southwest corner
                [47.8, 10.5],  # [lat_max, lon_max] - Northeast corner
            ]
        ],  # Switzerland region
    },
    "variables": ["air_temperature_at_height_level_2m"],
    "init_time": "latest",
    "prediction_timedelta": [0],  # IC only
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# 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']}")

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 150}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for bounding box")
print(df.head())
return df

Polygons

query = {
    "models": ["ept2"],
    "geo": {
        "type": "polygon",
        "value": [
            [
                [47.3, 8.0],  # Southwest corner
                [47.6, 8.0],  # Northwest corner
                [47.6, 8.8],  # Northeast corner
                [47.3, 8.8],  # Southeast corner
                [47.3, 8.0],  # Close the polygon (same as first point)
            ]
        ],  # Polygon around Zurich region
    },
    "variables": [
        "air_temperature_at_height_level_2m",
    ],
    "init_time": "latest",
    "prediction_timedelta": [0],  # IC only
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# 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']}")

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for polygon")
print(df.head())
return df

Last updated