Skip to content

lib-hisKit 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793849078/FIN+5.3.1+lib-hisKit 中文整理基于 FIN 5.3.1

导读: 历史学家分析功能库

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • docs
  • funcs
  • Overview
  • Interpolation
  • Windows and Slices
    • Windows
    • Slices
    • def
  • hisCompare(src, dates)
  • hisCuSum(g)
  • hisDailyProfile(src, fold)
  • hisDurProfile(src)
  • hisFindAll(src, fn)
  • hisFindInPeriods(src, periods)
  • hisFindPeaks(src)
  • hisFindPeriods(src, fn)
  • hisFindSlicePeriods(src, windows, fn)
  • hisFindTroughs(src)
  • hisFlatten(src, fn)
  • hisFoldCols(src, fold)
  • hisInWindows(ts, windows)
  • hisMap(src, fn)
  • hisMapSlices(src, windows, fn)
  • hisPeriodIntersection(periods)
  • hisPeriodMatrix(periods)
  • hisPeriodNormalize(grid)
  • hisPeriodShift(grid, startShift, endShift)
  • hisPeriodUnion(periods)
  • hisSlice(src, ts, dur)
  • hisSlidingWindows(range, dur, step)
  • hisTransitionWindows(src, dur, fn)

概述(中译) ​

历史学家分析功能库


API 正文(英文) ​

docs ​

Overview • Interpolation • Windows and Slices


funcs ​

hisCompareCompare a history query against an alternate set of dates
hisCuSumCalculate a simplified cumulative sum (CuSum) for the given history grid
hisDailyProfilePerform a rollup by time slice to produce a single 24-hour profile of the data
hisDurProfileCompute a "load duration" curve
hisFindAllPerform a filter transformation on a history grid
hisFindInPeriodsPerform filter transformation on a history grid by finding all rows which have a timestamp within the given periods
hisFindPeaksFilter a history grid so that only numeric samples that represent a peak are returned
hisFindPeriodsFind all the periods of time when fn returns true for a history grid
hisFindSlicePeriodsGiven a source history grid and a grid of windows, compute the periods of all the slices matched by given function
hisFindTroughsFilter a history grid so that only numeric samples that represent a trough are returned
hisFlattenPerform a transformation on the history to flatten out ts/val pairs into new rows
hisFoldColsGiven a history grid, fold all the value columns (every column* except "ts") into a single "v0" column
hisInWindowsReturn true or false if the given timestamp is inside at least one of the given windows
hisMapPerform a map transformation on the history value cells
hisMapSlicesGiven a source history grid and a grid of windows, compute the mapping of each slice
hisPeriodIntersectionFind the intersection of two or more historical periods
hisPeriodMatrixGet a grid which defines the "matrix" of unique combinations of all the periods merged together
hisPeriodNormalizeGiven a grid of historical periods, merge any overlapping periods to result in a "normalized" his period grid
hisPeriodShiftGiven of a grid of historical periods, shift the starting and ending timestamps by an offset
hisPeriodUnionFind the union of two or more historical periods
hisSliceSlice a source history grid by a single time window
hisSlidingWindowsCompute of grid of timestamp/duration windows
hisTransitionWindowsCompute a grid of timestamp/duration windows based on transitions of a history grid

lib hisKit ​

Overview ​

The hisKit extension provides a library of functions for analyzing time series data stored in the historian.

Interpolation ​

When doing time series analytics we often want to correlate different histories. For example we might want to compute the differential between two temperature sensors. Depending on the system which originally sampled the data, the time series is unlikely to be aligned by timestamp precisely. For example a typical query might result in:

// query
readAll(temp1 or temp2).hisRead(today)

// grid result
ts     temp1  temp2  kwh1
-----  -----  -----  ----
08:00     75   null  100
08:10   null     55  null
08:15     77   null  200
08:20   null     60  null
08:30     78     62  75
08:40   null     65  null
08:45     77   null  150

