Skip to content

Commit f0b0fd6

Browse files
committed
update example
1 parent 8dec7f8 commit f0b0fd6

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

example.py

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import numpy as np
32
import pystac_client
43
import fused_local
@@ -9,36 +8,32 @@
98

109
fused_local.configure_map(
1110
title="Sentinel-2 demo",
12-
center="ski santa fe, nm",
11+
center="ski santa fe",
1312
zoom=10,
1413
)
1514

1615

1716
@fused_local.tile
1817
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
3227

3328

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
4237

4338

4439
# @fused_local.tile
@@ -48,16 +43,22 @@ def s2_scene_june(gbox: GeoBox) -> xr.Dataset:
4843
# items = client.search(
4944
# collections=["sentinel-2-l2a"],
5045
# bbox=tuple(gbox.geographic_extent.boundingbox),
51-
# datetime="2022-06-01/2022-08-01",
46+
# datetime="2022-03-01/2022-04-01",
5247
# query={"eo:cloud_cover": {"lt": 10}},
5348
# max_items=20,
54-
# # sortby="datetime",
5549
# ).item_collection()
5650

5751
# print(f"{len(items)=}")
5852

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))
6061
# stack = stack.where(stack != 0, np.nan)
61-
# comp = stack.mean("time")
62+
# comp = stack.median("time")
6263

63-
# return comp
64+
# return comp.compute()

0 commit comments

Comments
 (0)