Any tutorial on the GFS model in Earth Engine describes filtering out the 6-hour precipitation intervals, to avoid double-counting the cumulative precipitation band. However, I cannot square the documentation with how to calculate the hourly precipitation itself.
The docs say:
'Cumulative precipitation at surface for the previous 1-6 hours, depending on the value of the "forecast_hours" property according to the formula ((F - 1) % 6) + 1 (and only for assets with forecast_hours > 0).
As a consequence, to calculate the total precipitation by hour X, double-counting should be avoided by only summing the values for forecast_hours that are multiples of 6 plus any remainder to reach X. It also means that to determine the precipitation for just hour X, one must subtract the value for the preceding hour unless X is the first hour in a 6-hour window.'
How exactly would I convert that to code? I have started something like so:
var dataset = ee.ImageCollection('NOAA/GFS0P25')
.filter(ee.Filter.date('2018-03-01', '2018-03-02'))
.filter(ee.Filter.neq('forecast_hours',0))
.select('total_precipitation_surface')
var ppt = dataset
print(ee.List(dataset))
//var interval_list = [1,2,3,4,5,7,8,9,10,11,13,14,15,16,17,19,20,21,22,23,25
// ,26,27,29,30,31,32,33,34,35,37]
var interval_list = [6,12,18,24,30,36,42,48,54,60,66,72,78,84,90,96,102,108,114,120,
126,132,138,144,150,156,162,168,174,180,186,192,198,204,210,216,
220,226,232,240,252,264,276,288,300,312,324,336,348,360,372,384]
var non_six_gfs = dataset
.filter(ee.Filter.inList('forecast_hours',interval_list).not())
print(non_six_gfs.toList(3).get(-1))
var gfs_hourly = dataset.map(function(image){
var previous_int = ee.Image(ee.List(dataset).get(-1));
return image.subtract(previous_int)
})
With the idea of filtering out the 6 hour intervals, and then subtracting the previous forecast hour from the current one, but I'm not sure how to do this and skip over those 6 hour intervals to avoid cutting into the previous cumulative period. I'd also like to avoid converting a image collection to a list, which is very computationally expensive.