1

I'm using the following code to convert hourly data into daily data records. In the first case (Surface Solar Radiation) it works well but in the second case (Mean 2m air temperature) occurs an error stateing: ImageCollection (Error) User memory limit exceeded. and Error generating chart: User memory limit exceeded.

Can you take a look at what I am not doing well?

var byDay = ee.ImageCollection(
  // map over each day
  ee.List.sequence(0,nDays).map(function (n) {
    // calculate the offset from startDate
    var ini = startDate.advance(n,'day');
    // advance
    var end = ini.advance(3,'day');
    // filter and reduce
    return era5_2mt.filterDate(ini,end)
                .select(0).mean()
                .set('system:time_start', ini)
}));

print(byDay, 'byDay');

//Chart 4
var TS04 = ui.Chart.image.series(byDay, AOI, ee.Reducer.mean(), 1000, 'system:time_start').setOptions({
          title: 'Mean air temperature at 2m height (Daily)',
          vAxis: {title: 'C'},
});
print(TS04);

Link to my full code: https://code.earthengine.google.com/433bb464c64b80c190e5ffe72b5bd0f8

1
  • Your daily data looks as it is not adequately calculated. I think they should have 56 elements; not 57 as they are produced in your code. So, you need to produce the mean for a slice of 24 images each day.
    – xunilk
    Nov 3, 2021 at 13:46

2 Answers 2

1

I found the solution:

// Convert mean temperature in K to C
var era5_2mt = era5_2mt.map(function(img) {
  return img
    .subtract(273.15)
    .copyProperties(img, ['system:time_start']);
});
0

Apparently, you found out a solution, however, your byDay variable should have 56 elements; not 57 as they are produced in your code. There is nothing wrong in your original variable:

// Convert mean temperature in K to C
var era5_2mt = era5_2mt.map(function(image) {
  return image.subtract(273.15).set(
    'system:time_start', image.get('system:time_start'));
});

However, when new era5_2mt is used in byDay variable with computed objects, it starts an infinite loop and produces an 'User memory limit exceeded' when it only should produce 57 images. Issues are in byDay; not in original era5_2mt.

Following code snippet has your original function. However, it produces a mean image for all 24 daily images.

// Convert mean temperature in K to C
var era5_2mt = era5_2mt.map(function(image) {
  return image.subtract(273.15).set(
    'system:time_start', image.get('system:time_start'));
});

//Clip
var clip_era5_2mt = era5_2mt.mean().clip(AOI);

//Chart 3
var TS03 = ui.Chart.image.series(era5_2mt, AOI, ee.Reducer.mean(), 1000, 'system:time_start').setOptions({
          title: 'Mean air temperature at 2m height (Hourly)',
          vAxis: {title: 'C'},
});
print(TS03);

var era5_2mt_list = era5_2mt.toList(count);

print(era5_2mt_list);

var era5_2mt_daily_list = list.map(function(ele){

  var start = ee.Number(ele).int(); 
  var end = ee.Number(ele).add(24).int();
  
  var date = ee.Image(era5_2mt_list.get(start)).get('system:time_start');

  var new_list = ee.List([]);
  var element = ee.ImageCollection(ee.List(era5_2mt_list.slice(start, end))).mean();

  new_list = new_list.add(element.set('system:time_start', date));

  return new_list;

}).flatten();

print(era5_2mt_daily_list);

//Chart 4
var TS04 = ui.Chart.image.series(era5_2mt_daily_list, AOI, ee.Reducer.mean(), 1000, 'system:time_start').setOptions({
          title: 'Mean air temperature at 2m height (Daily)',
          vAxis: {title: 'C'},
});

print(TS04);

Complete code is here.

After running it in GEE code editor, with adequate function for daily images, it produces a Image Collection with 56 elements and its corresponding chart as expected. It can be observed in following image.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.