podpac.algorithm.Generic

class podpac.algorithm.Generic(**kwargs: Any)[source]

Bases: GenericInputs

Generic Algorithm Node that allows arbitrary Python code to be executed.

code

The multi-line code that will be evaluated. This code should assign “output” to the desired result, and “output” needs to be a “numpy array” or “xarray DataArray”

Type:

str

inputs

A dictionary of PODPAC nodes that will serve as the input data for the Python script

Type:

dict(str: podpac.Node)

Examples

a = SinCoords() b = Arange() code = ‘’’import numpy as np output = np.minimum(a, b) ‘’’ generic = Generic(code=code, a=a, b=b)

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

algorithm(inputs, coordinates)

Run the generic code.

create_output_array(coords[, data, attrs, ...])

Initialize an output data array

eval(coordinates, **kwargs)

Evaluate the node at the given coordinates.

eval_group(group)

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

find_coordinates()

Get the available coordinates for the inputs to the Node.

from_name_params(name[, params])

Create podpac Node from a WMS/WCS request.

from_url(url)

Create podpac Node from a WMS/WCS request.

get_bounds([crs])

Get the full available coordinate bounds for the Node.

get_cache(key[, coordinates])

Get cached data for this node.

get_ui_spec([help_as_html])

Get spec of node attributes for building a ui

has_cache(key[, coordinates])

Check for cached data for this node.

init()

load(path)

Create podpac Node from file.

probe([lat, lon, time, alt, crs])

Evaluates every part of a node / pipeline at a point and records which nodes are actively being used.

put_cache(data, key[, coordinates, expires, ...])

Cache data for this node.

rem_cache(key[, coordinates, mode])

Clear cached data for this node.

save(path)

Write node to file.

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_is_defined(name)

trait_values(**metadata)

A dict of trait names and their values.

Attributes

attrs

List of node attributes

base_ref

Default reference/name in node definitions

cache_ctrl

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

cache_output

A boolean (True, False) trait.

code

A trait for unicode strings.

definition

dtype

An enum whose value must be in a given sequence.

force_eval

A boolean (True, False) trait.

hash

inputs

An instance of a Python dict.

json

Definition for this node in JSON format.

json_pretty

Definition for this node in JSON format, with indentation suitable for display.

output

A trait for unicode strings.

outputs

An instance of a Python list.

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

algorithm(inputs, coordinates)[source]

Run the generic code.

inputs

Evaluated outputs of the input nodes. The keys are the attribute names.

Type:

dict

coordinates

Requested coordinates. Note that the inputs may contain with different coordinates.

Type:

podpac.Coordinates

Returns:

result – Algorithm result.

Return type:

UnitsDataArray

code

A trait for unicode strings.

init()[source]