Observer class for OSP snapshot observer sets
Observer.RdAn R6 class that represents a single observer inside an ObserverSet. An observer is a simulation-time formula that computes a derived quantity from the underlying model (for example an amount observer or a container observer), used to expose values that are not natural model outputs.
In an OSP snapshot, each observer is one entry of the Observers
array nested inside an ObserverSets building block. An observer is
not itself a building block; it lives inside an ObserverSet.
Active bindings
dataThe raw
Observerlist as it appears in the snapshot JSON (read-only).nameThe name of the observer. Writable: must be a non-empty scalar string.
typeThe observer type. PK-Sim recognises
"Amount"(anAmountObserverBuilder) and"Container"(aContainerObserverBuilder). On assignment, a non-NULLvalue is validated against these two; assigningNULLremoves the type.dimensionThe dimension of the observed quantity, resolved in PK-Sim via
IDimensionRepository.DimensionByName(). Writable: must be a non-empty scalar string, orNULLto clear. There is no closed set of dimension names to validate against, so a required string is the strongest check available.formulaThe full
ExplicitFormulaobject backing the observer, as a list withName,Formula(the expression string),Dimension, andReferences(a list ofFormulaUsablePathentries, each withAlias,Path, andDimension).NULLwhen the observer carries no formula. Setting this field replaces the whole structure; passNULLto drop it. For the inner expression string or dimension only, useformula_expressionorformula_dimension.formula_expressionThe expression string of the underlying
ExplicitFormula(Formula$Formulain the snapshot JSON). Setting writes back to the innerFormula$Formulafield and preserves the siblingName,Dimension, andReferencesentries. To build a completeExplicitFormula(includingNameandReferences), assign toformulainstead.formula_dimensionThe output dimension of the underlying
ExplicitFormula(Formula$Dimensionin the snapshot JSON), resolved in PK-Sim viaIDimensionRepository.DimensionByName(). Setting writes back to the innerFormula$Dimensionfield.formula_referencesThe
Referenceslist of the underlyingExplicitFormula, where each entry is a named list withAlias,Path, andDimension. Assign a list ofcreate_formula_reference()outputs (or raw{Alias, Path, Dimension}lists) to replace it, preserving the siblingFormula$Name,Formula$Formula, andFormula$Dimension(theFormulais created if absent). AssignNULLto remove the references; when noFormulaexists this is a no-op that does not create an emptyFormula.container_tagsThe
Tagvalues from the observer'sContainerCriteria, joined with|. There is noContainerPathfield in the snapshot JSON; this binding is synthesized from the tags found inContainerCriteria.NULLwhen the observer carries no container criteria.container_criteriaThe full
ContainerCriterialist, each entry a named list withTagand (optionally)Type. Unlikecontainer_tags, this preserves each condition'sTypeverbatim (including non-enum values such as"MatchTag"). Assign a list ofcreate_descriptor_condition()outputs (or raw{Tag, Type}lists) to replace it; assignNULLto remove it.molecule_listThe full
MoleculeListobject (ForAll,MoleculeNamesToInclude,MoleculeNamesToExclude) orNULL. Assign acreate_molecule_list()output (or an equivalent raw list) to replace it; assignNULLto remove it.
Methods
Observer$new()
Create a new Observer object.
Observer$to_df()
Convert the observer to a single-row tibble suitable for the
tibble-layer exporter. Columns are name, type, dimension,
formula_expression, formula_dimension, formula_references,
and container_tags. formula_references collapses each
FormulaUsablePath entry (Alias, Path, Dimension) to
"alias=path" and joins entries with |; NA when the observer
carries no references.
Examples
observer <- Observer$new(list(
Name = "brain_plasma_conc",
Type = "Container",
Dimension = "Concentration (molar)",
Formula = list(
Name = "brain_plasma_conc_formula",
Formula = "Conc_Br",
Dimension = "Concentration (molar)",
References = list(list(
Alias = "Conc_Br",
Path = "Organism|Brain|Plasma|Drug|Concentration",
Dimension = "Concentration (molar)"
))
)
))
observer$name
#> [1] "brain_plasma_conc"
observer$type
#> [1] "Container"
observer$formula_expression
#> [1] "Conc_Br"
observer$formula_dimension
#> [1] "Concentration (molar)"
observer$formula_references
#> [[1]]
#> [[1]]$Alias
#> [1] "Conc_Br"
#>
#> [[1]]$Path
#> [1] "Organism|Brain|Plasma|Drug|Concentration"
#>
#> [[1]]$Dimension
#> [1] "Concentration (molar)"
#>
#>