In the example above temp1 was sampled on 15 minute intervals and temp2 on ten minute intervals. The kwh1 point is a consumption point. We can use the hisInterpolate() function to fill in the cells with a null value using interpolation to approximate the value.

There are three modes of interpolation:

  • cov: this mode assumes the data was sampled on change-of-value. This means that interpolation always uses the previous value until the next explicit change of value.
  • consumption: if the point has the hisMode tag set to consumption this means the value at the beginning of the interval needs to be apportioned across the interpolated cells.
  • linear: this mode is used with interval sampled data to compute the approximation using a linear equation based on the previous and next values and the associated timestamps.

The default behavior for Bool histories is to use "cov" mode and Number histories use "linear". You can explicitly configure a numeric history as "cov" using the hisMode tag.

You can explicitly configure the interpolation mode to use by setting the hisInterpolateMode tag to one of the values above.

Lets interpolate our raw data from the example above:

// query
readAll(temp1 or temp2 or kwh1).hisRead(today).hisInterpolate

// grid result
ts     temp1  temp2  kwh1
-----  -----  -----  ----
08:00   75.0   null  50
08:10   76.3   55.0  50
08:15   77.0   57.5  100
08:20   77.3   60.0  100
08:30   78.0   62.0  37.5
08:40   77.3   65.0  37.5
08:45   77.0   null  150

Note that interpolation may still produce null results if the original query is missing the data required to interpolate correctly (typically at the start and end of the range). This typically isn't a problem because remember that the standard behavior of hisRead is to query the samples immediately preceding and immediately following the desired time range.

Windows and Slices ​

Often when analyzing time series data, we wish to examine "windows" of time. We formally define a window as a timestamp and duration pair. We use the term slice to indicate a sub-set of historical data which is inclusive of a window.

A suite of functions is designed to create different combinations of windows and slices:

  • hisSlidingWindows()
  • hisTransitionWindows()
  • hisInWindows()
  • hisSlice()
  • hisFindSlicePeriods()
  • hisMapSlices()

Windows ​

We define windows as a grid of timestamp/duration pairs that indicates the start time and duration of each time window. Windows may overlap. You can check if a timestamp occurs inside a grid of windows using the hisInWindows() function.

We typically create windows of time using two different techniques. A sliding window is a discrete set of steps across a time range created by the hisSlidingWindows() function. For example if we wish to generate a grid of one hour windows with 15min steps we can use this expression:

hisSlidingWindows(dates, 1hr, 15min)

The other technique often used to create windows is from the state transition of a point. We use the hisTransitionWindows() to generate transition windows from historical data. For example, to generate 15min windows every time a pump transitions from off to on:

pump.readHis(dates).hisTransitionWindows(15min) (a,b) => not a->v0 and b->v0

Note the function used here is given a previous and current row from the source grid. In this case we looking at the v0 column where the previous value is not a->v0 (off) and current value is b->v0 (on).

Slices ​

We often will wish to analyze a stream of historical data against one or more windows. Intuitively a slice is just the set of history items which are inclusive of the window's time range. But a key characteristic of slices is that they always include a row for the boundary timestamps with interpolated values (if is the original data doesn't align with the boundaries).

The hisSlice() function is the low-level function which will generate a slice from a source history grid using a window timestamp and duration. But more often you will use the higher order functions: hisFindSlicePeriods() or hisMapSlices().

Let's say we have computed a set of windows from an equip transitioning from on to off and we wish to compute the change in electrical demand from 5min before the transition to 10min after. We can calculate that using the following example code:

// compute windows from -5min..10min from on -> off
windows: hisRead(equipOn, dates)
  .hisTransitionWindows(-5min..10min) (a,b) => a->v0 and not b->v0

// read the kw and map each delta over each window slice
hisRead(kw, dates).hisMapSlices(windows) slice => do
  first: slice.first
  last:  slice.last
  {ts:first->ts, kwDelta: last["v0"] - first["v0"]}
end


def ​

func:hisCompare ​

hisCompare(src, dates) ​

Compare a history query against an alternate set of dates. This function takes the result of a history query, potentially with transforms using hisMap(), hisRollup(), etc.

