Tar file contains always the last band listed without containing the rest

For the below posted evalscript and json request, at run time, i receive a tar file composed of only one band which is always has been the last one listed. in other words, for the bands specified in my question below, i receive a tar file contains only
percentageOfCloudy. When i comment out all the relevant code for percentageOfCloudy in both of the evalscript and json request, then i receive a tar contains only the band of percentageOfCloudFree and so on. i receive always a tar contains the
last band listed.

does this issue has any thing to do with sentinelhub api or it is related the backend

json request:

"input": {
	"bounds": {
	  "geometry": coordsInEPSG3857,
	  "properties": {
		"crs": "http://www.opengis.net/def/crs/EPSG/0/3857"
	  }
	},
	"data": [
	  {
		"dataFilter": {
		  "timeRange": {
			"from": sYear + "-" + sMonth + "-" + sDay + "T" + "00:00:00Z",
			"to": eYear + "-" + eMonth + "-" + eDay + "T" + "00:00:00Z"
		  }
		},
		"type": satMissionType
	  }
	]
  },
  "output": {
	// "width": 1535.8321176437041,
	// "height": 1646.6445869835497,
	// "resx": LSP,
	// "resy": LSP,
	"responses": [
		{
			"identifier": "default",
			"format": {
				"type": "image/tiff",
			},
			"identifier": "averages",
			"format": {
				"type": "image/tiff",
			},
			"identifier": "numOfCloudFreeSamples",
			"format": {
				"type": "image/tiff",
			},
			"identifier": "numOfCloudySamples",
			"format": {
				"type": "image/tiff",
			},
			 "identifier": "percentageOfCloudFree",
			 "format": {
			     "type": "image/tiff",
			 },
			 "identifier": "percentageOfCloudy",
			 "format": {
			     "type": "image/tiff",
			 }
		},
	]
  },
  "evalscript": evalscript,

evalscript:
//VERSION=3
// 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", "CLD"],
		units: "DN"
	  }],
	  output: [
		{
		  id: "default",
		  bands: 5,
		  sampleType: "FLOAT32",
		  nodataValue: NaN,
		},
		{
		  id: "averages",
		  bands: 1,
		  sampleType: "FLOAT32",
		  nodataValue: NaN,
		},
		{
		  id: "numOfCloudFreeSamples",
		  bands: 1,
		  sampleType: "FLOAT32",
		  nodataValue: NaN,
		},
		{
		  id: "numOfCloudySamples",
		  bands: 1,
		  sampleType: "FLOAT32",
		  nodataValue: NaN,
		},
		{
			id: "percentageOfCloudFree",
		   bands: 1,
		   sampleType: "FLOAT32",
		   nodataValue: NaN,
		 },
		 {
		   id: "percentageOfCloudy",
		   bands: 1,
		   sampleType: "FLOAT32",
		   nodataValue: NaN,
		}
	  ],
	  mosaicking: Mosaicking.ORBIT
	}
  }

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

  function samplesParser(samples) {
	const cloudFreeSamples = new Array();
	const cloudySamples = new Array();

	samples.forEach((sample) => {
	  if (sample.CLD > 0) {
		cloudySamples.push(sample);
	  } else {
		cloudFreeSamples.push(sample);
	  }
	});
	return [cloudySamples, cloudFreeSamples];
  }

  function calcAverage(samples) {
	let sum = 0;
	for(let i = 0;i < samples.length; i++) {
	  sum += samples[i];
	}
	let avg = sum / samples.length;
	return avg;
  }
  function calcNDVIForSamples(samples) {
	const ndvis = new Array(samples.length).fill(NaN);
	samples.forEach((sample, index) => {
	  ndvis[index] = (sample.B08 - sample.B04) / (sample.B08 + sample.B04) ;
	});
	return ndvis;
  }
  function calcPercentage(total, incidences) {
	if (total <= 0) {
	  return NaN;
	}
	return ((incidences / total) * 100);
  }
  function evaluatePixel(samples) {
	if (samples.length < 1) {
	  return {
		default: [NaN, NaN, NaN, NaN, NaN],
		averages: [NaN],
		numOfCloudFreeSamples: [NaN],
		numOfCloudySamples: [NaN],
		// percentageOfCloudFree: [NaN],
		// percentageOfCloudy: [NaN]
	  };
	}
	const parsedSamples = samplesParser(samples);
	const ndvis = calcNDVIForSamples(parsedSamples[1]);
	const averages = calcAverage(ndvis);
	const numOfCloudySamples = parsedSamples[0].length;
	const numOfCloudFreeSamples = parsedSamples[1].length;
	const totalNumOfSamples = numOfCloudySamples + numOfCloudFreeSamples;
	const percentageOfCloudy = calcPercentage(totalNumOfSamples, numOfCloudySamples);
	const percentageOfCloudFree = calcPercentage(totalNumOfSamples, numOfCloudFreeSamples);

	return {
	  default: [averages, numOfCloudFreeSamples, numOfCloudySamples, percentageOfCloudFree, percentageOfCloudy],
	  averages: [averages],
	  numOfCloudFreeSamples: [numOfCloudFreeSamples],
	  numOfCloudySamples: [numOfCloudySamples],
	  percentageOfCloudFree: [percentageOfCloudFree],
	  percentageOfCloudy: [percentageOfCloudy],
	};
  }

Hello Burkhard,

for me all outputs are included in the response using for example this similar request:

