MAP
mapper
framework
The MAP
framework applies a function on values of a Geo Time Series™ that fall into a sliding window.
The MAP
framework is designed to use an existing MAPPER or a custom MACROMAPPER. It could also accept a macro: the current window is passed as a GTS to the macro. See examples below.
MAP is available since version 1.0.0.
See also
Signatures
Examples
NEWGTS 'input' RENAME
1 100 <% s NaN NaN NaN RAND ADDVALUE %> FOR
'inputGTS' STORE //generate a gts with random values between 0.0 and 1.0, every second.
$inputGTS
[ $inputGTS 0.5 mapper.gt 0 0 0 ] MAP //keep values above 0.5
[ SWAP mapper.mean -10 s 0 0 ] MAP //do a moving average on 10s
'above 0.5, moving average' RENAME
NEWGTS 'input' RENAME
1 100 <% s NaN NaN NaN RAND ROUND TOBOOLEAN ADDVALUE %> FOR
'inputGTS' STORE //generate a gts with random booleans, every second.
$inputGTS
// a MACROMAPPER to implement a "NOT" on each VALUEDEDUP
[ $inputGTS
<%
'i' STORE //input is a list [tick_of_computation,[gts_classes],[label_maps],[ticks],[latitudes],[longitudes],[elevations],[values]]
//return a list [tick, latitude, longitude, elevation, value]
[
$i 0 GET // same timestamp
NaN NaN NaN //no location information
$i 7 GET 0 GET ! //not of the value.
]
%> MACROMAPPER
0 0 0
] MAP 'negated output' RENAME
NEWGTS 'input' RENAME
1 100 <% s NaN NaN NaN RAND ROUND TOBOOLEAN ADDVALUE %> FOR
'inputGTS' STORE //generate a gts with random booleans, every second.
$inputGTS
[ $inputGTS
//
// The following macro will extract the first value of its parameter GTS and will apply NOT to the value
//
// Note that when MAP is called with a macro and not a MACROMAPPER, the current window is passed as a GTS to the
// macro.
//
<%
// Retrieve singleton datapoint
0 ATINDEX
// Extract the value
4 REMOVE
// Negate the value
NOT
// Add it to the [ tick lat lon elev ] list
+!
%>
0 0 0 ] MAP 'negated output' RENAME