Public
Edited
Sep 17, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
globalMap = Plot.plot({
color: {
type: "threshold",
scheme: "BuRd",
domain: [0.25, 0.5, 0.75, 0.95, 0.99].map((d) =>
d3.quantile(valuesForLegend, d)
)
},
projection: {
type: "mercator",
domain: circle
},
marks: [
Plot.geo(land, { fill: "lightgrey", stroke: "#aaa", strokeWidth: 0.5 }),
Plot.graticule(),
Plot.geo(circle, {
stroke: "#bbb",
strokeWidth: 1,
strokeDasharray: "5,3"
}),
Plot.dot(
dataWithinRadius,
Plot.hexbin(
{
fill: (g) => d3[aggType](g, (d) => d.activity),
title: (g) =>
`${nuclide} (${aggType}): ${d3[aggType](g, (d) => d.activity)}`
},
{
x: "longitude",
y: "latitude",
fillOpacity: 0.9,
symbol: "hexagon",
stroke: "black",
strokeWidth: 0.5,
strokeOpacity: 0.5,
binWidth: 6,
tip: true
}
)
),
Plot.geo(WISPolygon),
Plot.geo(WOIPolygon),
Plot.geo(EISPolygon)
]
})
Insert cell
Insert cell
Plot.plot({
width,
inset: 8,
y: {
type: logscale ? "log" : "linear"
},
grid: true,
color: {
legend: true,
type: "categorical",
scheme: "tableau10"
},
marks: [
Plot.dot(
dataInBoxes,
{ x: "begPeriod", y: "activity", tip: true, fill: "roi" }
)
]
})
Insert cell
Insert cell
Insert cell
timePlot1 = Plot.plot({
width,
height: 500,
// color: { scheme: "OrRd" },
// color: {
// scheme: "Category10",
// type: "categorical"
// },
color: {
domain: [
"Eastern region of the Irish Sea",
"Western region of the Irish Sea",
"West of Ireland"
],
range: ["#1b9e77", "#7570b3", "#d95f02"] // Colorbind-safe
},
y: { type: logscale ? "log" : "linear" },
marks: [
Plot.dot(
dataInBoxes,
{
x: "begPeriod",
y: "activity",
fill: "roi",
stroke: "roi",
r: 3,
fillOpacity: 0.4,
strokeWidth: 0.5,
strokeOpacity: 0.4
}
// Plot.hexbin(
// { fill: "count" },
// {
// x: "begPeriod",
// y: "activity",

// symbol: "hexagon",
// fillOpacity: 0.9,
// stroke: "black",
// strokeWidth: 0.5,
// strokeOpacity: 0.5,
// binWidth: 7,
// tip: true
// }
// )
),
Plot.lineY(
dataInBoxes,
Plot.windowY(
{
k:
dataInBoxes.length > 0
? dataInBoxes.length /
((dataInBoxes[dataInBoxes.length - 1].begPeriod -
dataInBoxes[0].begPeriod) /
(3600 * 24 * 365.25 * 1000))
: 1,
reduce: "median"
},
{
x: "begPeriod",
y: "activity",
z: "roi",
stroke: "roi",
strokeWidth: 2
}
)
)
// Plot.text(
// dataInBoxes,
// Plot.selectLast({
// x: "begPeriod",
// y: "activity",
// z: "roi",
// fill: "roi",
// textAnchor: "end",
// text: "roi",
// lineAnchor: "top",
// lineWidth: 10
// // dx: 3,
// // dy: -8
// })
// )
]
})
Insert cell
hexTimeChart = Plot.plot({
width,
color: { scheme: "OrRd" },
y: { type: logscale ? "log" : "linear" },
marks: [
Plot.dot(
dataInBoxes,
Plot.hexbin(
{ fill: "count" },
{
x: "begPeriod",
y: "activity",

symbol: "hexagon",
fillOpacity: 0.9,
stroke: "black",
strokeWidth: 0.5,
strokeOpacity: 0.5,
binWidth: 7,
tip: true
}
)
),
Plot.lineY(
dataInBoxes,
Plot.windowY(
{
k:
dataInBoxes.length > 0
? dataInBoxes.length /
((dataInBoxes[dataInBoxes.length - 1].begPeriod -
dataInBoxes[0].begPeriod) /
(3600 * 24 * 365.25 * 1000))
: 1,
reduce: "median"
},
{ x: "begPeriod", y: "activity", z: "roi" }
)
),
Plot.text(
dataInBoxes,
Plot.selectLast({
x: "begPeriod",
y: "activity",
z: "roi",
textAnchor: "end",
text: "roi",
lineAnchor: "top",
lineWidth: 10,
dx: 3,
dy: -8
})
)
]
})
Insert cell
Plot.plot({
height: 300 ,
marginLeft: 150,
width,
y: {
label: "Region Of Interest"
},
marks: [
Plot.boxX(
dataInBoxes,
{ x: "activity", y: "roi", tip: true, fill: "roi" }
)
]
})
Insert cell
### Required for Map
Insert cell
land50m = d3.json("https://unpkg.com/world-atlas@2.0.2/land-50m.json ")
Insert cell
land = topojson.feature(land50m, land50m.objects.land)
Insert cell
Insert cell
valuesForLegend = dataWithinRadius.map((d) => d.activity)
Insert cell
Insert cell
MARIS API query parameters:
- Select data by specific IHO (shapeTypeId == 1) area_id (hardcoded) in order to speed up the query. This includes areaId = 9999 (unattributed). Is there are better way?
- sampleTypeId and nuclideId set by input.select control
- Sampling date >= 1 January 2010
- unitId Bq/m3 (seawater), Bq/kg, Bq/g C
Notes:
- Cannot select by detection, use post-processing filter to remove, e.g. "ND" values
Insert cell
params = ({
areaId: "1912,2350,2351,2357,2389,3141,4283,9999",
sampleTypeId: sampleType,
nuclideId: nuclide, // 137Cs
samplingDateFrom: "2010-01-01",
shapeTypeId: 1
})
Insert cell
dataRaw = getMeasurementData(params)
Insert cell
Insert cell
dataInterim = dataRaw.filter(
(d) => d.detection != "ND")
Insert cell
dataInterim2 =dataInterim.map((d) => ({ ...d, activity: (d["detection"] == "<") ? d["activity"]*0.5 : d["activity"]}))
Insert cell
Insert cell
### Data loading
Insert cell
data = dataRaw.map((d) => ({
...d,
begPeriod: new Date(d.begPeriod),
roi: getROI([d.longitude, d.latitude], [EISPolygon, WOIPolygon, WISPolygon])
}))
Insert cell
dataWithinRadius = data.filter(
(d) => d3.geoDistance([d.longitude, d.latitude], center) < kms / 6371
)
Insert cell
dataInBoxes = dataWithinRadius.filter((d) => d.roi != "Elsewhere").sort((a,b) => a.begPeriod - b.begPeriod)
Insert cell
Insert cell
center = [-5,53.5]
Insert cell
circle = d3
.geoCircle()
.center(center)
.radius((kms / (6371 * Math.PI * 2)) * 360)
.precision(10)()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { getMeasurementData, luts } from "@maris-iaea/api"
Insert cell
turf = require("@turf/turf@7")
Insert cell
function whatUnit(samptypeId) {
switch(samptypeId) {
case 1:
return "Bq/m<sup>3</sup>"
case 2:
return "Bq/kg f.w."
case 3:
return "Bq/kg d.w."
default:
return "Unknown"
}
}
Insert cell
function getDryWetFactor(biogroupId) {
switch(biogroupId) {
case 11:
return 0.167278970397589
case 4:
return 0.232254394570392
case 2:
return 0.226485185185185
case 14:
return 0.169374196277088
case 13:
return 0.232484162739303
case 12:
return 0.181976062091503
case 6:
return 0.194611473702632
case 5:
return 0.460238713453779
default:
return 1
}
}
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