smash.sparse_matrix_to_vector#

smash.sparse_matrix_to_vector(mesh, matrix)[source]#

Convert a NumPy 2D array to a 1D array respecting the order of the sparse storage.

Note

To avoid a memory overflow, the atmospheric forcings and simulated discharges can be sparse stored by precising it in the Model initialization setup dictionary (sparse_storage = True). It allows to store for each time step a 1D array whose size is the number of active cells instead of storing the whole rectangular domain. O(nrow * ncol) -> O(nac) with nac < nrow * ncol.

Parameters:
meshMeshDT, the Model mesh attributes (see Model.mesh).
matrixNumPy 2D array.

The 2D array to be converted

Returns:
vectorNumPy 1D array.

The 1D array respecting the order of the sparse storage.

Examples

>>> setup, mesh = smash.load_dataset("cance")
>>> model = smash.Model(setup, mesh)