squeeze

function of dascore.proc.coords source

squeeze(
    self: Patch ,
    dim = None,
)-> ‘PatchType’

Return a new object with len one dimensions flattened.

Parameters

Parameter Description
dim Selects a subset of the length one dimensions. If a dimension
is selected with length greater than one, an error is raised.
If None, all length one dimensions are squeezed.

Raises

CoordError If a selected dimension does not exist or has more than one sample. ParameterError If squeezing would remove every dimension from the patch.

Examples

import dascore as dc
import numpy as np
patch = dc.get_example_patch()

# Create a patch with a length-1 dimension by selecting time slice
time_array = patch.coords.get_array("time")
single_time = patch.select(time=(time_array[0], time_array[0]))

# Squeeze the length-1 time dimension
squeezed = single_time.squeeze(dim="time")