podpac.coordinates.Coordinates1d

class podpac.coordinates.Coordinates1d(**kwargs: Any)[source]

Bases: BaseCoordinates

Base class for 1-dimensional coordinates.

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

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

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

Alternative Constructors

from_definition(d)

Get Coordinates from a coordinates definition.

Methods

__init__(*args, **kwargs)

copy()

Make a deep copy of the 1d Coordinates.

flatten()

Get a copy of the coordinates with a flattened array.

get_area_bounds(boundary)

Get low and high coordinate area bounds.

issubset(other)

Report whether other coordinates contains these coordinates.

reshape(newshape)

Get a copy of the coordinates with a reshaped array (wraps numpy.reshape).

select(bounds[, return_index, outer])

Get the coordinate values that are within the given bounds.

simplify()

Get the simplified/optimized representation of these coordinates.

trait_defaults(*names, **metadata)

Return a trait's default value or a dictionary of them

trait_has_value(name)

Returns True if the specified trait has a value.

trait_values(**metadata)

A dict of trait names and their values.

unique([return_index])

Remove duplicate coordinate values.

Attributes

bounds

Low and high coordinate bounds.

coordinates

Coordinate values.

definition

Serializable 1d coordinates definition.

deltatype

dims

dtype

Coordinates dtype.

full_definition

Serializable 1d coordinates definition, containing all properties.

is_descending

is_monotonic

is_uniform

name

ndim

coordinates array ndim.

properties

Dictionary of the coordinate properties.

shape

coordinates array shape.

size

coordinates array size.

start

step

stop

udims

Tuple of unstacked dimension names, for compatibility.

xcoords

xarray coords

xdims

Tuple of indexing dimensions used to create xarray DataArray.

Members:

__init__(*args, **kwargs)
property bounds

Low and high coordinate bounds.

copy()[source]

Make a deep copy of the 1d Coordinates.

Returns:

Copy of the coordinates.

Return type:

Coordinates1d

property definition

Serializable 1d coordinates definition.

Type:

dict

property deltatype
property dims
property dtype

Coordinates dtype.

float for numerical coordinates and numpy datetime64 for datetime coordinates.

Type:

type

property full_definition

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

Type:

dict

get_area_bounds(boundary)[source]

Get low and high coordinate area bounds.

Parameters:

boundary (float, timedelta, array, None) –

Boundary offsets in this dimension.

  • For a centered uniform boundary (same for every coordinate), use a single positive float or timedelta

    offset. This represents the “total segment length” / 2.

  • For a uniform boundary (segment or polygon same for every coordinate), use an array of float or

    timedelta offsets

  • For a fully specified boundary, use an array of boundary arrays (2-D array, N_coords x boundary spec),

    one per coordinate. The boundary_spec can be a single number, two numbers, or an array of numbers.

  • For point coordinates, use None.

Returns:

  • low (float, np.datetime64) – low area bound

  • high (float, np.datetime64) – high area bound

property is_descending
property is_monotonic
property is_uniform
issubset(other)[source]

Report whether other coordinates contains these coordinates.

Parameters:

other (Coordinates, Coordinates1d) – Other coordinates to check

Returns:

issubset – True if these coordinates are a subset of the other coordinates.

Return type:

bool

name
property properties

Dictionary of the coordinate properties.

Type:

dict

select(bounds, return_index=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_index (bool, optional) – If True, return index for the selection in addition to coordinates. Default False.

Returns:

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

  • I (slice, boolean array) – index or slice for the selected coordinates (only if return_index=True)

simplify()[source]

Get the simplified/optimized representation of these coordinates.

Returns:

simplified – simplified version of the coordinates

Return type:

Coordinates1d

property start
property step
property stop
property xcoords

xarray coords

Type:

dict