-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from sentinel-hub/add/eob-stat-output-to-scripts
add eob script to S3 OLCI OTCI
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
}; | ||
} |