The original query is re-run againts the new starting dates using the same duration as the original query. For example if the original duration was over 7days, then comparison queries will also be 7days.

The comparison values are are added as columns "vNxM" where "N" represents the originals "v0", "v1" columns and "M" represents the comparison dates. The timestamps are aligned on the hour of the day based on the original query.

The dates may be one of the following:

  • Date: convenience for [date]
  • Date[]: list of starting dates
  • DateSpan: convenience for month with starting date is aligned to base query by weekdays
  • DateSpan[]: convenience for list months aligned by weekday
  • Int: convenience for 1st of year aligned by weekday
  • Int[]: convenience for list of 1st of years
  • Func: function which evaluates to one of the above supported types

meta ​

deffunc:hisCompare
isfunc
liblib:hisKit
namehisCompare

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisCuSum ​

hisCuSum(g) ​

Calculate a simplified cumulative sum (CuSum) for the given history grid. The v0 column is treated as the "actual" value, and the v1 column is treated as the "target" value.

Example:

// input data (dates ignored)
ts, v0, v1
00:00, 100 kWh, 150 kWh
01:00, 175 kWh, 100 kWh
02:00,  50 kWh, 100 kWh

// CuSum function
hisCuSum(src)

// resulting grid
ts, v0
00:00, -50 kWh
01:00,  25 kWh
02:00, -25 kWh

NOTE: this function is subject to change


meta ​

deffunc:hisCuSum
isfunc
liblib:hisKit
namehisCuSum

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisDailyProfile ​

hisDailyProfile(src, fold) ​

Perform a rollup by time slice to produce a single 24-hour profile of the data. The input must be a history grid with a ts DateTime column and timestamps spread across a uniform interval (typically result of hisRollup()). The result replaces ts with a time column for each unique time-slice.

For example, let's consider we wish to generate an average daily profile of our energy use in Jan of 2010. Assuming have 15-min demand data we would start with this rollup:

hisRead(pt, 2010-01).hisRollup(max, 1hr)

This produces a grid with one row for each hour of the month. The values of the grid are the peak demand within each hour window (using the max function). Now let's say we wish to average the entire month to get average peak for each one hour time slice:

hisRead(pt, 2010-01).hisRollup(max, 1hr).hisDailyProfile(avg)

The resulting grid will have 24 rows with the average of each time-slice:

time    val
-----   ----
00:00   avg(01-Jan 00:00, 02-Jan 00:00, ... 31-Jan 00:00)
01:00   avg(01-Jan 01:00, 02-Jan 01:00, ... 31-Jan 01:00)
....
23:00   avg(01-Jan 23:00, 02-Jan 23:00, ... 31-Jan 23:00)

meta ​

deffunc:hisDailyProfile
isfunc
liblib:hisKit
namehisDailyProfile

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisDurProfile ​

hisDurProfile(src) ​

Compute a "load duration" curve. The input must be a history grid with a ts DateTime column and all the values must be numbers with a uniform unit. The result is a grid shaped as follows:

bucket   v0            v1
------   -----------   ----------
  a      dur v0 >= a   dur v1 >= a  ...
  b      dur v0 >= b   dur v1 >= b  ...
....

The function creates 100 buckets based on the min/max range of all the values contained by the input grid. The ts column is replaced by a bucket column which defines 100 discrete "buckets" of the value range. The input's value columns and meta remain unchanged. The cells of the value columns define the number of hours the value is greater than or equal to the bucket value.

By default gaps in the data over 1hour are ignored. If the hisInterval grid.meta is specified and it is over 1hr, then it is used as the gap threshold.


meta ​

deffunc:hisDurProfile
isfunc
liblib:hisKit
namehisDurProfile

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindAll ​

hisFindAll(src, fn) ​

Perform a filter transformation on a history grid. The filter function takes (val, ts, his) and returns true or false.

By default, empty columns will be removed. To keep empty columns you may do one of the following:

  1. pass the hisKeepEmptyCols option to hisRead()
  2. add the hisKeepEmptyCols marker tag to the history grid meta using addMeta()

