Public
Edited
Jan 28
15 stars
Insert cell
Insert cell
Plot.plot({
title: "Net flux, 2000 — 2024",
subtitle:
"Net flux is a measure of the energy gained or lost by the Earth. Incoming sunlight adds energy, heat radiated into space removes energy. The difference is the net flux. Over the past 25 years the Earth has been gradually retaining more energy than it loses.",
width,
x: { axis: null },
fx: { tickFormat: Plot.formatMonth() },
y: { inset: 10 },
marks: [
Plot.frame(),
Plot.gridY(),
Plot.linearRegressionY(data, {
x: "year",
y: "flux",
fx: "month",
fill: null
}),
Plot.dot(data, {
x: "year",
y: "flux",
fx: "month",
fill: "steelblue",
r: 1.5,
tip: { format: { fx: Plot.formatMonth(), x: "" } }
})
]
})
Insert cell
Insert cell
netcdf = import("https://cdn.skypack.dev/netcdfjs@2.0.2?min").then((d) => d.NetCDFReader)
Insert cell
reader = FileAttachment("CERES_EBAF-TOA_Ed4.2.1_Subset_200003-202409.nc")
.arrayBuffer()
.then((d) => new netcdf(d))
Insert cell
data = d3
.zip(
Array.from(reader.getDataVariable("time"), (d) =>
d3.utcDay.offset(new Date("2000-03-01"), d)
),
reader.getDataVariable("gtoa_net_all_mon")
)
.map(([date, flux]) => ({
date,
year: date.getUTCFullYear(),
month: date.getUTCMonth(),
flux
}))
Insert cell
Insert cell
Plot.lineY(data, { x: "date", y: "flux" }).plot()
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.linearRegressionY(data, { x: "year", y: "flux", fx: "month" }),
Plot.lineY(data, { x: "year", y: "flux", fx: "month" })
]
})
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