I'm trying to estimate the total of clear days in a year with the help of state_1km band in the MOD09GA product. But I'm not sure if it is right, also the possible counts are higher than expected when compared with cloud cover observation at weather stations.
// Load morning (Terra) MODIS data.
var morning = ee.ImageCollection('MODIS/006/MOD09GA');
// A function to extract cloudiness data from a MODIS image.
function clear(image) {
// The cloud state is in the low two bits of the 'state_1km' band.
var cloudState = image.select('state_1km').bitwiseAnd(0x03);
// 0:clear, 1:cloudy, 2 means mixed, and 3:missing data.
return cloudState.float()
.remap([0,1],[1,0])
.updateMask(cloudState.neq(3))
.updateMask(cloudState.neq(2));
}
var select_morning = morning.filter(ee.Filter.calendarRange(2015,2015,'year'));
var clear_days = select_morning.map(clear);
var count = clear_days.reduce(ee.Reducer.sum());