cf.DimensionCoordinate.anchor¶
- DimensionCoordinate.anchor(value, cell=False, parameters=None, inplace=False)[source]¶
Anchor the coordinate values.
By default, the coordinate values are transformed so that the first coordinate is the closest to value from above (below) for increasing (decreasing) coordinates.
If the cell parameter is True, then the coordinate values are transformed so that the first cell either contains value; or is the closest to cell to value from above (below) for increasing (decreasing) coordinates.
Added in version 3.16.3.
- Parameters:
- value: scalar array_like
Anchor the coordinate values for the selected cyclic axis to the value. May be any numeric scalar object that can be converted to a
Data
object (which includesnumpy
andData
objects). If value has units then they must be compatible with those of the coordinates, otherwise it is assumed to have the same units as the coordinates.The coordinate values are transformed so the first coordinate is the closest to value from above (for increasing coordinates), or the closest to value from above (for decreasing coordinates)
Increasing coordinates with positive period, P, are transformed so that value lies in the half-open range (L-P, F], where F and L are the transformed first and last coordinate values, respectively.
Decreasing coordinates with positive period, P, are transformed so that value lies in the half-open range (L+P, F], where F and L are the transformed first and last coordinate values, respectively.
- Parameter example:
If the original coordinates are
0, 5, ..., 355
(evenly spaced) and the period is360
thenvalue=0
implies transformed coordinates of0, 5, ..., 355
;value=-12
implies transformed coordinates of-10, -5, ..., 345
;value=380
implies transformed coordinates of380, 385, ..., 735
.- Parameter example:
If the original coordinates are
355, 350, ..., 0
(evenly spaced) and the period is360
thenvalue=355
implies transformed coordinates of355, 350, ..., 0
;value=0
implies transformed coordinates of0, -5, ..., -355
;value=392
implies transformed coordinates of390, 385, ..., 35
.
- cell:
bool
, optional If True, then the coordinate values are transformed so that the first cell either contains value, or is the closest to cell to value from above (below) for increasing (decreasing) coordinates.
If False (the default) then the coordinate values are transformed so that the first coordinate is the closest to value from above (below) for increasing (decreasing) coordinates.
- parameters:
dict
, optional If a
dict
is provided then it will be updated in-place with parameters which describe the anchoring process.- inplace:
bool
, optional If True then do the operation in-place and return
None
.
- Returns:
DimensionCoordinate
orNone
The anchored dimension coordinates, or
None
if the operation was in-place.