weather_big3 = {
const map_nuts3 = new Map([
[403, "DE300"],
[1975, "DE600"],
[3379, "DE212"]
]);
aq.addFunction("map_stations", (id) => map_nuts3.get(id), { override: true });
aq.addFunction(
"parse_ts",
(ts) => {
const date = new Date(ts);
const year = date.getUTCFullYear();
const month = date.getUTCMonth();
const day = date.getUTCDate();
const hour = date.getUTCHours();
return op.datetime(year, month, day, hour);
},
{
override: true
}
);
aq.addFunction("formatd3", d3.timeFormat("%b %d"), { override: true });
var raw = await aq.loadArrow(
await FileAttachment("weather_big3_20210824.arrow").url()
);
raw = raw
.derive(
{ nuts3: (d) => op.map_stations(d.stations_id) },
{ before: "date" }
)
.derive({ datetime: (d) => op.parse_ts(d.date) }, { before: "temp_mean" })
.derive({ date_label: (d) => op.formatd3(d.date) })
.select(aq.not("stations_id", "date"));
return raw;
}