Skip to main content

Python SDK for the Jiskta Climate Data API

Project description

jiskta-python

Python SDK for the Jiskta Climate Data API — query historical air quality data (NO₂, PM2.5, PM10, O₃) and ERA5 meteorological data via a simple Python interface.

Install

pip install jiskta

Pandas is optional but recommended:

pip install "jiskta[pandas]"

Quick start

from jiskta import JisktaClient

client = JisktaClient(api_key="sk_live_...")

# Daily NO₂ and PM2.5 over Paris in 2023
df = client.query(
    lat=(48.7, 49.0),
    lon=(2.2, 2.5),
    start="2023-01",
    end="2023-12",
    variables=["no2", "pm2p5"],
    aggregate="daily",
)
print(df.head())
#         lat    lon        date  no2_mean  pm2p5_mean
# 0  48.7500  2.250  2023-01-01     12.34        8.21
# ...

All parameters

df = client.query(
    lat=(lat_min, lat_max),      # bounding box
    lon=(lon_min, lon_max),
    start="YYYY-MM-DD",          # or "YYYY-MM"
    end="YYYY-MM-DD",
    variables=["no2"],          # no2 | pm2p5 | pm10 | o3
    aggregate="daily",           # hourly | daily | monthly | annual
                                 # area_hourly | area_daily | area_monthly
                                 # diurnal | exceedance | percentile
    threshold=40.0,              # µg/m³  (exceedance mode)
    percentile=95,               # 0-100  (percentile mode)
)

Summary statistics (no DataFrame)

result = client.stats(
    lat=(48.7, 49.0),
    lon=(2.2, 2.5),
    start="2023-01",
    end="2023-01",
    variables=["no2"],
)
print(result["output"])

Error handling

from jiskta import JisktaClient, AuthError, InsufficientCreditsError, RateLimitError, JisktaError

try:
    df = client.query(...)
except AuthError:
    print("Invalid API key")
except InsufficientCreditsError:
    print("Buy more credits at https://jiskta.com/pricing")
except RateLimitError:
    print("Server busy, retry later")
except JisktaError as e:
    print(f"API error {e.status_code}: {e}")

Named area queries

Skip lat/lon by passing a named region:

df = client.query(
    area="paris",
    start="2023-01",
    end="2023-12",
    variables=["no2"],
    aggregate="daily",
)

result = client.stats(area="belgium", start="2023-01", end="2023-12")

Supported names depend on the API (e.g. "paris", "france", "belgium").

New aggregates

# Statistical aggregates
df = client.query(..., aggregate="max")       # daily/monthly max
df = client.query(..., aggregate="min")       # daily/monthly min
df = client.query(..., aggregate="stddev")    # standard deviation
df = client.query(..., aggregate="cumulative")  # running total (e.g. precipitation)

# Analytical aggregates
df = client.query(..., aggregate="seasonal")  # DJF/MAM/JJA/SON means
df = client.query(..., aggregate="trend")     # linear trend per grid cell

Wind variables

wind_speed and wind_dir are derived ERA5 variables (computed from u10/v10):

df = client.query(
    lat=(48.7, 49.0), lon=(2.2, 2.5),
    start="2023-01", end="2023-12",
    variables=["wind_speed", "wind_dir"],
    aggregate="daily",
)

Polygon-masked queries

Pass any GeoJSON Polygon or MultiPolygon geometry to restrict results to cells whose centres fall inside the polygon:

mask = {
    "type": "Polygon",
    "coordinates": [[[2.2, 48.7], [2.5, 48.7], [2.5, 49.0], [2.2, 49.0], [2.2, 48.7]]],
}

df = client.query_with_mask(
    lat_min=48.7, lat_max=49.0,
    lon_min=2.2, lon_max=2.5,
    start="2023-01",
    end="2023-12",
    variables=["no2"],
    aggregate="daily",
    mask=mask,
)

Advanced options

df = client.query(
    lat=(48.7, 49.0), lon=(2.2, 2.5),
    start="2023-01", end="2023-12",
    variables=["no2"],
    sort_by="no2_mean",       # sort CSV output by column
    sort_dir="desc",          # "asc" or "desc"
    unit="ppb",               # convert output units
    round=2,                  # decimal places
    dry_run=True,             # cost estimate only — no query executed
    missing_null=True,        # empty string for missing cells
    include_polygon=True,     # include area_polygon GeoJSON in raw response
)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jiskta-0.5.2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jiskta-0.5.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file jiskta-0.5.2.tar.gz.

File metadata

  • Download URL: jiskta-0.5.2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for jiskta-0.5.2.tar.gz
Algorithm Hash digest
SHA256 a33760c3b5a13480b7986c67548df1fc2e1b622feebbff95acc47730ac5b7bb9
MD5 d475f9ef05b556814599088f3253688c
BLAKE2b-256 fe3bff37114ff8f8f155c3e2b5fe0ff71783cbe410c5e5a5e59cccfabafb23cf

See more details on using hashes here.

File details

Details for the file jiskta-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: jiskta-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for jiskta-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0e60073c53ab8444f676d5ee616f9bcfe84c8709c758585d1d3022dda0d29f
MD5 9a74d85e3510f458ecc98ce69b27b1b1
BLAKE2b-256 bf32ee1779e2c83c2118ef40b98f0d85293a0f7e1e38ea9c11d1a57c93eb980c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page