meta ​

deffunc:hisFindAll
isfunc
liblib:hisKit
namehisFindAll

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindInPeriods ​

hisFindInPeriods(src, periods) ​

Perform filter transformation on a history grid by finding all rows which have a timestamp within the given periods. The periods grid must be in the standard format for history periods where first column is ts timestamp and second column is values measured in hours.

By default, empty columns will be removed. To keep empty columns you may do one of the following:

  1. pass the hisKeepEmptyCols option to hisRead()
  2. add the hisKeepEmptyCols marker tag to the history grid meta using addMeta()

meta ​

deffunc:hisFindInPeriods
isfunc
liblib:hisKit
namehisFindInPeriods

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindPeaks ​

hisFindPeaks(src) ​

Filter a history grid so that only numeric samples that represent a peak are returned. A peak is defined as a timestamp/value pair where both the previous and next value is smaller. Non-numeric columns are filtered out. If the source grid has multiple numeric value columns, then non-peak cells are set to null. Also see hisFindTroughs().


meta ​

deffunc:hisFindPeaks
isfunc
liblib:hisKit
namehisFindPeaks

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindPeriods ​

hisFindPeriods(src, fn) ​

Find all the periods of time when fn returns true for a history grid. The filter func takes (val, ts, his) and returns true or false. This function only works on data up to the current time; it does not work with future data.

By default, empty columns will be removed. To keep empty columns you may do one of the following:

  1. pass the hisKeepEmptyCols option to hisRead()
  2. add the hisKeepEmptyCols marker tag to the history grid meta using addMeta()

meta ​

deffunc:hisFindPeriods
isfunc
liblib:hisKit
namehisFindPeriods

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindSlicePeriods ​

hisFindSlicePeriods(src, windows, fn) ​

Given a source history grid and a grid of windows, compute the periods of all the slices matched by given function. For each window in the widows grid, the hisSlice() is computed and passed to the function as (grid). If the function returns true the window is added to the resulting periods. Adjacent or overlapping windows are coalesced together in the period results.

See Windows and Slices


meta ​

deffunc:hisFindSlicePeriods
isfunc
liblib:hisKit
namehisFindSlicePeriods

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFindTroughs ​

hisFindTroughs(src) ​

Filter a history grid so that only numeric samples that represent a trough are returned. A trough is defined as a timestamp/value pair where both the previous and next value is larger. Non-numeric columns are implicitly filtered out. If the source grid has multiple numeric value columns, then non-trough cells are set to null. Also see hisFindPeaks().


meta ​

deffunc:hisFindTroughs
isfunc
liblib:hisKit
namehisFindTroughs

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFlatten ​

hisFlatten(src, fn) ​

Perform a transformation on the history to flatten out ts/val pairs into new rows. The mapping function takes (val, ts, his) and returns a dict for the flattened row. Given a grid with n val colums, and m rows, the resulting grid has n x m rows. The resulting columns are determined by the dicts returned from the mapping func.


meta ​

deffunc:hisFlatten
isfunc
liblib:hisKit
namehisFlatten

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisFoldCols ​

hisFoldCols(src, fold) ​

Given a history grid, fold all the value columns (every column* except "ts") into a single "v0" column.

Examples:

readAll(kw).hisRead(lastWeek).hisFoldCols(sum)

meta ​

deffunc:hisFoldCols
isfunc
liblib:hisKit
namehisFoldCols

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisInWindows ​

hisInWindows(ts, windows) ​

Return true or false if the given timestamp is inside at least one of the given windows. The ts parameter may be either a DateTime or a Dict/Row with a ts tag/column. The windows parameter must be a grid of timestamp/duration rows. Windows are start-inclusive and end-exclusive for timestamp comparisons.

See Windows and Slices

Example:

// filter out rows not inside a grid of windows
hisRead(points, dates).findAll(row => hisInWindows(row, windows))

meta ​

deffunc:hisInWindows
isfunc
liblib:hisKit
namehisInWindows

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisMap ​

