podpac.coordinates.Coordinates1d

class podpac.coordinates.Coordinates1d(name=None, ctype=None, segment_lengths=None)[source]

Bases: podpac.core.coordinates.base_coordinates.BaseCoordinates

Base class for 1-dimensional coordinates.

Coordinates1d objects contain values and metadata for a single dimension of coordinates. Coordinates and StackedCoordinates use Coordinate1d objects.

The following coordinates types (ctype) are supported:

  • ‘point’: each coordinate represents a single location

  • ‘left’: each coordinate is the left endpoint of its segment

  • ‘right’: each coordinate is the right endpoint of its endpoint

  • ‘midpoint’: segment endpoints are at the midpoints between coordinate values.

The bounds are always the low and high coordinate value. For point coordinates, the area_bounds are the same as the bounds. For segment coordinates (left, right, and midpoint), the area_bounds include the portion of the segments above and below the ``bounds`.

Parameters
  • name (str) – Dimension name, one of ‘lat’, ‘lon’, ‘time’, or ‘alt’.

  • coordinates (array, read-only) – Full array of coordinate values.

  • ctype (str) – Coordinates type: ‘point’, ‘left’, ‘right’, or ‘midpoint’.

  • segment_lengths (array, float, timedelta) – When ctype is a segment type, the segment lengths for the coordinates. This may be single coordinate delta for uniform segment lengths or an array of coordinate deltas corresponding to the coordinates for variable lengths.

Alternative Constructors

from_definition(d)

Get Coordinates from a coordinates definition.

Methods

__init__([name, ctype, segment_lengths])

Do not use.

copy()

Make a deep copy of the 1d Coordinates.

select(bounds[, return_indices, outer])

Get the coordinate values that are within the given bounds.

Attributes

area_bounds

Low and high coordinate area bounds.

bounds

Low and high coordinate bounds.

coordinates

Coordinate values.

coords

xarray coordinates (container of coordinate arrays)

ctype

definition

Serializable 1d coordinates definition.

deltatype

dims

dtype

Coordinates dtype.

full_definition

Serializable 1d coordinates definition, containing all properties.

idims

is_descending

is_monotonic

is_uniform

name

properties

Dictionary of the coordinate properties.

segment_lengths

A trait which allows any value.

shape

size

Number of coordinates.

udims

Members

__init__(name=None, ctype=None, segment_lengths=None)[source]

Do not use.

area_bounds

Low and high coordinate area bounds.

When ctype != ‘point’, this includes the portions of the segments beyond the coordinate bounds.

bounds

Low and high coordinate bounds.

coords

xarray coordinates (container of coordinate arrays)

Type

dict-like

copy()[source]

Make a deep copy of the 1d Coordinates.

Returns

Copy of the coordinates.

Return type

Coordinates1d

ctype
definition

Serializable 1d coordinates definition.

Type

dict

deltatype
dims
dtype

Coordinates dtype.

float for numerical coordinates and numpy datetime64 for datetime coordinates.

Type

type

full_definition

Serializable 1d coordinates definition, containing all properties. For internal use.

Type

dict

idims
is_descending
is_monotonic
is_uniform
name
properties

Dictionary of the coordinate properties.

Type

dict

segment_lengths

A trait which allows any value.

select(bounds, return_indices=False, outer=False)[source]

Get the coordinate values that are within the given bounds.

The default selection returns coordinates that are within the bounds:

In [1]: c = ArrayCoordinates1d([0, 1, 2, 3], name='lat')

In [2]: c.select([1.5, 2.5]).coordinates
Out[2]: array([2.])

The outer selection returns the minimal set of coordinates that contain the bounds:

In [3]: c.select([1.5, 2.5], outer=True).coordinates
Out[3]: array([1., 2., 3.])

The outer selection also returns a boundary coordinate if a bound is outside this coordinates bounds but inside its area bounds:

In [4]: c.select([3.25, 3.35], outer=True).coordinates
Out[4]: array([3.0], dtype=float64)

In [5]: c.select([10.0, 11.0], outer=True).coordinates
Out[5]: array([], dtype=float64)
Parameters
  • bounds ((low, high) or dict) – Selection bounds. If a dictionary of dim -> (low, high) bounds is supplied, the bounds matching these coordinates will be selected if available, otherwise the full coordinates will be returned.

  • outer (bool, optional) – If True, do an outer selection. Default False.

  • return_indices (bool, optional) – If True, return slice or indices for the selection in addition to coordinates. Default False.

Returns

  • selection (Coordinates1d) – Coordinates1d object with coordinates within the bounds.

  • I (slice or list) – index or slice for the selected coordinates (only if return_indices=True)

shape
udims