This code gives me the snow depth less than 0.0254 for each day in 2021, as 0 and 1 (0 means snow depth greater than 0.0254 and 1 means snow depth less than 0.0254) but, at the end, I want an image that sums up 20 days 1st of 2021 (the number of days each pixel has snow depth less than 0.0254). How can I do this?
var year = 2021
var fromDayOfYear = 1
var toDayOfYear = 20
var collection = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
.select('SnowDepth_inst')
sequence(fromDayOfYear, toDayOfYear) // Client side array
.map(function (dayOfYear) {
var date = ee.Date.fromYMD(year, 1, 1).advance(dayOfYear - 2, 'days')
var image = collection
.filter(ee.Filter.date(date.getRange('day')))
.mean()
.lte(0.0254)
addWindspeedLayer(image, dayOfYear)
})
function addWindspeedLayer(image, dayOfYear) {
var visParams = {
min: -0.28945971257313863,
max: 7.197656994173444,
palette: ['1303ff', '42fff6', 'f3ff40', 'ff5d0f'],
}
Map.addLayer(image.clip(table), visParams, 'Day ' + dayOfYear)
}
var sdVis = {
min: 36.226610524397074,
max: 2253.6926496799506,
palette: ['1303ff', '42fff6', 'f3ff40', 'ff5d0f'],
}
function sequence(start, end) {
return Array
.apply(null, {length: 1 + end - start })
.map(function (_, i) { return i + start })
}