solarspatialtools.field.cascade_remap

solarspatialtools.field.cascade_remap(remap1, remap2)

Cascades the effect of a remapping of a remapping. This function is useful for situations where you’ve remapped the data once, and then you’ve reprocessed that data under the new locations, and obtained a new remapping. This function will combine the two remappings into a single remapping that maps from the original data to the final remapped positions.

After applying an initial remapping, the second remapping has indices that are now effectively scrambled by the new positions. Thus applying this in a sense has the effect of merging the values of the first column from the second remap into the second column from the first remap, and keeping the outer values as the result. This is a bit confusing, but the example below should help clarify.

remap1 = [(‘A’, ‘B’), (‘B’, ‘C’), (‘C’, ‘A’)] remap2 = [(‘A’, ‘B’), (‘B’, ‘C’), (‘C’, ‘A’)]

result = [(‘A’, ‘C’), (‘B’, ‘A’), (‘C’, ‘B’)]

Typically, values of remap inputs would be obtained from the assign_positions function.

Parameters

remap1list of tuples

The original remapping. Each tuple is a pair of indices, where the first index is the original location, and the second index is the name of the combiner whose location is the true location of the first index.

remap2list of tuples

The second remapping. Each tuple is a pair of indices, where the first index is the position within the remap1 space, and the second index is the new remapping also within that already remapped space.

Returns

outlist of tuples

The new remapping that maps from the original locations to the new remapped positions after reprocessing.