Loading

CROP

bucketize

The CROP function works on bucketized Geo Time Series™ instances, if transforms a GTS into another one whose bucketcount, last bucket parameters span the smallest interval with actual values. Bucket span remains the same.

When called on a non bucketized GTS instance, CROP simply clones it.

This function expects a list of GTS instances on the top of the stack.

CROP is available since version 1.0.0.

See also

Signatures

Examples

[ NEWGTS 'GTS1' RENAME 300 NaN NaN NaN 8 ADDVALUE 400 NaN NaN NaN 7 ADDVALUE 500 NaN NaN NaN 6 ADDVALUE 700 NaN NaN NaN 42 ADDVALUE 800 NaN NaN NaN 42 ADDVALUE 900 NaN NaN NaN 3 ADDVALUE 950 NaN NaN NaN 1 ADDVALUE NEWGTS 'GTS2' RENAME 100 NaN NaN NaN 1 ADDVALUE 700 NaN NaN NaN 42 ADDVALUE 800 NaN NaN NaN 42 ADDVALUE 1100 NaN NaN NaN 1 ADDVALUE ] // bucket span 200, bucket count 1150 (far too much in the past), last bucket 1600 (too far in the future) [ SWAP bucketizer.last 1600 200 1150 ] BUCKETIZE 'b' STORE // adjust last bucket and bucket count for each gts in the input list $b CROP 'c' STORE [ 'before/after crop: bucket count GTS1' [ $b 0 GET BUCKETCOUNT $c 0 GET BUCKETCOUNT ] ] [ 'before/after crop: last bucket GTS1' [ $b 0 GET LASTBUCKET $c 0 GET LASTBUCKET ] ] '' [ 'before/after crop: bucket count GTS2' [ $b 1 GET BUCKETCOUNT $c 1 GET BUCKETCOUNT ] ] [ 'before/after crop: last bucket GTS2' [ $b 1 GET LASTBUCKET $c 1 GET LASTBUCKET ] ]

Examples

GTS1 = NEWGTS() ADDVALUE(GTS1, 300, NaN, NaN, NaN, 8) ADDVALUE(GTS1, 400, NaN, NaN, NaN, 7) ADDVALUE(GTS1, 500, NaN, NaN, NaN, 6) ADDVALUE(GTS1, 700, NaN, NaN, NaN, 42) ADDVALUE(GTS1, 800, NaN, NaN, NaN, 42) ADDVALUE(GTS1, 900, NaN, NaN, NaN, 3) ADDVALUE(GTS1, 950, NaN, NaN, NaN, 1) GTS2 = NEWGTS() ADDVALUE(GTS2, 100, NaN, NaN, NaN, 1) ADDVALUE(GTS2, 700, NaN, NaN, NaN, 42) ADDVALUE(GTS2, 800, NaN, NaN, NaN, 42) ADDVALUE(GTS2, 1100, NaN, NaN, NaN, 1) lGTS = [ GTS1, GTS2 ] // bucket span 200, bucket count 1150 (far too much in the past), last bucket 1600 (too far in the future) b = BUCKETIZE([ lGTS, bucketizer.last(), 1600, 200, 1150 ]) // adjust last bucket and bucket count for each gts in the input list c = CROP(b) return [ 'before/after crop: bucket count GTS1', [ BUCKETCOUNT(GET(b,0)), BUCKETCOUNT(GET(c,0)) ] ], [ 'before/after crop: last bucket GTS1', [ LASTBUCKET(GET(b,0)), LASTBUCKET(GET(c,0)) ] ], '', [ 'before/after crop: bucket count GTS2', [ BUCKETCOUNT(GET(b,1)), BUCKETCOUNT(GET(c,1)) ] ], [ 'before/after crop: last bucket GTS2', [ LASTBUCKET(GET(b,1)), LASTBUCKET(GET(c,1)) ] ]