import dascore as dc
= dc.get_example_patch()
patch # Add two dummy dimensions to patch named "end" and "stop"
= patch.append_dims("end", "stop")
new # Add a dummy dimension called "face" to end of patch
# which has a coordinate value of [1].
= patch.append_dims(face=[1])
new # Same thing as above, but with a larger coords which broadcasts
# the data to shape appropriate to mach coordinates.
= patch.append_dims(face=[1, 2])
new # Add a dummy dimension of length 3 to end of patch.
# the data to shape appropriate to mach coordinates.
= patch.append_dims(face=3) new
append_dims
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
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.