|
10 | 10 | SpatialContext,
|
11 | 11 | TemporalContext,
|
12 | 12 | )
|
| 13 | +from openeo_gfmap.fetching.meteo import build_meteo_extractor |
13 | 14 | from openeo_gfmap.fetching.generic import build_generic_extractor
|
14 | 15 | from openeo_gfmap.fetching.meteo import build_meteo_extractor
|
15 | 16 | from openeo_gfmap.fetching.s1 import build_sentinel1_grd_extractor
|
@@ -238,6 +239,39 @@ def raw_datacube_METEO(
|
238 | 239 | return extractor.get_cube(connection, spatial_extent, temporal_extent)
|
239 | 240 |
|
240 | 241 |
|
| 242 | +def precomposited_datacube_METEO( |
| 243 | + connection: Connection, |
| 244 | + spatial_extent: SpatialContext, |
| 245 | + temporal_extent: TemporalContext, |
| 246 | +) -> DataCube: |
| 247 | + """Extract the precipitation and temperature AGERA5 data from a |
| 248 | + pre-composited and pre-processed collection. The data is stored in the |
| 249 | + CloudFerro S3 stoage, allowing faster access and processing from the CDSE |
| 250 | + backend. |
| 251 | +
|
| 252 | + Limitations: |
| 253 | + - Only monthly composited data is available. |
| 254 | + - Only two bands are available: precipitation-flux and temperature-mean. |
| 255 | + - This function do not support fetching points or polygons, but only |
| 256 | + tiles. |
| 257 | + """ |
| 258 | + temporal_extent = [temporal_extent.start_date, temporal_extent.end_date] |
| 259 | + spatial_extent = dict(spatial_extent) |
| 260 | + |
| 261 | + # Monthly composited METEO data |
| 262 | + cube = connection.load_stac( |
| 263 | + "https://s3.waw3-1.cloudferro.com/swift/v1/agera/stac/collection.json", |
| 264 | + spatial_extent=spatial_extent, |
| 265 | + temporal_extent=temporal_extent, |
| 266 | + bands=["precipitation-flux", "temperature-mean"], |
| 267 | + ) |
| 268 | + cube = cube.rename_labels(dimension="bands", target=[ |
| 269 | + "AGERA5-PRECIP", "AGERA5-TMEAN" |
| 270 | + ]) |
| 271 | + |
| 272 | + return cube |
| 273 | + |
| 274 | + |
241 | 275 | def worldcereal_preprocessed_inputs_gfmap(
|
242 | 276 | connection: Connection,
|
243 | 277 | backend_context: BackendContext,
|
@@ -302,24 +336,14 @@ def worldcereal_preprocessed_inputs_gfmap(
|
302 | 336 |
|
303 | 337 | dem_data = dem_data.linear_scale_range(0, 65534, 0, 65534)
|
304 | 338 |
|
305 |
| - meteo_data = raw_datacube_METEO( |
| 339 | + meteo_data = precomposited_datacube_METEO( |
306 | 340 | connection=connection,
|
307 |
| - backend_context=backend_context, |
308 | 341 | spatial_extent=spatial_extent,
|
309 | 342 | temporal_extent=temporal_extent,
|
310 |
| - fetch_type=FetchType.TILE, |
311 | 343 | )
|
312 | 344 |
|
313 |
| - # Perform compositing differently depending on the bands |
314 |
| - mean_temperature = meteo_data.band("AGERA5-TMEAN") |
315 |
| - mean_temperature = mean_compositing(mean_temperature, period="month") |
316 |
| - |
317 |
| - total_precipitation = meteo_data.band("AGERA5-PRECIP") |
318 |
| - total_precipitation = sum_compositing(total_precipitation, period="month") |
319 |
| - |
320 | 345 | data = s2_data.merge_cubes(s1_data)
|
321 | 346 | data = data.merge_cubes(dem_data)
|
322 |
| - data = data.merge_cubes(mean_temperature) |
323 |
| - data = data.merge_cubes(total_precipitation) |
| 347 | + data = data.merge_cubes(meteo_data) |
324 | 348 |
|
325 | 349 | return data
|
0 commit comments