Data Loading¶
data
¶
Data loading utilities for tramway simulations.
This module provides helper functions to load input data used in the simulation pipeline. In particular, it focuses on loading time-position profiles describing a train run.
The expected input format is intentionally simple to facilitate integration with external tools (e.g. MATLAB, Excel, or measurement systems).
load_train_run(path)
¶
Load a train trajectory from a text file.
The input file is expected to contain at least two columns:
- time in seconds,
- position in meters.
Additional columns are ignored. The function validates the data to ensure consistency with the assumptions made in the simulation pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a text file containing the train trajectory. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: Two arrays:
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
ValueError
|
If the file format is invalid, contains insufficient data, or if time is not strictly increasing. |
Notes
- Time must be strictly increasing because it is used to compute derivatives (speed and acceleration) via numerical differentiation.
- At least two samples are required to perform gradient-based computations.
- The function relies on
numpy.loadtxt, so the file must contain numeric values only.
Examples:
>>> time_s, position_m = load_train_run("data/train_run.txt")
>>> time_s.shape
(1000,)
>>> position_m.shape
(1000,)