aequilibrae.matrix.AequilibraeData#
- class aequilibrae.matrix.AequilibraeData[source]#
AequilibraE dataset
Methods
__init__
()create_empty
([file_path, entries, ...])Creates a new empty dataset
empty
(*args, **kwargs)export
(file_name[, table_name])Exports the dataset to another format.
load
(file_path)Loads dataset from file
Returns a random name for a dataset with root in the temp directory of the user
- create_empty(file_path=None, entries=1, field_names=None, data_types=None, memory_mode=False, fill=None, index=None)[source]#
Creates a new empty dataset
- Arguments:
file_path (
str
, Optional): Full path for the output data file. If memory_mode is ‘false’ and path is missing, then the file is created in the temp folderentries (
int
, Optional): Number of records in the dataset. Default is 1field_names (
list
, Optional): List of field names for this dataset. If no list is provided, the field ‘data’ will be createddata_types (
np.dtype
, Optional): List of data types for the dataset. Types need to be NumPy data types (e.g.np.int16
,np.float64
). If no list of types are provided, type will benp.float64
memory_mode (
bool
, Optional): IfTrue
, dataset will be kept in memory. IfFalse
, the dataset will be a memory-mapped numpy array
>>> from aequilibrae.matrix import AequilibraeData, AequilibraeMatrix >>> mat = AequilibraeMatrix() >>> mat.load('/tmp/test_project/matrices/demand.omx') >>> mat.computational_view() >>> vectors = "/tmp/test_project/vectors.aed" >>> args = { ... "file_path": vectors, ... "entries": mat.zones, ... "field_names": ["origins", "destinations"], ... "data_types": [np.float64, np.float64] ... } >>> dataset = AequilibraeData() >>> dataset.create_empty(**args)
- load(file_path)[source]#
Loads dataset from file
- Arguments:
file_path (
str
): Full file path to the AequilibraeData to be loaded
>>> from aequilibrae.matrix import AequilibraeData >>> dataset = AequilibraeData() >>> dataset.load("/tmp/test_project/vectors.aed")
- export(file_name, table_name='aequilibrae_table')[source]#
Exports the dataset to another format. Supports CSV and SQLite
- Arguments:
file_name (
str
): File name with PATH and extension (csv, or sqlite3, sqlite or db)table_name (
str
): It only applies if you are saving to an SQLite table. Otherwise ignored
>>> from aequilibrae.matrix import AequilibraeData >>> dataset = AequilibraeData() >>> dataset.load("/tmp/test_project/vectors.aed") >>> dataset.export("/tmp/test_project/vectors.csv")
- static random_name()[source]#
Returns a random name for a dataset with root in the temp directory of the user
>>> from aequilibrae.matrix import AequilibraeData >>> name = AequilibraeData().random_name() # This is an example of output # '/tmp/Aequilibrae_data_5werr5f36-b123-asdf-4587-adfglkjhqwe.aed'