What is samples in the evalscript

For the evalscript posted below, as shown in evaluatePixel(samples) method, i would like to know:

1- what samples is? and what is samples.length?does sample.length is the number of acquisition times?
For example, for the following time-series: TS1: 01.02.2024 and TS: 30.05.2024, if we assumed that withing the aforementioned times-series there were 7 acquisition times, does that mean that sample.length will return 7?!!

2-for the contents of samples, does it values of NDVI with cloude coverage or without it please?


   // Script to extract a time series of NDVI values using 
  // Sentinel 2 Level 2A data and  metadata file.
  function setup() {
	return {
	  input: [{
		bands: ["B04", "B08"],
		units: "DN"
	  output: [
	  id: "default",
	  bands: 1,
	  sampleType: "FLOAT32",
	  nodataValue: NaN,
	  mosaicking: Mosaicking.ORBIT

  function updateOutput(output, collection) {
	output.default.bands = collection.scenes.length

  function evaluatePixel(samples) {
	// Precompute an array to contain NDVI observations
	var n_observations = samples.length;
	let ndvi = new Array(n_observations).fill(NaN);
  //Fill the array with NDVI values
	samples.forEach((sample, index) => {
	  ndvi[index] = (sample.B08 - sample.B04) / (sample.B08 + sample.B04) ;
	return ndvi;

Hello Burkhard,

You are right in your assumptions. samples holds the band values with cloud coverage. It’s on you to filter out clouds or other missing values.

If you have 7 acquisitions over your area of interest it holds 7 items, so samples.length would be 7.

But do keep in mind that it will only ever hold the values for a single pixel of the image you are requesting. That is why it is called evaluatePixel. This function will be applied to every single pixel in your output image individually.

In the case of mosaicking: ORBIT it will give you an array of all 7 values which are in the time of interest. So samples is correct it will give you all values for that pixel which are available.

You can have a look at how samples is structured by running

  function evaluatePixel(samples) {
	throw new Error(JSON.stringify(samples))

How those 7 values are handled is entirely up to you. samples just returns the raw values. You can do whatever you want with them. If you want a temporal average you need to sum up all the values in the samples array and divide them by the length.

If you mean the structure of the samples object which evaluatePixel gets, then you can find the information here: Evalscript V3