Refactored aggregation so that it can be unit tested properly, and is easier to extend to ungridded data. Structure should be more similar to that for subsetting now.