getObject() returns the model building-block objects held in a container –
commodities, technologies, supplies, storages, and so on – selected by
class, name, description, region and/or any object slot.
It is the object-level counterpart of getData(), which returns those
objects' parameter data.
Usage
getObject(x, ...)
# Default S3 method
getObject(x, ...)
# S3 method for class 'repository'
getObject(
x,
class = NULL,
name = NULL,
desc = NULL,
region = NULL,
...,
regex = FALSE,
ignore.case = TRUE,
region_agnostic = TRUE,
drop = FALSE
)
# S3 method for class 'model'
getObject(
x,
class = NULL,
name = NULL,
desc = NULL,
region = NULL,
...,
regex = FALSE,
ignore.case = TRUE,
region_agnostic = TRUE,
drop = FALSE
)
# S3 method for class 'scenario'
getObject(
x,
class = NULL,
name = NULL,
desc = NULL,
region = NULL,
...,
regex = FALSE,
ignore.case = TRUE,
region_agnostic = TRUE,
drop = FALSE
)
# S3 method for class 'en_registry'
getObject(
x,
type = NULL,
name = NULL,
hash = NULL,
parent = NULL,
variant = NULL,
run = "main",
drop = FALSE,
verbose = FALSE,
...
)Arguments
- x
a
repository,modelorscenario.- ...
additional per-slot filters forwarded to the matching engine, e.g.
timeframe = "HOUR". Character filters are exact by default; a data.frame slot is filtered by named columns. Filtering by a slot implicitly restricts results to classes that have it.- class
character vector of object classes to keep (e.g.
"technology",c("supply", "import"));NULL(default) keeps all classes.- name
character, object name(s) to match against
@name.- desc
character, description pattern(s) to match against
@desc.- region
character, keep objects belonging to any of these regions. Region-agnostic objects (e.g. commodities, which carry no region) are kept for every region unless
region_agnostic = FALSE.- regex
logical; treat
name,descand character...filters as regular expressions instead of exact matches (defaultFALSE).- ignore.case
logical; case-insensitive matching for
regex = TRUE(defaultTRUE).- region_agnostic
logical; whether objects with no region information satisfy a
regionfilter (defaultTRUE).- drop
logical; if
TRUEand exactly one object matches, return that object itself instead of a one-element list (defaultFALSE).- type
character, registry row type(s) to load: "model", "repository", "scenario", "dataset".
NULL(default) loads every loadable type.- hash
character, content hash (prefix) selecting a stored version.
- parent, variant
character, extra registry filters (run bookkeeping).
- run
which run to activate in loaded scenarios:
"main"(default) keeps the scenario's own run, a character selects that run, andNULL,NAor"ALL"returns one entry per recorded run, keyedscenario/<name>:<variant>/<label>.- verbose
logical; report progress (the
en_registrymethod).
Value
A named list of model objects keyed by @name (empty list if none
match); or a single object when drop = TRUE and exactly one matches.
Details
Class, name, description and any other slot are matched by the same engine
that powers the internal object accessors; the region filter is applied
with get_region(), which reads regions uniformly from @region slots and
from the region/src/dst columns of data.frame slots, so it works for
every class (including import/export/trade, which store region
structurally). A scenario is unwrapped to its model automatically.
Examples
if (FALSE) { # \dontrun{
repo <- topia$modules$electricity$R3$repo
getObject(repo, class = "technology") # all technologies
getObject(repo, class = c("supply", "commodity")) # two classes
getObject(repo, region = "R1") # everything in R1
getObject(repo, name = "ECOA", drop = TRUE) # the ECOA object
getObject(repo, desc = "coal", regex = TRUE) # by description
getObject(repo, class = "technology", timeframe = "HOUR") # slot filter
} # }
