{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "One leg of the Swiss rail network, and how much lateness it gives back",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "from_bpuic",
    "to_bpuic",
    "category",
    "traversals_measured",
    "scheduled_run_median_s"
  ],
  "properties": {
    "from_bpuic": {
      "type": "string",
      "description": "Station number of the first stop, as the publisher records it (BPUIC).",
      "x-origin": "redistributed",
      "x-source": "src:opentransportdata-istdaten-v2"
    },
    "to_bpuic": {
      "type": "string",
      "description": "Station number of the second stop. The pair is ordered: this leg is one direction.",
      "x-origin": "redistributed",
      "x-source": "src:opentransportdata-istdaten-v2"
    },
    "from_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "Station name as the publisher delivers it. Their own note: it is the operator's string, not the official DiDok name, so the two can differ.",
      "x-origin": "redistributed",
      "x-source": "src:opentransportdata-istdaten-v2"
    },
    "to_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "The same for the second stop.",
      "x-origin": "redistributed",
      "x-source": "src:opentransportdata-istdaten-v2"
    },
    "category": {
      "type": "string",
      "description": "Train category, the publisher's VERKEHRSMITTEL_TEXT: IC, IR, RE, S, R and so on. Part of the class key, because stopping pattern and rolling stock differ by category over the same rails.",
      "x-origin": "redistributed",
      "x-source": "src:opentransportdata-istdaten-v2"
    },
    "traversals_measured": {
      "type": "integer",
      "description": "Trains that ran this leg in the window with a REAL departure at the first stop and a REAL arrival at the second. Every statistic below is over these.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "traversals_scheduled": {
      "type": "integer",
      "description": "Trains scheduled over this leg in the window, measured or not. The gap is coverage, not cancellation.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "traversals_impossible": {
      "type": "integer",
      "description": "Traversals dropped because the realised run time came out negative, which cannot happen. Non-zero here means the record disagrees with itself on this leg; see the README.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "scheduled_run_median_s": {
      "type": [
        "number",
        "null"
      ],
      "description": "Median scheduled running time, second stop's scheduled arrival minus first stop's scheduled departure. The publisher rounds scheduled times to the minute, so this is a multiple of 60 except where the median falls between two values.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "realised_run_median_s": {
      "type": [
        "number",
        "null"
      ],
      "description": "Median of the same quantity measured.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "realised_run_p01_s": {
      "type": [
        "number",
        "null"
      ],
      "description": "First percentile of realised running time, nearest rank. Used as an UPPER BOUND on the technical minimum, which is not observable. It is not a claim about how fast the train could go.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "slack_present_s": {
      "type": [
        "number",
        "null"
      ],
      "description": "scheduled_run_median_s minus realised_run_p01_s. How much longer the timetable allows than the fastest the trains are observed to do it. Slack PRESENT.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "absorption_best_s": {
      "type": [
        "number",
        "null"
      ],
      "description": "The largest median lateness this leg gives back, over entering-delay bins of one minute from 0 to 15 with at least 10 traversals. Slack USED, and a different quantity from slack present: the two differ in nine leg classes out of ten. Null means no bin qualified. Negative means that on the median this leg makes trains later.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "absorption_best_at_min": {
      "type": [
        "integer",
        "null"
      ],
      "description": "The entering delay, in whole minutes, at which that best absorption occurs.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "absorption_best_n": {
      "type": [
        "integer",
        "null"
      ],
      "description": "How many traversals were in that bin.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "on_time_rate": {
      "type": [
        "number",
        "null"
      ],
      "description": "Share of measured traversals arriving at the second stop under 180 seconds late. Six decimal places.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery"
    },
    "absorption_curve": {
      "type": "array",
      "description": "The whole curve, not just its maximum: one entry per entering-delay bin that had any traversals.",
      "x-origin": "built",
      "x-source": "src:aw-timetable-recovery",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "entered_late_min",
          "n",
          "median_delay_change_s"
        ],
        "properties": {
          "entered_late_min": {
            "type": "integer",
            "description": "Whole minutes late leaving the first stop, -1 to 15. -1 is early."
          },
          "n": {
            "type": "integer",
            "description": "Traversals in the bin."
          },
          "median_delay_change_s": {
            "type": [
              "number",
              "null"
            ],
            "description": "Median of (arrival delay at the second stop) minus (departure delay at the first). Negative is lateness given back."
          }
        }
      }
    }
  }
}
