Skip to content

data_sources

Declared CSV/Excel/SQLite/SQL/JSON sources model parameters can be read from.

In the model file this key holds a list of data_source entries, each named by its name.

Typical uses

These sections connect a model to data. data_sources declare where data lives: a CSV or Excel file, a database, a web address, or a live plant connection. data_bindings read a column from a source, reduce it, and write the result into a model parameter. initial_state starts a run from a snapshot of a real system instead of an empty one.

Behaviour and rules

A binding names a source, a column, an optional filter and a transform, such as mean, last, table or fit. Its target is an override path such as resources.Nurse.capacity. A binding whose target does not exist is an error. A disabled binding leaves the parameter at its file value. A filter holds comparisons only, never code.

A model never holds an address or a credential. For a live source, connection names an entry in the connections file of whoever runs the model. A file path is relative to the model file. Network access, redirects and the size of what is read are limited, and the caller, not the file, decides whether the network may be used.

An initial_state places entities in blocks, sets variables, levels and resource states, and sets the clock. Statistics then cover the run from that clock, as after a warm-up of that length. A state that names a block the model does not have is an error. The schedule_offset makes a mid-shift start resume the shift.

Fields

Field Type Required Default Unit Description
name string yes The source's name, the source of a binding.
kind choice yes The kind of source, which decides how its location is read. One of csv, xlsx, sqlite, sql, json_url, rest, mqtt, opcua, modbus.
location string yes Path relative to the model file, or a URL. For a live kind: what to read over the connection (a path), never a host.
connection string Live kinds only: the NAME of a connection the person running the model defined in their own connections file. A model never holds an address or a credential.
query string SELECT, for the sqlite/sql kinds.
sheet string Worksheet name, for the xlsx kind.
options object Extra keyword arguments for the pandas reader; for a live kind, that reader's own options.
description string What the source holds; the run does not read it.

A field of a nested object is described in the JSON Schema (naga schema).

Example

{"data_sources": [{"name": "Arrivals", "kind": "csv", "location": "arrivals.csv"}]}

In the Python builder:

from nagasim import build as nb
m = nb.Model()
m.add_data_source(name='Arrivals', kind='csv', location='arrivals.csv')

Used in

Bundled models: Berth: shore power, Hub day: electrifying the ground support equipment, Container terminal: electrification, Container terminal: quay to yard, Hub day: turnaround workload (crews, ground equipment, on-time departures), Walk-in clinic digital twin.

Guides: Live data, Model file format, Digital twin, Semantic diff.

See also