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