append_dims

function of dascore.proc.coords source

append_dims(
    patch: Patch ,
    *empty_dims ,
    **dim_kwargs ,
)-> ‘PatchType’

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.