esnet / esnet/pond

fixedWindowRollup example needed

Open
#293 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
211
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Could you show me how to use `fixedWindowRollup` because I can't figure out what I'm doing wrong.

I'd like to resample a dataset to have uniform timestamps, so here is the code I'm using based on doc and what I see in the source:

```
const data = res.map((data: any) => {
return {
timestamp: new Date(data.End).getTime(),
value: data.Value,
}
})

const ts = timeSeries({
points: data.map((entry: any) => [entry.timestamp, entry.value]),
columns: ["time", "value"],
name: "data",
})
.fixedWindowRollup({
window: window(duration("1day")),
//aggregation: { value: { value: avg() } }, //ts compiler complains
aggregation: {value: ["value", avg()]},
})
.eventList().map(e => {
return {
timestamp: e?.timestamp().getTime(),
value: e?.get("value")
}
});
```

but the `fixedWindowRollup` returns that error:

```
TypeError: Cannot read properties of undefined (reading 'mid')
at Index.timestamp (project/node_modules/pondjs/src/index.ts:89:32)
at Event.timestamp (project/node_modules/pondjs/src/event.ts:578:30)
at project/node_modules/pondjs/src/collection.ts:839:23
at List.__iterate (project/node_modules/immutable/dist/immutable.js:3370:13)
at List.forEach (project/node_modules/immutable/dist/immutable.js:4899:19)
at SortedCollection.forEach (project/node_modules/pondjs/src/collection.ts:425:29)
at SortedCollection.isChronological (project/node_modules/pondjs/src/collection.ts:837:14)
at new SortedCollection (project/node_modules/pondjs/src/sortedcollection.ts:43:20)
at project/node_modules/pondjs/src/windowedcollection.ts:177:51
at project/node_modules/immutable/dist/immutable.js:2488:31
at project/node_modules/immutable/dist/immutable.js:2506:18
```

btw I'm using syntax from version `1.0.0-alpha.0` because latest version didn't work with my ts compiler ...

Thanks for any hint!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.