podpac.data.Array

class podpac.data.Array(**kwargs)[source]

Bases: podpac.core.node.NoCacheMixin, podpac.core.data.datasource.DataSource

Create a DataSource from an array – this node is mostly meant for small experiments

source

Numpy array containing the source data

Type

np.ndarray

coordinates

The coordinates of the source data

Type

podpac.Coordinates

Notes

coordinates need to supplied by the user when instantiating this node.

This Node is not meant for large arrays, and cause issues with caching. As such, this Node override the default cache behavior as having no cache – its data is in RAM already and caching is not helpful.

Example

>>> # Create a time series of 10 32x34 images with R-G-B channels
>>> import numpy as np
>>> import podpac
>>> data = np.random.rand(10, 32, 34, 3)
>>> coords = podpac.Coordinates([podpac.clinspace(1, 10, 10, 'time'),
                                 podpac.clinspace(1, 32, 32, 'lat'),
                                 podpac.clinspace(1, 34, 34, 'lon')])
>>> node = podpac.data.Array(source=data, coordinates=coords, outputs=['R', 'G', 'B'])
>>> output = node.eval(coords)

Alternative Constructors

from_definition(definition)

Create podpac Node from a dictionary definition.

from_json(s)

Create podpac Node from a JSON definition.

Methods

__init__(**kwargs)

Do not overwrite me

create_output_array(coords[, data])

Initialize an output data array

eval(coordinates[, output])

Evaluates this node using the supplied coordinates.

eval_group(group)

Evaluate the node for each of the coordinates in the group.

find_coordinates()

Get the available coordinates for the Node.

from_url(url)

Create podpac Node from a WMS/WCS request.

get_cache(key[, coordinates])

Get cached data for this node.

get_coordinates()

Returns a Coordinates object that describes the coordinates of the data source.

get_data(coordinates, coordinates_index)

This method must be defined by the data source implementing the DataSource class.

has_cache(key[, coordinates])

Check for cached data for this node.

init()

Overwrite this method if a node needs to do any additional initialization after the standard initialization.

load(path)

Create podpac Node from file.

put_cache(data, key[, coordinates, overwrite])

Cache data for this node.

rem_cache(key[, coordinates, mode])

Clear cached data for this node.

save(path)

Write node to file.

set_coordinates(value)

Not needed.

trait_is_defined(name)

Attributes

attrs

List of node attributes

base_ref

Default reference/name in node definitions

boundary

An instance of a Python dict.

cache_coordinates

A boolean (True, False) trait.

cache_ctrl

A trait whose value must be an instance of a specified class.

cache_output

A boolean (True, False) trait.

coordinate_index_type

An enum whose value must be in a given sequence.

coordinates

A trait whose value must be an instance of a specified class.

definition

dtype

A trait which allows any value.

force_eval

A boolean (True, False) trait.

hash

interpolation

interpolation_class

Get the interpolation class currently set for this data source.

interpolators

Return the interpolators selected for the previous node evaluation interpolation.

json

json_pretty

nan_vals

An instance of a Python list.

output

A trait for unicode strings.

outputs

An instance of a Python list.

shape

Returns the shape of self.source

source

A coercing numpy array trait.

style

A trait whose value must be an instance of a specified class.

units

A trait for unicode strings.

Members

__init__(**kwargs)

Do not overwrite me

coordinates

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

get_data(coordinates, coordinates_index)[source]

This method must be defined by the data source implementing the DataSource class. When data source nodes are evaluated, this method is called with request coordinates and coordinate indexes. The implementing method can choose which input provides the most efficient method of getting data (i.e via coordinates or via the index of the coordinates).

Coordinates and coordinate indexes may be strided or subsets of the source data, but all coordinates and coordinate indexes will match 1:1 with the subset data.

This method may return a numpy array, an xarray DaraArray, or a podpac UnitsDataArray. If a numpy array or xarray DataArray is returned, podpac.data.DataSource.evaluate() will cast the data into a UnitsDataArray using the requested source coordinates. If a podpac UnitsDataArray is passed back, the podpac.data.DataSource.evaluate() method will not do any further processing. The inherited Node method create_output_array can be used to generate the template UnitsDataArray in your DataSource. See podpac.Node.create_output_array() for more details.

Parameters
  • coordinates (podpac.Coordinates) – The coordinates that need to be retrieved from the data source using the coordinate system of the data source

  • coordinates_index (List) – A list of slices or a boolean array that give the indices of the data that needs to be retrieved from the data source. The values in the coordinate_index will vary depending on the coordinate_index_type defined for the data source.

Returns

A subset of the returned data. If a numpy array or xarray DataArray is returned, the data will be cast into UnitsDataArray using the returned data to fill values at the requested source coordinates.

Return type

np.ndarray, xr.DataArray, podpac.UnitsDataArray

set_coordinates(value)[source]

Not needed.

property shape

Returns the shape of self.source

Returns

Shape of self.source

Return type

tuple

source

A coercing numpy array trait.