hisMap(src, fn) ​

Perform a map transformation on the history value cells. The mapping function takes (val, ts, his) and returns new vals. The src must be a history grid.

By default, empty columns will be removed. To keep empty columns you may do one of the following:

  1. pass the hisKeepEmptyCols option to hisRead()
  2. add the hisKeepEmptyCols marker tag to the history grid meta using addMeta()

meta ​

deffunc:hisMap
isfunc
liblib:hisKit
namehisMap

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisMapSlices ​

hisMapSlices(src, windows, fn) ​

Given a source history grid and a grid of windows, compute the mapping of each slice. For each window in the widows grid, the hisSlice() is computed and passed to the function as (grid). The function must return a dict for resulting row or null to skip mapping that window/slice.

See Windows and Slices


meta ​

deffunc:hisMapSlices
isfunc
liblib:hisKit
namehisMapSlices

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisPeriodIntersection ​

hisPeriodIntersection(periods) ​

Find the intersection of two or more historical periods. The periods parameter may be:

  • Grid: a single grid where the first column is a "ts" column, and all remaining columns are named anything and contain period values.
  • Grid?[]: a list of grids where each grid has the format described above

All input grids must be normalized

The resulting grid has "ts" and "v0" column, where "v0" is duration in hours.

Example:

// find periods when both a and b are on
hisPeriodIntersection([a, b])

meta ​

deffunc:hisPeriodIntersection
isfunc
liblib:hisKit
namehisPeriodIntersection

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisPeriodMatrix ​

hisPeriodMatrix(periods) ​

Get a grid which defines the "matrix" of unique combinations of all the periods merged together. The periods parameter may be:

  • Grid: a single grid where the first column is a "ts" column, and all remaining columns are named anything and contain period values.
  • Grid?[]: a list of grids where each grid has the format described above,

All input grids must be normalized

The result is returned as a grid with these columns:

  • ts: starting timestamp of each unique period
  • dur: duration in hours of each unique period
  • numTrue: number of input periods "on" during period
  • v{i}: true of false indicating if input was "on" during that period

Example, lets assume we have three unit runtime periods a, b, and c:

// look for periods where all units are all off
hisPeriodMatrix([a, b, c]).findAll r => r->numTrue == 0

// look for periods where all units are all on
hisPeriodMatrix([a, b, c]).findAll r => r->numTrue == 3

// look for periods where a and b are on, but c is off
hisPeriodMatrix([a, b, c]).findAll r => r->v0 and r->v1 and not r->v2

meta ​

deffunc:hisPeriodMatrix
isfunc
liblib:hisKit
namehisPeriodMatrix

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisPeriodNormalize ​

hisPeriodNormalize(grid) ​

Given a grid of historical periods, merge any overlapping periods to result in a "normalized" his period grid.

Examples:

// input periods
02:00 1hr
02:30 3hr

hisPeriodNormalize(src)
02:00 3.5hr

meta ​

deffunc:hisPeriodNormalize
isfunc
liblib:hisKit
namehisPeriodNormalize

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisPeriodShift ​

hisPeriodShift(grid, startShift, endShift) ​

Given of a grid of historical periods, shift the starting and ending timestamps by an offset. The input grids must have a "ts" timestamp column and value columns of duration. The startShift specifies a positive or negative shift of the starting timestamp of each period. The endShift indicates the amount to add/remove to each period duration (shifting the implied end timestamp). If the shift results a negative duration, then that period it is removed. If the shift creates overlapping periods, then they are merged.

Examples:

// input periods
02:00  1hr
08:00  4hr
13:00  5hr

// shift start timestamp one hour forward and end timestamp
// back two hours (note 02:00 period is removed)
hisPeriodShift(src, 1hr, -2hr)
09:00  1hr
14:00  2hr

// keep start timestamp unchanged, but move end timestamp
// ahead three hours (note 08:00 and 13:00 periods merged)
hisPeriodShift(src, 0hr, 3hr)
02:00  4hr
08:00  13hr

meta ​

