Skip to content

Commit

Permalink
Merge pull request #310 from sentinel-hub/add/eob-stat-output-to-scripts
Browse files Browse the repository at this point in the history
add eob script to S3 OLCI OTCI
  • Loading branch information
dthiex authored Apr 30, 2024
2 parents 815604d + 34f3f3d commit 1350003
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sentinel-3/otci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ grand_parent: Sentinel
layout: script
permalink: /sentinel-3/otci/
nav_exclude: true
scripts:
- - Visualization
- script.js
- - EO Browser
- eob.js
examples:
- zoom: '7'
lat: '44.868'
Expand All @@ -15,7 +20,7 @@ examples:
- CDSE
- EOB
datasetId: S3OLCI
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-3/otci/script.js
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-3/otci/eob.js
---

## Description
Expand Down
40 changes: 40 additions & 0 deletions sentinel-3/otci/eob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//VERSION=3
const map = [
[0.0, 0x00007d],
[1.0, 0x004ccc],
[1.8, 0xff3333],
[2.5, 0xffe500],
[4.0, 0x00cc19],
[4.5, 0x00cc19],
[5.0, 0xffffff],
];

const visualizer = new ColorRampVisualizer(map);
function setup() {
return {
input: ["B10", "B11", "B12", "dataMask"],
output: [
{ id: "default", bands: 4 },
{ id: "index", bands: 1, sampleType: "FLOAT32" },
{ id: "eobrowserStats", bands: 1 },
{ id: "dataMask", bands: 1 },
],
};
}

function evaluatePixel(samples) {
let OTCI = (samples.B12 - samples.B11) / (samples.B11 - samples.B10);
let imgVals = null;
// The library for tiffs works well only if there is only one channel returned.
// So we encode the "no data" as NaN here and ignore NaNs on frontend.
// we restrict the interval to [-10, 10] as it covers most of the value range
const indexVal =
samples.dataMask === 1 && OTCI >= -10 && OTCI <= 10 ? OTCI : NaN;
imgVals = [...visualizer.process(OTCI), samples.dataMask];
return {
default: imgVals,
index: [indexVal],
eobrowserStats: [indexVal],
dataMask: [samples.dataMask],
};
}

0 comments on commit 1350003

Please sign in to comment.