podpac.algorithm.Mask

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

Bases: Algorithm

Masks the source based on a boolean expression involving the mask (i.e. source[mask <bool_op> <bool_val> ] = <masked_val>). For a normal boolean mask input, default values for bool_op, bool_val and masked_val can be used.

source

The source that will be masked

Type:

podpac.Node

mask

The data that will be used to compute the mask

Type:

podpac.Node

masked_val

Default value is np.nan. The value that will replace the masked items.

Type:

float, optional

bool_val

Default value is 1. The value used to compare the mask when creating the boolean expression

Type:

float, optional

bool_op

Default value is ‘==’. One of [‘==’, ‘<’, ‘<=’, ‘>’, ‘>=’]

Type:

enum, optional

in_place

Default is False. If True, the source array will be changed in-place, which could affect the value of the source in other parts of the pipeline.

Type:

bool, optional

Examples

# Mask data from a boolean data node using the default behavior. # Create a boolean masked Node (as an example) b = Arithmetic(A=SinCoords(), eqn=’A>0) # Create the source node a = Arange() masked = Mask(source=a, mask=b)

# Create a node that make the following substitution “a[b > 0] = np.nan” a = Arange() b = SinCoords() masked = Mask(source=a, mask=b,

masked_val=np.nan, bool_val=0, bool_op=’>’ in_place=True)

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)

Sets the values in inputs['source'] to self.masked_val using (inputs['mask'] <self.bool_op> <self.bool_val>)

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

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

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

bool_op

An enum whose value must be in a given sequence.

bool_val

A float trait.

cache_ctrl

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

cache_output

A boolean (True, False) trait.

definition

dtype

An enum whose value must be in a given sequence.

force_eval

A boolean (True, False) trait.

hash

in_place

A boolean (True, False) trait.

inputs

json

Definition for this node in JSON format.

json_pretty

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

mask

masked_val

A float trait.

output

A trait for unicode strings.

outputs

An instance of a Python list.

source

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]

Sets the values in inputs[‘source’] to self.masked_val using (inputs[‘mask’] <self.bool_op> <self.bool_val>)

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

bool_op

An enum whose value must be in a given sequence.

bool_val

A float trait.

in_place

A boolean (True, False) trait.

mask
masked_val

A float trait.

source