Pass a `[TSDataPoint]` directly to `normalize` function

#1

To save effort when you want to see what function normalize does with your raw measurements of type TSDataPoint stored in a JavaScript array, you can do this:

var raw1 = [
    {type:"TSDataPoint",value:1252,unit:{id:"kilowatt_hour"},
     start:"2017-06-04T22:00:00.000",isEstimated:false,dataVersion:369},
    {type:"TSDataPoint",value:2182,unit:{id:"kilowatt_hour"},
     start:"2017-06-04T23:00:00.000",isEstimated:false,dataVersion:955},
...]

var str = C3.typesys.Stream(TSDataPoint, raw1, false)
var tss = YourNormalizer.normalize(str, spec1)

So, no need to persist data nor to link to other objects. The spec1 looks like:

var spec1 = {
  type:"TSNormalizationSpec",
  header: {
    type:"PointPhysicalMeasurementSeries",
... // not necessary, just for pattern-matching
    id:"9bdca0da-7378-4b73-7aa6-0163cf8a5134-13",
    name:"test_CustomNormalizer_PointPhysicalMeasurementSeries-1",
    meta: {...},
    unitConstraint: {
      id:"kilowatt_hour"
    },
    treatment:"rate",
    multiplier:1,
    asset: {
      id:"9bdca0da-7378-4b73-7aa6-0163cf8a5134-11"
    },
    interval:"HOUR",
  },
  normInterval:"HOUR",
  tsField:"quantity"
}
0 Likes