{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/ringsaturn/xue/blob/main/docs/schemas/aq-line.schema.json",
  "title": "AqLine",
  "description": "One line of aq.<round>/<network>.jsonl: a station and its window of hourly means (docs/aq.md section 6). That time is strictly increasing, that every obs array is as long as time and that obs keys are element keys are the readers' own checks.",
  "type": "object",
  "required": ["id", "lat", "lon", "rank", "time", "obs"],
  "properties": {
    "id": {"type": "string", "pattern": "^[a-z][a-z0-9]*(-[a-z0-9]+)*:[0-9A-Za-z_.-]+$"},
    "name": {"type": ["string", "null"]},
    "names": {
      "description": "BCP 47 language tag to the network's own spelling.",
      "type": ["object", "null"],
      "additionalProperties": {"type": "string"}
    },
    "lat": {"type": "number", "minimum": -90, "maximum": 90},
    "lon": {"type": "number", "minimum": -180, "maximum": 180},
    "elev": {"type": ["number", "null"], "minimum": -500, "maximum": 9000},
    "rank": {"enum": [0, 1, 2]},
    "agency": {"type": ["string", "null"]},
    "time": {
      "description": "Epoch seconds UTC, the end of each hour, oldest first.",
      "type": "array",
      "minItems": 1,
      "items": {"type": "integer", "minimum": 0}
    },
    "obs": {
      "description": "One array per element the station reported in the window, null where it did not report that hour. The elements of docs/aq.md section 2 keep their ranges; another element is only held to be a number.",
      "type": "object",
      "properties": {
        "pm25": {"$ref": "#/$defs/Pm"},
        "pm10": {"$ref": "#/$defs/Pm"},
        "o3": {"type": "array", "items": {"type": ["number", "null"], "minimum": -5, "maximum": 1000}},
        "no2": {"type": "array", "items": {"type": ["number", "null"], "minimum": -5, "maximum": 2000}},
        "so2": {"type": "array", "items": {"type": ["number", "null"], "minimum": -5, "maximum": 5000}},
        "co": {"type": "array", "items": {"type": ["number", "null"], "minimum": -0.5, "maximum": 100}}
      },
      "additionalProperties": {"type": "array", "items": {"type": ["number", "null"]}}
    }
  },
  "$defs": {
    "Pm": {
      "description": "A particle mass concentration, µg/m³.",
      "type": "array",
      "items": {"type": ["number", "null"], "minimum": -5, "maximum": 10000}
    }
  }
}
