Skip to content

Commit 7b1b0e7

Browse files
new sentinel-5p NO2 monthly mean custom script
1 parent a9b5776 commit 7b1b0e7

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: NO2 Monthly mean
3+
parent: Sentinel-5p
4+
grandparent: Sentinel
5+
layout: script
6+
permalink: /sentinel-5p/no2_monthly_mean/
7+
nav_exclude: true
8+
examples:
9+
- zoom: '8'
10+
lat: '46.60228'
11+
lng: '15.17212'
12+
datasetId: S5_NO2
13+
fromTime: '2024-12-28T00:00:00.000Z'
14+
toTime: '2025-01-28T23:59:59.999Z'
15+
platform:
16+
- CDSE
17+
- EOB
18+
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel/sentinel-5p/no2_monthly_mean/script.js
19+
---
20+
21+
The layout `script` automatically adds the title defined in the front matter and adds buttons to visualize the script. For the buttons to work the evalscript has to be named `script.js` and must be in the same directory as the `README.md` file.
22+
23+
## General description of the script
24+
25+
This script calculates the mean values of NO<sub>2</sub> over the time period you select. It is useful for visualizing large-scale patterns of air pollution.
26+
In order to comply with the SI unit definitions, the TROPOMI NO2 data product gives trace gas concentrations in mol/m<sup>2</sup>.
27+
28+
Cloud-affected pixels are masked from Sentinel-5P air pollution imagery, you will see them as empty pixels on the map. Due to the relatively low resolution of Sentinel-5P TROPOMI, these datasets work best at regional to continental scale, however, at such scales it is extremely rare to encounter an image that is not influenced by clouds. Therefore, similar to [Sentinel-2 quarterly mosaics](https://dataspace.copernicus.eu/news/2024-2-27-exploring-new-frontier-sentinel-cloudless-mosaics-copernicus-data-space-ecosystem), creating longer-term mean mosaics of Sentinel-5P data enables exploring pollution patterns across regions.
29+
30+
The script is written to work for NO2, but can be used for other Sentinel-5P data layers as well by manually changing the variable "NO2" in the setup function and in the sum(array) function.
31+
32+
## References
33+
34+
- Sentinel-5P TROPOMI NO2 data products Algorithm Theoretical Basis Document: https://sentiwiki.copernicus.eu/__attachments/1673595/S5P-KNMI-L2-0005-RP%20-%20Sentinel-5P%20TROPOMI%20ATBD%20NO2%20data%20products%202022%20-%202.4.0.pdf?inst-v=9aab56a9-2b0f-4066-9dbe-4985b055a039
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//VERSION=3
2+
// By Jonas Viehweger, Sinergise
3+
4+
var minVal = 0.0;
5+
var maxVal = 0.0001;
6+
const map = [
7+
[0, 0x00007f],
8+
[1, 0x0000ff],
9+
[2, 0x00ffff],
10+
[3, 0xffff00],
11+
[4, 0xff0000],
12+
[5, 0x7f0000]
13+
];
14+
const visualizer = new ColorRampVisualizer(map, minVal, maxVal)
15+
function setup() {
16+
return {
17+
input: ["NO2","dataMask"],
18+
output: [
19+
{ id: "default", bands: 4 },
20+
{ id: "index", bands: 1, sampleType: "FLOAT32" },
21+
{ id: "eobrowserStats", bands: 1, sampleType: "FLOAT32"},
22+
{ id: "dataMask", bands: 1 },
23+
],
24+
mosaicking: "ORBIT"
25+
};
26+
}
27+
function isClear(sample) {
28+
return sample.dataMask == 1;
29+
}
30+
function sum(array) {
31+
let sum = 0;
32+
for (let i = 0; i < array.length; i++) {
33+
sum += array[i].NO2;
34+
}
35+
return sum;
36+
}
37+
function evaluatePixel(samples) {
38+
const clearTs = samples.filter(isClear)
39+
const mean = sum(clearTs) / clearTs.length
40+
const [r, g, b] = visualizer.process(mean);
41+
const dataMask = clearTs.length > 0;
42+
return {
43+
default: [r, g, b, dataMask],
44+
index: [mean],
45+
eobrowserStats: [mean],
46+
dataMask: [dataMask],
47+
};
48+
}

0 commit comments

Comments
 (0)