Skip to main content

after reading SampleType: what’s all the fuss about? | by Maxim Lamare | Sentinel Hub Blog | Medium i tried to alter an eval script in the hope to reduce processing units but there seems to have been no impact. is there something im missing?

original eval script

//VERSION=3
function setup() {
return {
input: [{
bands: [“VH”,“VV”, “dataMask”]
}],
output: [
{
id: “s1_vh”,
bands: 1
},
{
id: “s1_vv”,
bands: 1
},
{
id: “s1_ratio”,
bands: 1
},
{
id: “dataMask”,
bands: 1
}]
};
}

function toDb(linear){
return 10 * Math.LN10 * linear
}

function evaluatePixel(samples) {
let vh_Db = toDb(samples.VH)
let vv_Db = toDb(samples.VV)
let s1_ratio = vh_Db / vv_Db
return {
s1_vh: [vh_Db],
s1_vv: [vv_Db],
s1_ratio: [s1_ratio],
dataMask: [samples.dataMask],
};
}

edited eval script

//VERSION=3
function setup() {
return {
input: [{
bands: [“VH”,“VV”, “dataMask”]
}],
output: [
{
id: “s1_vh”,
bands: 1,
sampleType: “UINT16”
},
{
id: “s1_vv”,
bands: 1,
sampleType: “UINT16”
},
{
id: “s1_ratio”,
bands: 1,
sampleType: “UINT16”
},
{
id: “dataMask”,
bands: 1
}]
};
}

function toDb(linear){
return 10 * Math.LN10 * linear
}

function evaluatePixel(samples) {
let vh_Db = toDb(samples.VH)
let vv_Db = toDb(samples.VV)
let s1_ratio = vh_Db / vv_Db
let s1_ratio_scale = s1_ratio * 50000
let vh_scale = samples.VH * 40000
let vv_scale = samples.VV * 40000

  return {
      s1_vh: [vh_scale],
      s1_vv: [vv_scale],
      s1_ratio: [s1_ratio_scale],
      dataMask: [samples.dataMask],
  };

}

Hi,

I tested your script using statistical api and it does reduce cost of PUs to half.

Note that when using Batch Statistical API there’s a minimal cost of 100 PUs for each request. Could this be the reason of the same PU usage for your test requests using the different Evalscript?