deffunc:hisPeriodShift
isfunc
liblib:hisKit
namehisPeriodShift

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisPeriodUnion ​

hisPeriodUnion(periods) ​

Find the union of two or more historical periods. The periods parameter may be:

  • Grid?: a single grid where the first column is a "ts" column, and all remaining columns are named anything and contain period values.
  • Grid?[]: a list of grids where each grid has the format described above,

All input grids must be normalized

The resulting grid has "ts" and "v0" column, where "v0" is duration in hours.

Example:

// find periods when either a, b, or c is on
hisPeriodUnion([a, b, c])

meta ​

deffunc:hisPeriodUnion
isfunc
liblib:hisKit
namehisPeriodUnion

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisSlice ​

hisSlice(src, ts, dur) ​

Slice a source history grid by a single time window. Slices only include items from the source grid which are inclusive of the window time range. The starting and ending rows are always the time boundaries of window with the values interpolated (or null if they cannot be interpolated).

Example:

// input data (dates ignored)
ts, v0
00:00, 20, true
01:00, 30, false
02:00, 40, null
03:00, 50, true
04:00, 60, false

// slice function
hisSlice(src, dateTime(date, 1:30), 2hr)

// resulting grid
ts, val
1:30, 35, false
2:00, 40, null
3:00, 50, true
3:30, 55, true

Note in the example above that we added a row at beginning and at the end for the window boundaries. The values of these boundary rows are interpolated from the original data.

See Windows and Slices


meta ​

deffunc:hisSlice
isfunc
liblib:hisKit
namehisSlice

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisSlidingWindows ​

hisSlidingWindows(range, dur, step) ​

Compute of grid of timestamp/duration windows. The window start times are defined by range and step parameter. The window duration is defined by dur parameter. The last window's end timestamp is always before or equal to the range ending timestamp.

  • range: may be any date/datetime range supported by hisRead() or may be a history grid itself in which case the hisStart/hisEnd grid meta tags are used as the range
  • dur: Number with duration unit, standard unit is hour
  • step: Number with duration unit, standard unit is hour

See Windows and Slices

Example:

// create sliding 1hr windows every 30min
hisSlidingWindows(2011-07-04, 1hr, 30min)

// resulting grid
ts, v0
4-Jul-2011 00:00:00, 1hr
4-Jul-2011 00:30:00, 1hr
4-Jul-2011 01:00:00, 1hr
4-Jul-2011 01:30:00, 1hr
...

meta ​

deffunc:hisSlidingWindows
isfunc
liblib:hisKit
namehisSlidingWindows

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:hisTransitionWindows ​

hisTransitionWindows(src, dur, fn) ​

Compute a grid of timestamp/duration windows based on transitions of a history grid. The window duration is defined by the dur parameter. The transitions are determined by the fn parameter which is a function of (row, row) which returns trues to create a transition window.

The dur parameter may be one of the following:

Dur Value             Window
---------             -------
Positive Number       ts .. ts+dur
Negative Number       ts+dur .. ts
Range of two Numbers  ts+dur.start .. ts+dur.end

In all cases above the numbers must have a duration unit (hour is standard). The timestamp uses is always the later of the rows being compared. Here are some examples assuming transition time of 2:00:

15min          >>  2:00 to 2:15  // postive number
-15min         >>  1:45 to 2:00  // negative number
-20min..20min  >>  1:40 to 2:20  // range number
-1hr..-30min   >>  1:00 to 1:30  // window before transition
 1hr..2hr      >>  3:00 to 4:00  // window after transition

Example:

// input data (dates ignored)
ts, v0
00:00, false
08:00, true
17:00, false
19:00, true
20:00, false

// function to create transitions for the 30min window
// after each transition from true => false
hisTransitionWindows(src, 30min) (a,b) => a->v0 and not b->v0

// resulting grid of windows
ts, v0
17:00, 0.5hr
20:00, 0.5hr

See Windows and Slices


meta ​

deffunc:hisTransitionWindows
isfunc
liblib:hisKit
namehisTransitionWindows

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function