In essence, I used GRIDMET to pull both monthly and annual precip over the same area, same time, and same database, but summing each month for the same water year is not matching:
NEW NOTE: As pointed out in Answer#1, running the code using a point is fine; the issue is running the code over an area. When troubleshooting, create a geometry poly and then run function over the poly instead of point.
Approach: I created a sequence of years and then used ee.Date.fromYMD and the built-in .advance function to pull GRIDMET 'pt' data as an annual mean (for water years [Oct-Sept]) over user-defined areas (i.e., HUC6):
This works; however, I also needed to pull the same data as monthly means over the same areas; i.e., I changed .advance(1, "year") to .advance(1,"month"). The sum of the monthly data over the same water year should, theoretically, be identical to the annual mean (same dataset, same area, same timeframe). However, they are different. The pattern is very similar and co-varies; but why would the 'pt' be different? I need to know if the difference is due to the built-in code (e.g., does "month" correctly advance each month 30, 31, 30, 31 days?) or whether it is on the database side (TERRACLIMATE/GRIDMET).
Code: (create a geometric area in GEE instead of using a point)
var point = ee.Geometry.Point (-110.93, 32.28);
var climateYEAR = ee.ImageCollection(ee.List.sequence(1994, 2000).map(function (year){
var date_start = ee.Date.fromYMD(year, 1, 1);
var date_end = date_start.advance(1, "year");
return ee.ImageCollection('IDAHO_EPSCOR/GRIDMET') //changed to/from IDAHO_EPSCOR/TERRACLIMATE
.select(['pr'])
.filterDate(date_start, date_end)
.filterBounds(point)
.sum()
.set({year: year, 'system:time_start':date_start});
}));
var climateYEARmean = climateYEAR.map(function(image) {
return image.reduceRegions({
collection: point,
reducer: ee.Reducer.mean(),
scale: 4000,
crs: 'EPSG:4326',
tileScale: 1
}).map(function(f){return f.set({'year': image.get('year')})});
});
print(climateYEARmean, 'climateYEARmean');
var climateMEAN = (ee.FeatureCollection(climateYEARmean).flatten());
print(climateMEAN, 'climateMEAN');
Also, I likely should post as a different question, but while troubleshooting, I pulled the same data from TerraClimate and found that TC is computing much lower annual means for the same area, same timeframe (and they also covary very well)??