podpac.compositor.Compositor

class podpac.compositor.Compositor(**kwargs)[source]

Bases: podpac.core.node.Node

cache_native_coordinates

Default is True. If native_coordinates are requested by the user, it may take a long time to calculate if the Compositor points to many sources. The result is relatively small and is cached by default. Caching may not be desired if the datasource change or is updated.

Type

Bool

interpolation

Interpolation definition for the data source. By default, the interpolation method is set to 'nearest' for all dimensions.

Type

str, dict, optional

is_source_coordinates_complete

Default is False. The source_coordinates do not have to completely describe the source. For example, the source coordinates could include the year-month-day of the source, but the actual source also has hour-minute-second information. In that case, source_coordinates is incomplete. This flag is used to automatically construct native_coordinates.

Type

Bool

shared_coordinates

Coordinates that are shared amongst all of the composited sources

Type

podpac.Coordinates, optional

source

The source is used for a unique name to cache composited products.

Type

str

source_coordinates

Description

Type

podpac.Coordinates

sources

An array of sources. This is a numpy array as opposed to a list so that boolean indexing may be used to subselect the nodes that will be evaluated.

Type

np.ndarray

source_coordinates

Coordinates that make each source unique. This is used for subsetting which sources to evaluate based on the user-requested coordinates. It is an optimization.

Type

podpac.Coordinates, optional

Notes

Developers of new Compositor nodes need to implement the composite method.

Multitheading::
  • When MULTITHREADING is False, the compositor stops evaluated sources once the output is completely filled.

  • When MULTITHREADING is True, the compositor must evaluate every source. The result is the same, but note that because of this, disabling multithreading could sometimes be faster, especially if the number of threads is low.

  • NASA data servers seem to have a hard limit of 10 simultaneous requests, so a max of 10 threads is recommend for most use-cases.

Methods

__init__(**kwargs)

Do not overwrite me

composite(outputs[, result])

Implements the rules for compositing multiple sources together.

create_output_array(coords[, data])

Initialize an output data array

eval(coordinates[, output])

Evaluates this nodes using the supplied coordinates.

eval_group(group)

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

find_coordinates()

Get the available native coordinates for the Node.

get_cache(key[, coordinates])

Get cached data for this node.

get_shared_coordinates()

Coordinates shared by each source.

get_source_coordinates()

Returns the coordinates describing each source.

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.

iteroutputs(coordinates)

Summary

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

Cache data for this node.

rem_cache(key[, coordinates, mode])

Clear cached data for this node.

select_sources(coordinates)

Downselect compositor sources based on requested coordinates.

Attributes

base_definition

Base node defintion for Compositor nodes.

base_ref

Default pipeline node reference/name in pipeline node definitions

cache_ctrl

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

cache_native_coordinates

A boolean (True, False) trait.

cache_output

A boolean (True, False) trait.

cache_update

A boolean (True, False) trait.

definition

Full pipeline definition for this node.

dtype

A trait which allows any value.

hash

interpolation

A trait type representing a Union type.

is_source_coordinates_complete

A boolean (True, False) trait.

json

definition for this node in json format

json_pretty

pipeline

Create a pipeline node from this node

shared_coordinates

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

source

A trait for unicode strings.

source_coordinates

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

sources

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

property base_definition

Base node defintion for Compositor nodes.

Returns

Dictionary containing the location of the Node, the name of the plugin (if required), as well as any parameters and attributes that were tagged by children.

Return type

OrderedDict

cache_native_coordinates

A boolean (True, False) trait.

composite(outputs, result=None)[source]

Implements the rules for compositing multiple sources together.

Parameters
  • outputs (list) – A list of outputs that need to be composited together

  • result (UnitDataArray, optional) – An optional pre-filled array may be supplied, otherwise the output will be allocated.

Raises

NotImplementedError

eval(coordinates, output=None)[source]

Evaluates this nodes using the supplied coordinates.

Parameters
  • coordinates (podpac.Coordinates) – The set of coordinates requested by a user. The Node will be evaluated using these coordinates.

  • output (podpac.UnitsDataArray, optional) – Default is None. Optional input array used to store the output data. When supplied, the node will not allocate its own memory for the output array. This array needs to have the correct dimensions, coordinates, and coordinate reference system.

Returns

Unit-aware xarray DataArray containing the results of the node evaluation.

Return type

podpac.UnitsDataArray

find_coordinates()[source]

Get the available native coordinates for the Node.

Returns

coords_list – list of available coordinates (Coordinate objects)

Return type

list

get_shared_coordinates()[source]

Coordinates shared by each source.

Raises

NotImplementedError – Description

get_source_coordinates()[source]

Returns the coordinates describing each source. This may be implemented by derived classes, and is an optimization that allows evaluation subsets of source.

Returns

Coordinates describing each source.

Return type

podpac.Coordinates

interpolation

A trait type representing a Union type.

is_source_coordinates_complete

A boolean (True, False) trait.

iteroutputs(coordinates)[source]

Summary

Parameters

coordinates (podpac.Coordinates) – Coordinates to evaluate at compositor sources

Yields

podpac.core.units.UnitsDataArray – Output from source node eval method

select_sources(coordinates)[source]

Downselect compositor sources based on requested coordinates.

This is used during the eval() process as an optimization when source_coordinates are not pre-defined.

Parameters

coordinates (podpac.Coordinates) – Coordinates to evaluate at compositor sources

Returns

Array of downselected sources

Return type

np.ndarray

shared_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

source

A trait for unicode strings.

source_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

sources

A coercing numpy array trait.