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(
self ,
inventory: ‘Inventory’ ,
attrs: ‘bool | tuple[str, …]’ = True,
coords: ‘bool | tuple[str, …]’ = True,
acquisition_key: ‘str | None’ = None,
time = None,
on_missing: ‘ON_MISSING’ = raise,
conflict: ‘ENRICH_CONFLICT’ = raise,
)-> ‘Self’
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 |
|---|---|
| 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 is every scalar field of the resolved acquisition (and of its interrogator) except data_typeand data_units, which describe the data as it now stands ratherthan the system, and sample_rate and spatial_interval, which thepatch’s own coordinates already state and a decimated patch would contradict. Naming one of those four asks for the as-acquired value; whether it lands over one the patch already states is conflict’sbusiness, as it is for every other name. |
| coords |
True (the default) to add the geometry axes and label groups of the resolved optical path, a tuple of names to add exactly those, or False to add none. The blanket form adds the geometry axes, named as the inventory’s CRS names them ( x, y, z when the inventorykeeps the default CRS), the label groups, and coupling, whosevalues are the coupling type of each channel. Names may be distancefor optical distance, one of the axes the inventory’s CRS names, a label group, a typed track ( coupling, geometry,optical_components), or a qualified track field such ascoupling.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; the marker never replaces a value the patch already states. Blanket requests copy what is applicable and never trigger it, and per-channel coverage gaps are always missing values rather than errors. |
| conflict |
What to do when an attr the patch states disagrees with the inventory. An attr either side leaves unset (None, NaN, ““) never conflicts: the patch’s is filled and the inventory’s is ignored, under every policy. Numbers equal up to float rounding agree. ”raise” (default) raises a PatchError, since a disagreement usually means the acquisition_key resolved to the wrong place.“keep_first” keeps the patch’s value, “keep_last” takes the inventory’s to correct the file, and “drop” removes the attr. |