Issues in handling data fusion requests

Hi Maxim, thanks for getting back to me. Turns out part of the problem was a keyboard-chair interface issue :sweat_smile: - when debugging I disabled the code that fetches the second data source (afterEvent). While I took care of not referencing a source I do not request, it seems the API does not accept processing single sources that have an assigned user ID (e.g. beforeEvent), when there is no other source requested. So, it is working well with both beforeEvent and afterEvent being called in the script!

Getting the metadata through scenes.{sourceID}.scenes.tiles (or I assume .orbits depending on the mosaicking) works well too. Thank you.

I just have a second issue I allow myself to piggyback with on this post regarding relative orbit filtering. I have been trying to replicate using code from the example here, adapting it for S1 sats. The modified orbit filtering code snipper is the following (changing the satellite names and the rel. orb. coefficients):


  //VERSION=3

  function setup() {
    return {
      input: [
        {bands: ["VV", "dataMask"], datasource: "beforeEvent"},
        {bands: ["VV", "dataMask"], datasource: "afterEvent"}
      ],
      output: [
        {{id: "mask", bands: 1}}
      ],
      mosaicking: "TILE",
    };
  }

  var orbNr = 147 // or 74 for the given test dates

  function getAbsOrbitIdFromTileOriginalId(tileOriginalId) {
    textParts = tileOriginalId.split("_")
    absOrbitId = parseInt(textParts[6].substring(1));
    return absOrbitId
  }

  function getSatelliteFromTileOriginalId(tileOriginalId) {
    textParts = tileOriginalId.split("_")
    satellite = textParts[0];
    return satellite
  }

  function getRelativeOrbitIdFromAbsOrbitId(absOrbitId, satellite) {
    relativeOrbitCoefficinets = {
        // Arrays of coefficients [firstRelOrbit, maxRelOrbit, add], where:
        // Relative Orbit Number = mod (Absolute Orbit Number orbit + firstRelOrbit, maxRelOrbit) + add
        "S1A": [-73, 175, 1],
        "S1B": [-27, 175, 1],
      }

    coefficients = relativeOrbitCoefficinets[satellite.toString()]
    return (absOrbitId + coefficients[0]) % coefficients[1] + coefficients[2]
  }

  // Filter by relative orbit id
  function preProcessScenes(collections) {
    var allowedRelativeOrbits = [orbNr]
    collections.scenes.tiles = collections.scenes.tiles.filter(function(tile) {
      var satellite = getSatelliteFromTileOriginalId(tile.tileOriginalId);
      var absOrbitId = getAbsOrbitIdFromTileOriginalId(tile.tileOriginalId);
      return allowedRelativeOrbits.includes(getRelativeOrbitIdFromAbsOrbitId(absOrbitId, satellite))
    })
    return collections;
  }

  function evaluatePixel(samples) {{
    return [samples.afterEvent] // just returning this for testing
  }

My test BBox is the following:
BBox(((153.22406171417035, -28.87289144461865), (153.39147095497796, -28.742148861725493)), crs=CRS('4326'))

of size (546, 481).

My beforeEvent date range is 2022-01-01 - 2022-01-31, and my afterEvent images are:

  • 2022-03-26, orbit number 74
  • 2022-03-31, orbit number 147

Using on these dates in this area throws the error:
Server response: "{"error":{"status":400,"reason":"Bad Request","message":"Failed to evaluate script!\nevalscript.js:46: TypeError: Cannot read property 'tiles' of undefined\n collections.scenes.tiles = collections.scenes.tiles.filter(function(tile) {\n ^\nTypeError: Cannot read property 'tiles' of undefined\n at preProcessScenes (evalscript.js:46:50)\n at internalPreProcessScenes (<anonymous>:1187:11)\n","code":"RENDERER_EXCEPTION"}}"

I would assume the filtering code filters for both collections.scenes.beforeEvent.scenes.tiles and collections.scenes.afterEvent.scenes.tiles, but following your statement on accessing metadata for each collection, I am not sure now. How should I modify the preProcessScenes() function?

Thanks again for your help, and have a good evening!