YashMK89 commited on
Commit
7b58e6c
·
verified ·
1 Parent(s): 6f6b853

update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -145,6 +145,16 @@ def calculate_custom_formula(image, geometry, selected_bands, custom_formula, re
145
  return ee.Image(0).rename('custom_result').set('error', str(e))
146
 
147
  # Aggregation functions
 
 
 
 
 
 
 
 
 
 
148
  def aggregate_data_daily(collection):
149
  """
150
  Aggregates data on a daily basis.
 
145
  return ee.Image(0).rename('custom_result').set('error', str(e))
146
 
147
  # Aggregation functions
148
+ def aggregate_data_custom(collection):
149
+ collection = collection.map(lambda image: image.set('day', ee.Date(image.get('system:time_start')).format('YYYY-MM-dd')))
150
+ grouped_by_day = collection.aggregate_array('day').distinct()
151
+ def calculate_daily_mean(day):
152
+ daily_collection = collection.filter(ee.Filter.eq('day', day))
153
+ daily_mean = daily_collection.mean()
154
+ return daily_mean.set('day', day)
155
+ daily_images = ee.List(grouped_by_day.map(calculate_daily_mean))
156
+ return ee.ImageCollection(daily_images)
157
+
158
  def aggregate_data_daily(collection):
159
  """
160
  Aggregates data on a daily basis.