Created
July 16, 2021 18:18
-
-
Save jdbcode/7eeb4cc4ced369ce68c11e74827adc00 to your computer and use it in GitHub Desktop.
Earth Engine dataset latency calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ############################################################################# | |
// ### 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