curl -X POST https://services.sentinel-hub.com/api/v1/process \
 -H 'Content-Type: application/json' \
 -H 'Authorization: Bearer '' \
 -H 'Accept: application/tar' \
 -d '{
  "input": {
    "bounds": {
      "bbox": [
        12.44693,
        41.870072,
        12.541001,
        41.917096
      ]
    },
    "data": [
      {
        "dataFilter": {
          "timeRange": {
            "from": "2024-05-13T00:00:00Z",
            "to": "2024-06-13T23:59:59Z"
          }
        },
        "type": "sentinel-2-l2a"
      }
    ]
  },
  "output": {
    "width": 512,
    "height": 343.697,
    "responses": [
      {
        "identifier": "default",
        "format": {
          "type": "image/tiff"
        }
      },
      {
        "identifier": "averages",
        "format": {
          "type": "image/tiff"
        }
      },
      {
        "identifier": "numOfCloudFreeSamples",
        "format": {
          "type": "image/tiff"
        }
      },
      {
        "identifier": "numOfCloudySamples",
        "format": {
          "type": "image/tiff"
        }
      },
      {
        "identifier": "percentageOfCloudFree",
        "format": {
          "type": "image/tiff"
        }
      },
      {
        "identifier": "percentageOfCloudy",
        "format": {
          "type": "image/tiff"
        }
      }
    ]
  },
  "evalscript": " function setup() {\n\treturn {\n\t  input: [{\n\t\tbands: [\"B04\", \"B08\", \"CLD\"],\n\t\tunits: \"DN\"\n\t  }],\n\t  output: [\n\t\t{\n\t\t  id: \"default\",\n\t\t  bands: 5,\n\t\t  sampleType: \"FLOAT32\",\n\t\t  nodataValue: NaN,\n\t\t},\n\t\t{\n\t\t  id: \"averages\",\n\t\t  bands: 1,\n\t\t  sampleType: \"FLOAT32\",\n\t\t  nodataValue: NaN,\n\t\t},\n\t\t{\n\t\t  id: \"numOfCloudFreeSamples\",\n\t\t  bands: 1,\n\t\t  sampleType: \"FLOAT32\",\n\t\t  nodataValue: NaN,\n\t\t},\n\t\t{\n\t\t  id: \"numOfCloudySamples\",\n\t\t  bands: 1,\n\t\t  sampleType: \"FLOAT32\",\n\t\t  nodataValue: NaN,\n\t\t},\n\t\t{\n\t\t\tid: \"percentageOfCloudFree\",\n\t\t   bands: 1,\n\t\t   sampleType: \"FLOAT32\",\n\t\t   nodataValue: NaN,\n\t\t },\n\t\t {\n\t\t   id: \"percentageOfCloudy\",\n\t\t   bands: 1,\n\t\t   sampleType: \"FLOAT32\",\n\t\t   nodataValue: NaN,\n\t\t}\n\t  ],\n\t  mosaicking: Mosaicking.ORBIT\n\t}\n  }\n\n  // function updateOutput(output, collection) {\n  //   output.default.bands = collection.scenes.length\n  // }\n\n  function samplesParser(samples) {\n\tconst cloudFreeSamples = new Array();\n\tconst cloudySamples = new Array();\n\n\tsamples.forEach((sample) => {\n\t  if (sample.CLD > 0) {\n\t\tcloudySamples.push(sample);\n\t  } else {\n\t\tcloudFreeSamples.push(sample);\n\t  }\n\t});\n\treturn [cloudySamples, cloudFreeSamples];\n  }\n\n  function calcAverage(samples) {\n\tlet sum = 0;\n\tfor(let i = 0;i < samples.length; i++) {\n\t  sum += samples[i];\n\t}\n\tlet avg = sum / samples.length;\n\treturn avg;\n  }\n  function calcNDVIForSamples(samples) {\n\tconst ndvis = new Array(samples.length).fill(NaN);\n\tsamples.forEach((sample, index) => {\n\t  ndvis[index] = (sample.B08 - sample.B04) / (sample.B08 + sample.B04) ;\n\t});\n\treturn ndvis;\n  }\n  function calcPercentage(total, incidences) {\n\tif (total <= 0) {\n\t  return NaN;\n\t}\n\treturn ((incidences / total) * 100);\n  }\n  function evaluatePixel(samples) {\n\tif (samples.length < 1) {\n\t  return {\n\t\tdefault: [NaN, NaN, NaN, NaN, NaN],\n\t\taverages: [NaN],\n\t\tnumOfCloudFreeSamples: [NaN],\n\t\tnumOfCloudySamples: [NaN],\n\t\t// percentageOfCloudFree: [NaN],\n\t\t// percentageOfCloudy: [NaN]\n\t  };\n\t}\n\tconst parsedSamples = samplesParser(samples);\n\tconst ndvis = calcNDVIForSamples(parsedSamples[1]);\n\tconst averages = calcAverage(ndvis);\n\tconst numOfCloudySamples = parsedSamples[0].length;\n\tconst numOfCloudFreeSamples = parsedSamples[1].length;\n\tconst totalNumOfSamples = numOfCloudySamples + numOfCloudFreeSamples;\n\tconst percentageOfCloudy = calcPercentage(totalNumOfSamples, numOfCloudySamples);\n\tconst percentageOfCloudFree = calcPercentage(totalNumOfSamples, numOfCloudFreeSamples);\n\n\treturn {\n\t  default: [averages, numOfCloudFreeSamples, numOfCloudySamples, percentageOfCloudFree, percentageOfCloudy],\n\t  averages: [averages],\n\t  numOfCloudFreeSamples: [numOfCloudFreeSamples],\n\t  numOfCloudySamples: [numOfCloudySamples],\n\t  percentageOfCloudFree: [percentageOfCloudFree],\n\t  percentageOfCloudy: [percentageOfCloudy],\n\t};\n  }"
}'

Can you double check that the actual request that you send, includes all of the outputs that you have specified?

thank you, i found the mistake.
appreciate your attention.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.