Public
Edited
Nov 28, 2023
Insert cell
Insert cell
flowData = d3.csv(
"https://raw.githubusercontent.com/mschmidty/dolores_flow_predict/master/output/flow_data_all.csv"
)
Insert cell
bedrockFlowData = flowData
.filter((obs) => {
if (obs.site_id == "Bedrock") {
return obs;
}
})
.map((obs) => {
const dateSplit = obs.date.split("-");
const monthDay = dateSplit[1] + dateSplit[2];
obs["monthDay"] = monthDay;
obs["flow"] = parseInt(obs.flow);
obs["singleDate"] = new Date("1999-" + dateSplit[1] + "-" + dateSplit[2]);
return obs;
})
Insert cell
bedrockFlowData
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
combBedrockFlowData = tidy(
bedrockFlowData,
groupBy("singleDate", [
summarize({
min: min("flow"),
max: max("flow"),
median: median("flow")
})
]),
filter((d) => d.singleDate > new Date("1999-02-15")),
filter((d) => d.singleDate < new Date("1999-08-15"))
)
Insert cell
combBedrockFlowData
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
function arealineY(data, { color, fillOpacity = 0.1, ...options } = {}) {
return Plot.marks(
Plot.ruleY([0]),
Plot.areaY(data, { fill: color, fillOpacity, ...options }),
Plot.lineY(data, { stroke: color, ...options })
);
}
Insert cell
arealineY(combBedrockFlowData, {
x: "singleDate",
y: "max",
color: "steelBlue"
}).plot()
Insert cell
Plot.plot({
y: {
label: "Cubic Feet per Second (CFS)",
grid: true
},
marks: [
Plot.areaY(combBedrockFlowData, {
x: "singleDate",
y1: "max",
y2: "median",
fillOpacity: 0.2
})
]
})
Insert cell
flowDaysPerYear = d3.csv(
"https://raw.githubusercontent.com/mschmidty/dolores_flow_predict/master/output/number_of_flow_days_per_year_at_bedrock.csv"
)
Insert cell
flowDaysPerYearCL = flowDaysPerYear.map((year) => {
year["raftable_release_days"] = parseInt(year.raftable_release_days);
// year["year"] = parseInt(year.year);
return year;
})
Insert cell
Plot.plot({
marginLeft: 90,
x: { axis: null },
y: { label: null },
marks: [
Plot.barX(flowDaysPerYearCL, {
x: "raftable_release_days",
y: "year"
})
]
})
Insert cell
yr_2023 = flowDaysPerYearCL.filter((d) => {
return d.year == 2023;
})[0].raftable_release_days
Insert cell
currentPredictions = d3.csv(
"https://raw.githubusercontent.com/mschmidty/dolores_flow_predict/master/output/current_predictions.csv"
)
Insert cell
currentPredictions
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
import {
tidy,
groupBy,
summarize,
median,
min,
max,
filter
} from "@pbeshai/tidyjs"
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