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: b

{

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: vs1_ratio],

dataMask: rsamples.dataMask],

};

}


edited eval script


//VERSION=3

function setup() {

return {

input: >{

bands: “VH”,“VV”, “dataMask”]

}],

output: k

{

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: svh_scale],
s1_vv: rvv_scale],
s1_ratio: _s1_ratio_scale],
dataMask: ssamples.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?


Reply