total_precip_sum_by_seasons = weatherDT
.derive({
yearGroup: aq.escape((obs) => {
for (let i = 0; i < yearStarts.length; i++) {
if ((obs.year >= yearStarts[i]) && (obs.year < yearStarts[i] + yearsGroupLen))
return yearStarts[i]
}
}),
period: aq.escape((obs) => {
if ((obs.year >= 1950) & (obs.year < 1980))
return 'reference'
else if (obs.year >= 2014)
return 'now'
else
return 'junk'
})
})
.select('city', 'date', 'yearGroup', 'year', 'season', 'precip_sum', 'period')
.groupby(['city', 'yearGroup', 'year', 'season', 'period'])
.rollup({
precip_sum: d => op.sum(d.precip_sum),
})
.groupby(['city', 'season', 'period'])
.rollup({
avg_precip_sum: d => op.mean(d.precip_sum),
})
.view()