I want to calculate the number of monthly in a year that have less than 10% of the annual precipitation of that year, using the CHIRPS daily precip dataset on GEE.
My logic with code below (initiated for YY-1998 and annual precip for 1998 code not shown)-
1) Calculate the monthly precip for year YYYY and save it as an imagecollection by_monthYY.
2) Write a conditional statement to compare each image in by_MonthYY with annual precipitation of same year, such that if the by_MonthYY <=10% annual precipitation, a value of 1 is assigned, else 0, all saved in an other image collection by_MonthdryYY.
3) Reduce by_MonthdryYY by sum, to get the total number of dry months for that year.
I need to do above for multiple years and finally reduce by mean to get the average number of dry months over a time period.
var chirps_timeperiod = chirps_complete.filterDate('1998-01-01', '1998-12-31'); //YY=1998
var month_sum98 = ee.List.sequence(0, 1*12).map(function(n) { // .sequence: number of years from starting year to present
var start = ee.Date('1998-01-01').advance(n, 'month'); // Starting date
var end = start.advance(1, 'month'); // Step by each iteration
return ee.ImageCollection(chirps_timeperiod)
.filterDate(start, end)
.sum()
.set('system:time_start', start.millis());
});
print(month_sum98);
var collection98 = ee.ImageCollection(month_sum98); //monthly precip for 1998
var replacement = ee.Image(1);
var conditional = function(image) { //image is map image collection of monthly precip by year separetly
return image.where(image.lte(0.1*(annualprecip_1998)), replacement);
};
var dryseason98=month_sum98.map(conditional);
However, I get an error saying image.lte is not a function. I also used image.ee.Filter.lessThanOrEqual with error image.ee is undefined. What function should I use to compare the two images?