import dascore as dc
from dascore.examples import inventory_patch_pair
patch, inventory = inventory_patch_pair()
# Copy everything applicable.
enriched = patch.enrich(inventory)
# Or name what is wanted.
enriched = patch.enrich(
inventory, attrs=("gauge_length",), coords=("x", "y", "z"),
)enrich
enrich(
patch: Patch ,
inventory: Inventory ,
attrs: bool | tuple[bool, tuple[str, …]] = True,
coords: bool | tuple[bool, tuple[str, …]] = True,
acquisition_key: str | None[str, None] = None,
time = None,
on_missing: Literal[‘raise’, ‘warn’, ‘ignore’, ‘null’] = raise,
conflict: Literal[‘drop’, ‘raise’, ‘keep_first’] = keep_first,
)-> ‘PatchType’
Copy inventory metadata onto a patch.
The patch resolves its inventory context from its acquisition_key and its time, then the acquisition’s channel map places each channel on the optical path so the path’s tracks can be projected onto it. The patch keeps no reference to the inventory afterwards.
Parameters
| Parameter | Description |
|---|---|
| patch | The patch to enrich. |
| inventory | The inventory to resolve against. |
| attrs |
True (the default) to copy the observing-system facts the inventory is authoritative for, a tuple of names to copy exactly those, or False to copy none. The blanket form excludes data_type,data_category, and data_units, which describe the data as itnow stands, and sample_rate and spatial_interval, which thepatch’s own coordinates already state; naming one restores the as-acquired value. |
| coords |
True (the default) to add the geometry axes and annotation groups of the resolved optical path, a tuple of names to add exactly those, or False to add none. Names may be distance for optical distance, acoordinate label the inventory’s CRS defines, an annotation group, or a qualified track field such as coupling.medium.
|
| acquisition_key |
The inventory identity to resolve, for a patch which does not carry one. Given both, the patch and this argument must agree. |
| time |
The instant to resolve at, for a patch whose time axis is not physical. A patch with a real time coordinate resolves at its own time and passing this raises. |
| on_missing |
What to do when an explicitly requested name is one the inventory does not define: “raise” (the default), “warn” to say so and leave it off, “ignore” to leave it off silently, or “null” to fill the dtype-appropriate missing marker so the name is present either way. Blanket requests copy what is applicable and never trigger it, and per-channel coverage gaps are always missing values rather than errors. |
| conflict |
Indicates how to handle conflicts in attributes other than those indicated by dim (eg tag, history, acquisition_key, etc). If “drop” simply drop conflicting attributes, or attributes not shared by all models. If “raise” raise an [AttributeMergeError]( dascore.exceptions.AttributeMergeError] whenissues are encountered. If “keep_first”, just keep the first value for each attribute. Enrichment combines the inventory’s values with the patch’s own, so the default keep_first lets the inventory win and re-enriching isa refresh. raise is the misresolution guard: a header disagreeingwith the resolved acquisition usually means the acquisition_keyresolved to the wrong place. |