DropCoords

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

DropCoords(
    *args ,
    coords: tuple[Any, …] = (),
    to_attrs: bool = False,
)-> None

Drop one or more non-dimensional coordinates.

Parameters

Parameter Description
*coords One or more coordinates to drop. Each can be a coordinate name or
a sequence of them.
to_attrs If True, store each dropped coordinate’s value as an attribute of
the same name; each must hold one non-null value throughout, and
its units are not kept. With no names given, every non-dimensional
coordinate holding one value moves, skipping private coordinates
and names the attrs reserve.

Raises

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

Examples

import numpy as np
import dascore as dc
pa = dc.get_example_patch("random_patch_with_lat_lon")
# Drop non-dimensional coordinate latitude
pa_no_lat = pa.drop_coords("latitude")
# A sequence of names works as well.
pa_no_lat = pa.drop_coords(["latitude"])
# Move a coordinate holding one value into the attrs.
ones = np.ones(pa.coord_shapes["distance"])
out = pa.update_coords(quality=("distance", ones)).drop_coords(
    "quality", to_attrs=True
)
assert out.attrs["quality"] == 1

Methods

Name Description
check Refuse a patch which does not carry what the operation needs.
chunk_contract Return what a chunk of the output needs of the input, or None.
get_metadata Return the coordinates which survive; a dimension cannot go.
halo Return how far along an axis the kernel reads to fill a sample.
model_copy Copy the model, dropping cached values the update invalidates.
new Create new instance with some attributed updated.
drop_coords Drop one or more non-dimensional coordinates.
reconcile Return metadata or a patch holding the final data; default as is.
run Run the operation: check, get_metadata, kernel, reconcile, record.