Load simulations from a snapshot file
Source:R/utilities-snapshots.R
loadSimulationsFromSnapshot.RdLoads the simulations stored in a snapshot file and returns them as a list of
Simulation objects. By default every simulation in the snapshot is loaded.
When simulationNames are supplied, only the simulations whose name matches
(case-sensitive) are returned. By default, an error is thrown if any of the
requested names is not present in the snapshot. Set ignoreIfNotFound = TRUE
to instead return NULL for the names that were not found.
Arguments
- snapshotFile
Character string, path to the snapshot file (
.json).- simulationNames
Optional character vector of simulation names to load. If
NULL(default), all simulations in the snapshot are loaded.- ignoreIfNotFound
Logical. If
FALSE(default), an error is thrown when any of the requestedsimulationNamesis not found in the snapshot. IfTRUE, missing names are returned asNULLentries instead. Has no effect whensimulationNamesisNULL.
Value
A named list of Simulation objects, with names being the simulation
names. When simulationNames is supplied, the returned list keeps the order
of the requested names; with ignoreIfNotFound = TRUE, entries for names
that were not found are NULL.
Examples
snapshotPath <- system.file("extdata", "test_snapshot.json", package = "ospsuite")
# Load every simulation from a snapshot
simulations <- loadSimulationsFromSnapshot(snapshotPath)
# Load only a specific simulation by name
firstName <- simulations[[1]]$name
oneSimulation <- loadSimulationsFromSnapshot(
snapshotPath,
simulationNames = firstName
)