NAME

CXC::Number::Grid::Tree - A Tree representing a Grid

VERSION

version 0.13

DESCRIPTION

This is a subclass of Tree::Range which is used to manipulate grids

CONSTRUCTORS

new

$tree = CXC::Number::Grid::Tree->new( ?\%options )

Construct a new tree, using a default numerical key comparison function. All options recognized by Tree::Range::RB are accepted.

from_array

$tree = CXC::Number::Grid::Tree->from_array( \@array );

Construct a tree object from an array generated by "to_array".

from_grid

$tree = CXC::Number::Grid::Tree->from_grid( $grid );

Construct a tree object from a CXC::Number::Grid object.

METHODS

to_string

$tree->to_string;

Return a string representation of the tree.

to_array

\@array = $tree->to_array;

Return an arrayref with one element per bin. Each element is an arrayref and contains the lower bound, upper bound, and value stored in the tree for the bin bin.

to_grid

$grid = $tree->to_grid;

Return a CXC::Number::Grid object represented by the tree.

snap_overlaid

$tree->snap_overlaid( $layer, $snap_to, $snap_dist ) {

Snap overlaid bins' edges.

Works in place!!

This assumes that the Tree has been

  1. loaded with ranges from two grids, one of which overlays the other; and

  2. that the range values are arrayrefs with the first value being the layer id (larger number indicates the top grid); and

  3. that the top grid is contiguous (e.g. no holes through which the lower grid is visible)

In the general case, the minimum and maximum edges of the top grid will intersect bins in the lower grid. If the remnants of those bins (e.g. the parts not covered by the top grid) are small enough (e.g, smaller than $snap_dist in width), then this routine will either:

  • move the outer edge of the top grid to coincide with the remaining edge of the intersected lower bin ($snap_to = 'underlay')

  • move the remaining edge of the intersected lower bin to coincide with the edge of the top grid. ($snap_to = 'overlay')

clone

$clone = $tree->clone;

Clone a tree, performing a shallow copy of the values associated with each bin in the tree.

INTERNALS

Methods

_snap_overlaid_edges

$self->_snap_overlaid_edges( $layer, $snap_to, $snap_dist, $scan_direction ) {

A helper for "snap_to". This routine is run twice, with $scan_direction set to left and right, then to handle the extrema of the overlaid grid.

SUPPORT

Bugs

Please report any bugs or feature requests to bug-cxc-number@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=CXC-Number

Source

Source is available at

https://gitlab.com/djerius/cxc-number

and may be cloned from

https://gitlab.com/djerius/cxc-number.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007