AppendDims

class of dascore.proc.coords
inherits from: PatchProcessor, DascoreBaseModel, pydantic.main.BaseModel
source

AppendDims(
    *args ,
    **kwargs ,
)-> None

Insert dimensions at the end of the patch.

Parameters

Parameter Description
*empty_dims Used to pass the name of empty dimensions.
**dim_kwargs Used to pass keys (new dim names) and values. Values can either be
an int specifying the length of the new dimension or a sequence
specifying the coordinate values. If an int is used, the new dimension
will be a non-coordinate dimension.

Examples

import dascore as dc
patch = dc.get_example_patch()

# Add two dummy dimensions to patch named "end" and "stop"
new = patch.append_dims("end", "stop")

# Add a dummy dimension called "face" to end of patch
# which has a coordinate value of [1].
new = patch.append_dims(face=[1])

# Same thing as above, but with a larger coords which broadcasts
# the data to shape appropriate to mach coordinates.
new = patch.append_dims(face=[1, 2])

# Add a dummy dimension of length 3 to end of patch.
# the data to shape appropriate to mach coordinates.
new = patch.append_dims(face=3)
Note
  • This tries to be more simple than numpy and xarray’s expand_dims.
  • Use Patch.transpose to re-arrange dimensions.
  • If dimension with the same name already exists nothing will happen.

Methods

Name Description
check Refuse a patch which does not carry what the operation needs.
get_metadata Return the longer coordinates, and the shape they describe.
kernel Return the data stretched over the dimensions which were added.
new Create new instance with some attributed updated.
append_dims Insert dimensions at the end of the patch.
reconcile Return the result’s metadata once the data are known; default as is.
run Run the operation: check, get_metadata, kernel, reconcile, record.