Source code for pycif.plugins.obsvects.standard.ini_mapper
[docs]
def ini_mapper(obsvect, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform="", **kwargs):
"""Build the transform mapper for the observation vector.
Scans the datavect components and collects every ``(component, tracer)``
pair whose ``isobs`` flag is ``True``. These pairs become the output
tracer IDs of the observation operator — i.e. the quantities that the
``toobsvect`` system transform will write into ``obsvect.ysim``.
Args:
obsvect (Plugin): obsvect plugin instance (carries the populated
``datavect`` with component/tracer metadata).
general_mapper (dict): mapper dictionaries from other transforms;
unused but accepted for interface consistency.
backup_comps (dict): unused; accepted for interface consistency.
transforms_order (list): unused; accepted for interface consistency.
ref_transform (str): unused; accepted for interface consistency.
**kwargs: unused.
Returns:
dict: mapper dict with ``"inputs": {}`` (observation vector has no
inputs from other transforms) and ``"outputs": {(comp, trcr): …}``
for every observation tracer.
"""
# Output dictionary
obs_outputs = {}
components = obsvect.datavect.components
for comp in components.attributes:
component = getattr(components, comp)
# Skip if component does not have parameters
if not hasattr(component, "parameters"):
continue
for trcr in component.parameters.attributes:
tracer = getattr(component.parameters, trcr)
if tracer.isobs:
obs_outputs[(comp, trcr)] = {"isobs": True}
# Executable
mapper = {
"inputs": {},
"outputs": obs_outputs,
}
return mapper