1
- import os
2
1
import numpy as np
3
2
import pystac_client
4
3
import fused_local
9
8
10
9
fused_local .configure_map (
11
10
title = "Sentinel-2 demo" ,
12
- center = "ski santa fe, nm " ,
11
+ center = "ski santa fe" ,
13
12
zoom = 10 ,
14
13
)
15
14
16
15
17
16
@fused_local .tile
18
17
def s2_scene_june (gbox : GeoBox ) -> xr .Dataset :
19
- try :
20
- item = pystac .Item .from_file (
21
- "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_13SDV_20240601_0_L2A"
22
- )
23
- print (f"fetched item { item .id } { gbox } { os .getpid ()= } " )
24
- data = odc .stac .load ([item ], ["red" , "green" , "blue" ], geobox = gbox )
25
- print (f"loaded data for { item .id } { gbox } " )
26
- # idk why odc.stac doesn't handle nodata / offer an option to mask it
27
- data = data .where (data != 0 , np .nan )
28
- return data
29
- except KeyboardInterrupt :
30
- print ("AAAAHAHGAGHA" )
31
- raise
18
+ item = pystac .Item .from_file (
19
+ "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_13SDV_20240601_0_L2A"
20
+ )
21
+ print (f"fetched item { item .id } { gbox } " )
22
+ data = odc .stac .load ([item ], ["red" , "green" , "blue" ], geobox = gbox )
23
+ print (f"loaded data for { item .id } { gbox } " )
24
+ # idk why odc.stac doesn't handle nodata / offer an option to mask it
25
+ data = data .where (data != 0 , np .nan )
26
+ return data
32
27
33
28
34
- # @fused_local.tile
35
- # def s2_scene_march(gbox: GeoBox) -> xr.Dataset:
36
- # item = pystac.Item.from_file(
37
- # "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_13SDV_20240301_0_L2A"
38
- # )
39
- # data = odc.stac.load([item], ["red", "green", "blue"], geobox=gbox)
40
- # data = data.where(data != 0, np.nan)
41
- # return data
29
+ @fused_local .tile
30
+ def s2_scene_march (gbox : GeoBox ) -> xr .Dataset :
31
+ item = pystac .Item .from_file (
32
+ "https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_13SDV_20240301_0_L2A"
33
+ )
34
+ data = odc .stac .load ([item ], ["red" , "green" , "blue" ], geobox = gbox )
35
+ data = data .where (data != 0 , np .nan )
36
+ return data
42
37
43
38
44
39
# @fused_local.tile
@@ -48,16 +43,22 @@ def s2_scene_june(gbox: GeoBox) -> xr.Dataset:
48
43
# items = client.search(
49
44
# collections=["sentinel-2-l2a"],
50
45
# bbox=tuple(gbox.geographic_extent.boundingbox),
51
- # datetime="2022-06 -01/2022-08 -01",
46
+ # datetime="2022-03 -01/2022-04 -01",
52
47
# query={"eo:cloud_cover": {"lt": 10}},
53
48
# max_items=20,
54
- # # sortby="datetime",
55
49
# ).item_collection()
56
50
57
51
# print(f"{len(items)=}")
58
52
59
- # stack = odc.stac.load(items, groupby="solar_day", geobox=gbox, bands=["red", "green", "blue"])
53
+ # stack = odc.stac.load(
54
+ # items,
55
+ # groupby="solar_day",
56
+ # geobox=gbox,
57
+ # bands=["red", "green", "blue"],
58
+ # chunks={"time": 1},
59
+ # )
60
+ # stack = stack.isel(time=slice(4))
60
61
# stack = stack.where(stack != 0, np.nan)
61
- # comp = stack.mean ("time")
62
+ # comp = stack.median ("time")
62
63
63
- # return comp
64
+ # return comp.compute()
0 commit comments