MACROREDUCER


reducer
Since v1.0.0
Available on all platforms
See also

MACROREDUCER converts a macro into a reducer which can be used with the REDUCE framework

For each tick in the Geo Time Series™ to reduce, the macro will be called with a list containing the following elements on the stack:

[tick_of_computation,[gts_classes],[label_maps],[ticks],[latitudes],[longitudes],[elevations],[values]]

Each list have a length of the number of GTSs in the partition. Each missing value are replaced by null, each missing tick by the minimum value of long and each missing latitude, longitude or elevation by NaN. The label_maps list as one more element at the end compared to the other lists: the common labels for the GTSs of the partition.

After each call the macro is expected to leave on the stack a list with the following elements:

[tick, latitude, longitude, elevation, value]

MACROREDUCER can also create a multivariate reducer, that is, a reducer that outputs multiple results. To do this, macro calls shall leave on the stack a map:

{
'result_1': [tick, latitude, longitude, elevation, value],
'result_2': [tick, latitude, longitude, elevation, value],
...
}

When using a multivariate reducer with REDUCE, each input List of GTS produces as much output GTS in a list, whose classnames are the keys found in the map left by the macro call on the stack.

Signature

Examples

<% 'input' STORE // We keep the input in a variable 0 'total' STORE 0 'elements' STORE // The number of nun null elements $input 7 GET // Get the values <% 'val' STORE <% $val ISNULL ! %> // If condition : Value non null <% $total $val + 'total' STORE // Increasing total $elements 1 + 'elements' STORE // Increasing element count %> IFT %> FOREACH $total $elements / 'mean' STORE // Calculating the mean $input 0 GET NaN NaN NaN $mean %> 'reducer.mean.ignorenull' STORE [ '60V8S5KnS1toOLpk5k9701tWR6.7O5xYAaGWS537RqKiRqxmHLF1Nn3LXsXMjhYGz8Bt4emFa9LYuu1Pb.3Q.0V6PLtbRaKnRk0L.0Vn6sg7.........ECGJy4YODOZ033yGYNFkFkXLEVNqP4w1572Zwl.WWsn.AVWYzkp....4acG..' '60V8S5KnS1toOLpk5k9701tWR6.7O5xYAaGWS537RqKiRqxmHLF1Nn7LXsXMjhYGz8Bt4eMTaSviitX8eF3Q.0V6PLtbRaKnRk0L.0W.6sg7.........EElJyCYODSZt5CZsqCZ.YAt52_.E.WXsLCZ0O7V.QVRFdNOeVqcW.ZemV3J0F0QeVn4Jk...0Pa.G3.' '60V8S5KnS1toOLpk5k9701tWR6.7O5xYAaGWS537RqKiRqxmHLF1NnBLXsXMjhYGz8Bt4cjHwiTOcUrZBGg.5.SdQaSmOMCn.4N.52NUXkV.........wz4IsLCZtLCZ.HBVVl6BNDOYOD73Bhb..Z0W2Y.2X8WV22N.7dj8E2g....LSW3.' ] UNWRAP DUP [ SWAP [] $reducer.mean.ignorenull MACROREDUCER ] REDUCE