Public
Edited
Nov 22, 2022
Insert cell
Insert cell
db
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
// the Array.from() below nukes the NaN value but we can make do with a bounds check
buoy_data = buoys.flatMap((d) => processBuoy(d)).filter((d) => d.temp < 50)
Insert cell
function processBuoy(buoy) {
const temp = Array.from(new Float32Array(buoy.getDataVariable("T_25")));
const ts = Array.from(new Float32Array(buoy.getDataVariable("time")));
const lng = new Float32Array(buoy.getDataVariable("lon"));
const lat = new Float32Array(buoy.getDataVariable("lat"));
const start = new Date("1998-02-15");

function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}

return d3.zip(temp, ts).map((d) => ({
lng: lng[0] > 180 ? -360 + lng[0] : lng[0],
lat: lat[0],
temp: d[0],
ts: addDays(start, Math.trunc(d[1]))
}));
}
Insert cell
buoys[0].variables
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more