Skip to content

Instantly share code, notes, and snippets.

@jdbcode
Created July 16, 2021 18:18
Show Gist options
  • Save jdbcode/7eeb4cc4ced369ce68c11e74827adc00 to your computer and use it in GitHub Desktop.
Save jdbcode/7eeb4cc4ced369ce68c11e74827adc00 to your computer and use it in GitHub Desktop.
Earth Engine dataset latency calculator
// #############################################################################
// ### INPUTS ###
// #############################################################################
var COL_ID = ee.ImageCollection("COPERNICUS/S1_GRD");
var PERIOD = 0.1; // Today to PERIOD months prior
// #############################################################################
function calcLatency(img) {
var version = img.get('system:version');
var ingest = ee.Date(ee.Number(version).divide(1000));
var observe = img.date();
var latency = ingest.difference(observe, 'hours');
return img.set('latency', latency);
}
var col = ee.ImageCollection(COL_ID);
var today = ee.Date(Date.now());
col = col.filterDate(today.advance(-PERIOD, 'months'), today)
.map(calcLatency);
var meanLatency = col.reduceColumns({
reducer: ee.Reducer.mean(),
selectors: ['latency']
}).get('mean');
print('Mean latency (hours) for last ' + PERIOD + ' months:',
meanLatency);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment