Locally Constant Values
Seeq Formula strives to offer an expressive way for users to perform time series calculations and compute new values for their analyses. Most of the available functions focus on the data, but some functions also manipulate the metadata. What’s the difference between data and metadata?
Data are the values you see on screen, the samples in a signal, capsules in a condition or other calculation results. For timeseries, the data is relative to your investigation range
Metadata is information about the data that is independent of the data. This includes units, interpolation method, and series-specific controls like maximum interpolation and maximum duration.
It is critical that data and metadata don’t mix. The trouble is, in formula expressions, it’s difficult to distinguish the two syntactically. An example of mixing the two concepts is
$newPeriod = $signal2.estimateSamplePeriod(capsule('February 2020'))
$signal1.resample($newPeriod)
Here, we’re picking a new sampling rate for $signal1
using the measured sampling rate of $signal2
. It’s not just that the result has samples spaced at a new interval, but that it also has a new maximum interpolation of that interval. The metadata of the result says that you’ll be interpolate between any 2 samples that are less than $newPeriod apart.
In order to work, resample must have a value that does not depend on data. Your new formula might look like
// To figure out this value, I used
// $signal2.estimateSamplePeriod(capsule('February 2020'))
$newPeriod = 2min
$signal1.resample($newPeriod)
We can clearly see that $newPeriod
is constant, but it doesn’t have to be literal. You can parameterize $newPeriod
into a separate scalar formula and reuse it in multiple formulas and still satisfy the data/metadata separation rule.
Examples of functions that manipulate metadata:
$signal.setMaxInterpolation($value)
$signal.resample($period)
$condition.grow($amount)
$condition.removeLongerThan($maxDuration)
$signal.setUnits($unit)