Skip to content

Lab data API: AeroViz.fetch

Hourly data from the lab's stations, straight from the AeroViz website's database into a pandas DataFrame — no raw files, no reader. It is for members of the lab only: every request needs a personal key, and a key works only while its holder has the Data API permission.

AeroViz.fetch only fetches. It does not read raw files, analyse, plot or write anything back. It is not imported by import AeroViz; import it explicitly.

Get a key

  1. On the website, open Data Center → Data API and apply for access.
  2. Once an administrator approves it, create a key on the same page. The key is shown once — copy it then. Keys expire; create a new one when it does.
  3. Keep it in environment variables, never in code or in git:
export AEROVIZ_API_KEY="<your key>"
export AEROVIZ_API_URL="<website address>"

AEROVIZ_API_URL is the website's root address (the Data API page shows it), with no path. Both can also be passed to Client(api_key=..., base_url=...).

Use

from AeroViz.fetch import Client

client = Client()

client.stations()                       # stations and their instruments
client.variables("NZ", "BC1054")        # names, units, wavelengths, data period

df = client.timeseries("FS", "AE33", ["bc_880nm", "ebc"],
                       start="2025-01-01", end="2025-12-31")
df.to_csv("FS_AE33.csv")
Item Meaning
variables A list or a single name; omit for every variable of the instrument
start, end YYYY-MM-DD strings or dates, Taipei time; end is inclusive
Index time, Asia/Taipei; each row is labelled with the start of its hour
Missing NaN: no valid data in that hour (including hours still in the future)
Long ranges Over 366 days are fetched in pieces and joined
Rate limits On HTTP 429 it waits as the server asks and retries, up to 3 times

Variable names are the same across instruments for the same quantity — bc_880nm is BC6 on an AE33 and BC9 on a BC1054. The server owns the list; client.variables() shows what a station has.

df.attrs carries units, time_label and notes. pandas does not always keep attrs through merges and other operations; save them first if needed.

Usage notes

Some stations, instruments and periods have known problems. When the data you fetch overlaps one, a DataNote warning is raised — read it before analysing. Once checked:

import warnings
from AeroViz.fetch import DataNote

warnings.filterwarnings("ignore", category=DataNote)

Errors

All inherit from FetchError; status_code holds the HTTP status (None when no response arrived). The message is the server's own explanation.

Exception Cause
AuthError Key invalid, expired or revoked; no Data API permission; account disabled
BadRequest Unknown station, instrument or variable — the message lists the valid ones
RateLimited Still over a rate limit after retrying
ConnectionFailed Server unreachable or timed out
ServerError The server failed; report it to an administrator

Missing settings and malformed dates raise ValueError / TypeError before any request is sent.