Skip to content

Commit

Permalink
add UK
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs committed Aug 15, 2024
1 parent 6101cb0 commit 41eff67
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/components/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {html} from "npm:htl";

import { tableReshape, normalizePollutantLabel, normalizeUnitsLabel } from '../utils/utils.js';

export function breakpointsTable(data) {
export function breakpointsTable(data, range=true) {

const headerColumns = data.map((i) => html`<th>${i.category}<br/>${i.categoryLower}${i.categoryUpper ? `-${i.categoryUpper}`: '+'}</th>`)
const headerColumns = data.map((i) => html`<th>${i.category}<br/>${i.categoryLower}${i.categoryUpper ? `-${i.categoryUpper}`: range ? '+': ''}</th>`)


return html`<table>
Expand All @@ -21,7 +21,7 @@ export function breakpointsTable(data) {
const pollutantLabel = normalizePollutantLabel(measurand)
const unitsLabel = normalizeUnitsLabel(units)
const avgPeriod = o[0].split('-')[1];
return html`<tr><td>${pollutantLabel} ${unitsLabel}</td><td>${avgPeriod} hr.</td>${o.slice(1)[0].map(i => html`<td>${i.concentrationLower ? i.concentrationLower : '-'}${i.concentrationLower ? i.concentrationUpper ? `-${i.concentrationUpper}`: '+' : ''}</td>`)}</tr>`
return html`<tr><td>${pollutantLabel} ${unitsLabel}</td><td>${avgPeriod} hr.</td>${o.slice(1)[0].map(i => html`<td>${i.concentrationLower ? i.concentrationLower : '-'}${i.concentrationLower ? i.concentrationUpper ? `-${i.concentrationUpper}`: '+' : ''}</td>`)}</tr>`
})}
</tbody>
</table>`
Expand Down
51 changes: 51 additions & 0 deletions docs/data/uk/breakpoints.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ISO,variant,category,hex,category_lower,category_upper,pollutant,units,averaging_period,concentration_lower,concentration_upper
GB,,Low,#9cff9c,1,,O3,ug/m3,8,0,33
GB,,Low,#9cff9c,1,,NO2,ug/m3,1,0,67
GB,,Low,#9cff9c,1,,SO2,ug/m3,15,0,88
GB,,Low,#9cff9c,1,,PM2.5,ug/m3,24,0,11
GB,,Low,#9cff9c,1,,PM10,ug/m3,24,0,16
GB,,Low,#31ff00,2,,O3,ug/m3,8,34,66
GB,,Low,#31ff00,2,,NO2,ug/m3,1,68,134
GB,,Low,#31ff00,2,,SO2,ug/m3,15,89,177
GB,,Low,#31ff00,2,,PM2.5,ug/m3,24,12,23
GB,,Low,#31ff00,2,,PM10,ug/m3,24,17,33
GB,,Low,#31cf00,3,,O3,ug/m3,8,67,100
GB,,Low,#31cf00,3,,NO2,ug/m3,1,135,200
GB,,Low,#31cf00,3,,SO2,ug/m3,15,178,266
GB,,Low,#31cf00,3,,PM2.5,ug/m3,24,24,35
GB,,Low,#31cf00,3,,PM10,ug/m3,24,34,50
GB,,Moderate,#ffff00,4,,O3,ug/m3,8,101,120
GB,,Moderate,#ffff00,4,,NO2,ug/m3,1,201,267
GB,,Moderate,#ffff00,4,,SO2,ug/m3,15,267,354
GB,,Moderate,#ffff00,4,,PM2.5,ug/m3,24,36,41
GB,,Moderate,#ffff00,4,,PM10,ug/m3,24,51,58
GB,,Moderate,#ffcf00,5,,O3,ug/m3,8,121,140
GB,,Moderate,#ffcf00,5,,NO2,ug/m3,1,268,334
GB,,Moderate,#ffcf00,5,,SO2,ug/m3,15,355,443
GB,,Moderate,#ffcf00,5,,PM2.5,ug/m3,24,42,47
GB,,Moderate,#ffcf00,5,,PM10,ug/m3,24,59,66
GB,,Moderate,#ff9a00,6,,O3,ug/m3,8,141,160
GB,,Moderate,#ff9a00,6,,NO2,ug/m3,1,335,400
GB,,Moderate,#ff9a00,6,,SO2,ug/m3,15,444,532
GB,,Moderate,#ff9a00,6,,PM2.5,ug/m3,24,48,53
GB,,Moderate,#ff9a00,6,,PM10,ug/m3,24,67,75
GB,,High,#ff9292,7,,O3,ug/m3,8,161,187
GB,,High,#ff9292,7,,NO2,ug/m3,1,401,467
GB,,High,#ff9292,7,,SO2,ug/m3,15,533,710
GB,,High,#ff9292,7,,PM2.5,ug/m3,24,54,58
GB,,High,#ff9292,7,,PM10,ug/m3,24,76,83
GB,,High,#ff0000,8,,O3,ug/m3,8,188,213
GB,,High,#ff0000,8,,NO2,ug/m3,1,468,534
GB,,High,#ff0000,8,,SO2,ug/m3,15,711,887
GB,,High,#ff0000,8,,PM2.5,ug/m3,24,59,64
GB,,High,#ff0000,8,,PM10,ug/m3,24,84,91
GB,,High,#990000,9,,O3,ug/m3,8,214,240
GB,,High,#990000,9,,NO2,ug/m3,1,535,600
GB,,High,#990000,9,,SO2,ug/m3,15,888,1064
GB,,High,#990000,9,,PM2.5,ug/m3,24,65,70
GB,,High,#990000,9,,PM10,ug/m3,24,92,100
GB,,Very high,#ce30ff,10,,O3,ug/m3,8,241,
GB,,Very high,#ce30ff,10,,NO2,ug/m3,1,601,
GB,,Very high,#ce30ff,10,,SO2,ug/m3,15,1065,
GB,,Very high,#ce30ff,10,,PM2.5,ug/m3,24,71,
GB,,Very high,#ce30ff,10,,PM10,ug/m3,24,101,
83 changes: 83 additions & 0 deletions docs/indices/uk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# United Kingdom

## Daily Air Quality Index (DAQI)

## Overview

The United Kingdom’s Daily Air Quality Index (DAQI) accounts for five primary pollutants: PM2.5, PM10, O3, NO2 and SO2. The DAQI displays the air quality for the previous day. A forecast AQI also provides information on predicted pollutant levels for the next 5 days.

The United Kingdom Department for Environment Food & Rural Affairs (DEFRA) has developed the Daily Air Quality Index (DAQI). Following a review, Defra and the Devolved Administrations replaced the older UK Air Quality Index with the Daily Air Quality Index (DAQI) in 2012 [^3].

## Color scale

```js

import {breakpointsTable} from "../components/table.js";
import { parseBreakpointsCsv, tableReshape, colorScaleReshape } from '../utils/utils.js';
import { colorScale } from '../components/color-scale.js';

```

```js

const breakpoints = await FileAttachment('../data/uk/breakpoints.csv').text();
const data = parseBreakpointsCsv(breakpoints);

```

The composite index uses a four color color scale:

```js
colorScale(colorScaleReshape(data, false))
```

Note: Adapted from “Daily Air Quality Index” (n.d.), [https://uk-air.defra.gov.uk/air-pollution/daqi](https://uk-air.defra.gov.uk/air-pollution/daqi) [^4]. Accessed August 12, 2024.

Sub-indexes have a separate, expanded color scale:

```js
colorScale([
{ label: 'Low', color: '#9cfe9c' },
{ label: 'Low', color: '#30fe00'},
{ label: 'Low', color: '#30ce00' },
{ label: 'Moderate', color: '#fffe00' },
{ label: 'Moderate', color: '#fecf02'},
{ label: 'Moderate', color: '#fe9a01'},
{ label: 'High', color: '#ff6363' },
{ label: 'High', color: '#ff0000'},
{ label: 'High', color: '#990000' },
{ label: 'Very High', color: '#ce30fe'},
])
```

Note: Adapted from “Guide to UK Air Pollution Information
Resources” (June 2014), [https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf](https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf) [^1]. Accessed August 12, 2024.

## Methods

The sub-index DAQI values range from 1 to 10 and each correspond to a different category [^1]. The ‘Low’ category corresponds to index values 1 to 3, ‘Moderate’ from 4 to 6, ‘High’ from 7 to 9, and ‘Very high’ equal to 10. The DAQI is determined by the maximum concentration of the pollutants [^2].

Recorded pollutant data is assigned a sub-index value 1 through 10 according to the respective pollutant concentration banding.

```js
breakpointsTable(data, false)
```

Note: Adapted from “Guide to UK Air Pollution Information
Resources” (June 2014), [https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf](https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf) [^1]. Accessed August 12, 2024.

The maximum sub-index is used as the overall DAQI for that station. It is reported as its respective category and corresponding color. All pollutant concentration values should be rounded to the nearest whole number integer value before applying it to the concentration breakpoints [^3]. For the 8-hour and daily mean concentration calculations, un-rounded hourly means should be used [^3].

When calculating the hourly, 8-hour or daily mean concentration, at least a 75% coverage rate is required. For calculating the hourly mean, at least 3 15 minute mean concentrations are required. For calculating an 8-hour mean, at least 6 hourly mean concentration values are required. For calculating a daily mean, 18 hourly mean concentrations are required.

## References

Forecasting: [https://uk-air.defra.gov.uk/forecasting/](https://uk-air.defra.gov.uk/forecasting/)

[^1]: [https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf](https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1406191156_060618_Guide_to_UK_Air_Pollution_Information_Resources-issue_2-FINAL.pdf)

[^2]: [https://uk-air.defra.gov.uk/air-pollution/daqi?view=more-info](https://uk-air.defra.gov.uk/air-pollution/daqi?view=more-info)

[^3]: [https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1304251155_Update_on_Implementation_of_the_DAQI_April_2013_Final.pdf](https://uk-air.defra.gov.uk/assets/documents/reports/cat14/1304251155_Update_on_Implementation_of_the_DAQI_April_2013_Final.pdf)

[^4]: [https://uk-air.defra.gov.uk/air-pollution/daqi](https://uk-air.defra.gov.uk/air-pollution/daqi)
2 changes: 1 addition & 1 deletion docs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const tableReshape = (data) => data.reduce((acc, { category, categoryLowe
}, {});


export const colorScaleReshape = (data) => data.map(o => {return { label: o.category, color: o.hex, range: `${o.categoryLower}${o.categoryUpper ? `-${o.categoryUpper}`: '+'}` }});
export const colorScaleReshape = (data, range=true) => data.map(o => {return { label: o.category, color: o.hex, range: `${o.categoryLower}${o.categoryUpper ? `-${o.categoryUpper}`: range ? '+' : ''}` }});

export function normalizePollutantLabel(value) {
switch (value) {
Expand Down
1 change: 1 addition & 0 deletions observablehq.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default {
{name: "Taiwan", path: "/indices/taiwan"},
{name: "Thailand", path: "/indices/thailand"},
{name: "UAE", path: "/indices/uae"},
{name: "UK", path: "/indices/uk"},
{name: "US", path: "/indices/us"},
{name: "Vietnam", path: "/indices/vietnam"},
]
Expand Down

0 comments on commit 41eff67

Please sign in to comment.