SqueezeCoords

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

SqueezeCoords(
    *args ,
    coords: tuple[Any, …] = (),
)-> None

Move non-dimensional coordinates holding one value into the attrs.

Each coordinate is dropped and its value stored as an attribute of the same name; units are not kept and dimensions are never touched.

Parameters

Parameter Description
*coords The coordinates to squeeze, as names or sequences of them. If none
are given, every non-dimensional coordinate whose values are all one
non-null value is squeezed, skipping private coordinates and names
the attrs reserve.

Raises

CoordError If a named coordinate is absent, a dimension, private, reserved by the attrs, or not one non-null value throughout.

Examples

import numpy as np
import dascore as dc
patch = dc.get_example_patch()
ones = np.ones(patch.coord_shapes["distance"])
patch = patch.update_coords(quality=("distance", ones))
out = patch.squeeze_coords()
assert "quality" not in out.coords.coord_map
assert out.attrs["quality"] == 1

Methods

Name Description
check Refuse a patch which does not carry what the operation needs.
get_metadata Return the coordinates without the squeezed ones, and the new attrs.
model_copy Copy the model, dropping cached values the update invalidates.
new Create new instance with some attributed updated.
squeeze_coords Move non-dimensional coordinates holding one value into the attrs.
reconcile Return metadata or a patch holding the final data; default as is.
run Run the operation: check, get_metadata, kernel, reconcile, record.