import numpy as np
import xarray as xr
import rasterio.features
import stackstac
import pystac_client
import planetary_computer
import xrspatial.multispectral as ms
# from dask_gateway import GatewayCluster
# # just for speed. This runs fine on a single machine.
# cluster = GatewayCluster()
# cluster.scale(24)
# client = cluster.get_client()
# cluster
Our task is to create a cloud-free composite of some Sentinel-2 imagery by taking a median over time. The "easy" way of doing things is to use stackstac
to create the DataArray and call .median(dim="time")
.
area_of_interest = {
"type": "Polygon",
"coordinates": [
[
[-122.27508544921875, 47.54687159892238],
[-121.96128845214844, 47.54687159892238],
[-121.96128845214844, 47.745787772920934],
[-122.27508544921875, 47.745787772920934],
[-122.27508544921875, 47.54687159892238],
]
],
}
bbox = rasterio.features.bounds(area_of_interest)
stac = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")
search = stac.search(
bbox=bbox,
# datetime="2018-01-01/2020-12-31",
datetime="2020-06-01/2020-12-31",
collections=["sentinel-2-l2a"],
limit=500, # fetch items in batches of 500
query={"eo:cloud_cover": {"lt": 25}},
)
items = list(search.get_items())
print(len(items))
signed_items = [planetary_computer.sign(item).to_dict() for item in items]
bad_data = (
stackstac.stack(
signed_items,
assets=["B04", "B03", "B02"], # red, green, blue
chunksize=2048,
)
.where(lambda x: x > 0, other=np.nan) # sentinel-2 uses 0 as nodata
# .assign_coords(band=lambda x: x.common_name.rename("band")) # use common names
)
bad_data
26
<xarray.DataArray 'stackstac-6add7ccc542226180faed750e3208a58' (time: 26, band: 3, y: 10980, x: 10980)> dask.array<where, shape=(26, 3, 10980, 10980), dtype=float64, chunksize=(1, 1, 2048, 2048), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2020-06-26... id (time) <U54 'S2A_MSIL2A_20200626... * band (band) <U3 'B04' 'B03' 'B02' * x (x) float64 5e+05 ... 6.098e+05 * y (y) float64 5.3e+06 ... 5.19e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 s2:generation_time (time) <U24 '2020-08-24T04:44:17... s2:not_vegetated_percentage (time) float64 6.29 6.48 ... 1.764 s2:cloud_shadow_percentage (time) float64 0.095 ... 8.791 s2:snow_ice_percentage (time) float64 1.324 ... 1.404 sat:orbit_state <U10 'descending' s2:thin_cirrus_percentage (time) float64 5.034 ... 0.1651 s2:nodata_pixel_percentage (time) float64 3.652 ... 3.947 s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:unclassified_percentage (time) float64 1.278 0.992 ... 8.58 s2:water_percentage (time) float64 10.82 ... 9.798 s2:medium_proba_clouds_percentage (time) float64 0.366 ... 6.466 s2:product_uri (time) <U65 'S2A_MSIL2A_20200626... platform (time) <U11 'Sentinel-2A' ... 'S... eo:cloud_cover (time) float64 6.042 ... 22.94 s2:high_proba_clouds_percentage (time) float64 0.6417 ... 16.31 s2:granule_id (time) <U62 'S2A_OPER_MSI_L2A_TL... s2:dark_features_percentage (time) float64 0.5517 ... 14.56 sat:relative_orbit (time) int64 13 56 56 ... 56 56 13 s2:mean_solar_zenith (time) float64 26.92 ... 71.85 s2:datatake_type <U8 'INS-NOBS' s2:vegetation_percentage (time) float64 73.6 68.68 ... 32.16 constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 s2:reflectance_conversion_factor (time) float64 0.968 ... 1.034 s2:datastrip_id (time) <U64 'S2A_OPER_MSI_L2A_DS... s2:mean_solar_azimuth (time) float64 148.0 ... 165.6 s2:datatake_id (time) <U34 'GS2A_20200626T18592... proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title (band) <U20 'Band 4 - Red - 10m'... gsd int64 10 common_name (band) <U5 'red' 'green' 'blue' center_wavelength (band) float64 0.665 0.56 0.49 full_width_half_max (band) float64 0.038 0.045 0.098 epsg int64 32610 Attributes: spec: RasterSpec(epsg=32610, bounds=(499980.0, 5190240.0, 609780.0... crs: epsg:32610 transform: | 10.00, 0.00, 499980.00|\n| 0.00,-10.00, 5300040.00|\n| 0.0... resolution: 10.0
|
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['S2A_MSIL2A_20200626T185921_R013_T10TET_20200824T044417', 'S2B_MSIL2A_20200714T190919_R056_T10TET_20200918T171907', 'S2A_MSIL2A_20200719T190921_R056_T10TET_20200816T174917', 'S2B_MSIL2A_20200721T185919_R013_T10TET_20200817T013018', 'S2A_MSIL2A_20200726T185921_R013_T10TET_20201024T183833', 'S2A_MSIL2A_20200729T190921_R056_T10TET_20200818T003739', 'S2B_MSIL2A_20200731T185919_R013_T10TET_20200818T085554', 'S2A_MSIL2A_20200805T185921_R013_T10TET_20201025T023207', 'S2B_MSIL2A_20200810T185919_R013_T10TET_20200814T140814', 'S2B_MSIL2A_20200813T190919_R056_T10TET_20201025T101153', 'S2A_MSIL2A_20200815T185921_R013_T10TET_20200818T093648', 'S2B_MSIL2A_20200823T190919_R056_T10TET_20200918T171910', 'S2A_MSIL2A_20200825T185921_R013_T10TET_20200827T175050', 'S2A_MSIL2A_20200828T190921_R056_T10TET_20200907T112416', 'S2B_MSIL2A_20200830T185919_R013_T10TET_20200907T164839', 'S2B_MSIL2A_20200902T190919_R056_T10TET_20200907T231347', 'S2A_MSIL2A_20200904T185921_R013_T10TET_20200908T004502', 'S2A_MSIL2A_20200907T190931_R056_T10TET_20200911T172006', 'S2B_MSIL2A_20200909T185929_R013_T10TET_20200911T225318', 'S2B_MSIL2A_20200929T190109_R013_T10TET_20201001T085751', 'S2B_MSIL2A_20201002T191229_R056_T10TET_20201004T193349', 'S2B_MSIL2A_20201101T191539_R056_T10TET_20201102T211503', 'S2B_MSIL2A_20201108T190619_R013_T10TET_20201109T194251', 'S2B_MSIL2A_20201121T191719_R056_T10TET_20201123T062421', 'S2B_MSIL2A_20201201T191749_R056_T10TET_20201203T103951', 'S2B_MSIL2A_20201228T190809_R013_T10TET_20210113T180911'], dtype='<U54')
array(['B04', 'B03', 'B02'], dtype='<U3')
array([499980., 499990., 500000., ..., 609750., 609760., 609770.])
array([5300040., 5300030., 5300020., ..., 5190270., 5190260., 5190250.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array(['2020-08-24T04:44:17.115Z', '2020-09-18T17:19:07.543Z', '2020-08-16T17:49:17.368Z', '2020-08-17T01:30:18.783Z', '2020-10-24T18:38:33.928Z', '2020-08-18T00:37:39.827Z', '2020-08-18T08:55:54.939Z', '2020-10-25T02:32:07.311Z', '2020-08-14T14:08:14.944Z', '2020-10-25T10:11:53.422Z', '2020-08-18T09:36:48.464Z', '2020-09-18T17:19:10.769Z', '2020-08-27T17:50:50.878Z', '2020-09-07T11:24:16.977Z', '2020-09-07T16:48:39.196Z', '2020-09-07T23:13:47.965Z', '2020-09-08T00:45:02.187Z', '2020-09-11T17:20:06.830Z', '2020-09-11T22:53:18.279Z', '2020-10-01T08:57:51.731Z', '2020-10-04T19:33:49.388Z', '2020-11-02T21:15:03.594Z', '2020-11-09T19:42:51.793Z', '2020-11-23T06:24:21.864Z', '2020-12-03T10:39:51.912Z', '2021-01-13T18:09:11.872Z'], dtype='<U24')
array([ 6.290432, 6.480319, 6.767954, 7.708924, 7.928471, 7.950327, 9.535755, 9.016984, 9.12929 , 9.060695, 9.453898, 9.139152, 9.787615, 9.285574, 10.141966, 9.488664, 12.374111, 8.90085 , 11.759762, 7.954067, 6.086313, 4.860784, 4.797184, 3.894184, 3.469761, 1.764327])
array([0.094999, 0.059137, 0.076277, 0.232951, 0.072096, 0.079162, 0.326765, 0.456621, 0.104632, 1.205356, 0.075554, 0.100743, 0.501472, 0.147678, 0.472829, 0.66556 , 0.145095, 0.258632, 0.111284, 0.204145, 0.789139, 1.041254, 2.714972, 9.856695, 9.011336, 8.79128 ])
array([1.323742, 0.799668, 0.655901, 0.630841, 0.54568 , 0.392374, 0.428297, 0.357225, 0.331375, 0.279197, 0.291267, 0.210515, 0.231054, 0.183132, 0.203165, 0.150668, 0.183767, 0.155032, 0.130765, 0.254027, 0.18461 , 0.164027, 1.587358, 1.2792 , 1.234377, 1.404385])
array('descending', dtype='<U10')
array([5.0338030e+00, 1.0001393e+01, 7.0697800e+00, 0.0000000e+00, 2.4000000e-05, 1.7100000e-04, 2.4887230e+00, 4.7091800e-01, 1.5200000e-04, 5.8644800e+00, 2.1700000e-04, 1.3173900e-01, 3.4712000e-02, 3.4000000e-05, 3.0941860e+00, 4.7900000e-04, 6.8915000e-02, 1.5246893e+01, 4.6500000e-04, 1.6390000e-03, 3.0000000e-06, 1.8400000e-04, 3.6979000e-02, 1.3144411e+01, 3.2467100e-01, 1.6510300e-01])
array([3.652413, 0.863242, 1.065909, 4.176993, 3.690336, 1.121065, 4.044588, 3.621408, 3.894635, 1.003202, 3.553024, 1.040657, 3.453157, 1.243095, 3.742994, 1.045133, 3.456634, 1.268738, 3.60455 , 3.834702, 1.011267, 1.07412 , 3.727648, 1.124625, 1.109927, 3.946998])
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array([1.277646, 0.991991, 1.167407, 1.26263 , 0.923307, 0.932377, 2.562061, 1.394824, 0.984245, 1.738879, 1.035986, 0.982437, 1.275216, 1.049667, 1.4299 , 1.756933, 2.124291, 1.210631, 1.313668, 1.603998, 3.394891, 3.067507, 4.377814, 5.895722, 6.460319, 8.579691])
array([10.816842, 11.918814, 10.358963, 11.832625, 12.329768, 12.724151, 9.589529, 11.699309, 12.326572, 11.031749, 12.305065, 12.745297, 12.474465, 12.78944 , 11.116999, 12.473881, 12.214094, 8.251854, 12.486327, 12.196962, 7.055665, 12.891929, 12.825294, 8.046945, 12.740107, 9.798116])
array([0.366022, 0.069933, 0.105276, 0.454663, 0.151699, 0.120276, 1.940389, 0.73282 , 0.15053 , 1.072746, 0.151356, 0.074142, 0.339427, 0.114976, 0.235713, 1.149968, 0.115034, 1.699547, 0.097726, 0.082752, 4.575134, 0.065712, 0.680831, 3.296361, 2.071489, 6.466416])
array(['S2A_MSIL2A_20200626T185921_N0212_R013_T10TET_20200824T044417.SAFE', 'S2B_MSIL2A_20200714T190919_N0212_R056_T10TET_20200918T171907.SAFE', 'S2A_MSIL2A_20200719T190921_N0212_R056_T10TET_20200816T174917.SAFE', 'S2B_MSIL2A_20200721T185919_N0212_R013_T10TET_20200817T013018.SAFE', 'S2A_MSIL2A_20200726T185921_N0212_R013_T10TET_20201024T183833.SAFE', 'S2A_MSIL2A_20200729T190921_N0212_R056_T10TET_20200818T003739.SAFE', 'S2B_MSIL2A_20200731T185919_N0212_R013_T10TET_20200818T085554.SAFE', 'S2A_MSIL2A_20200805T185921_N0212_R013_T10TET_20201025T023207.SAFE', 'S2B_MSIL2A_20200810T185919_N0212_R013_T10TET_20200814T140814.SAFE', 'S2B_MSIL2A_20200813T190919_N0212_R056_T10TET_20201025T101153.SAFE', 'S2A_MSIL2A_20200815T185921_N0212_R013_T10TET_20200818T093648.SAFE', 'S2B_MSIL2A_20200823T190919_N0212_R056_T10TET_20200918T171910.SAFE', 'S2A_MSIL2A_20200825T185921_N0212_R013_T10TET_20200827T175050.SAFE', 'S2A_MSIL2A_20200828T190921_N0212_R056_T10TET_20200907T112416.SAFE', 'S2B_MSIL2A_20200830T185919_N0212_R013_T10TET_20200907T164839.SAFE', 'S2B_MSIL2A_20200902T190919_N0212_R056_T10TET_20200907T231347.SAFE', 'S2A_MSIL2A_20200904T185921_N0212_R013_T10TET_20200908T004502.SAFE', 'S2A_MSIL2A_20200907T190931_N0212_R056_T10TET_20200911T172006.SAFE', 'S2B_MSIL2A_20200909T185929_N0212_R013_T10TET_20200911T225318.SAFE', 'S2B_MSIL2A_20200929T190109_N0212_R013_T10TET_20201001T085751.SAFE', 'S2B_MSIL2A_20201002T191229_N0212_R056_T10TET_20201004T193349.SAFE', 'S2B_MSIL2A_20201101T191539_N0212_R056_T10TET_20201102T211503.SAFE', 'S2B_MSIL2A_20201108T190619_N0212_R013_T10TET_20201109T194251.SAFE', 'S2B_MSIL2A_20201121T191719_N0212_R056_T10TET_20201123T062421.SAFE', 'S2B_MSIL2A_20201201T191749_N0212_R056_T10TET_20201203T103951.SAFE', 'S2B_MSIL2A_20201228T190809_N0212_R013_T10TET_20210113T180911.SAFE'], dtype='<U65')
array(['Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B'], dtype='<U11')
array([ 6.041552, 10.124131, 7.27951 , 1.108193, 0.49786 , 0.516656, 6.070975, 2.732675, 0.5038 , 9.000901, 0.494444, 0.480433, 0.991054, 0.454406, 3.71128 , 6.77912 , 0.436394, 17.323714, 0.372039, 0.330355, 19.443338, 0.285518, 1.863562, 22.483132, 6.071228, 22.940759])
array([ 0.641728, 0.052805, 0.104454, 0.65353 , 0.346137, 0.396209, 1.641863, 1.528937, 0.353118, 2.063675, 0.342871, 0.274552, 0.616915, 0.339397, 0.381381, 5.628673, 0.252445, 0.377274, 0.273848, 0.245964, 14.868201, 0.219621, 1.145752, 6.04236 , 3.675069, 16.30924 ])
array(['S2A_OPER_MSI_L2A_TL_ESRI_20200824T044422_A026179_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171908_A017528_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200816T174919_A026508_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200817T013020_A017628_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201024T183835_A026608_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T003746_A026651_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200818T085557_A017771_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201025T023208_A026751_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200814T140817_A017914_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201025T101155_A017957_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T093651_A026894_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171913_A018100_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200827T175052_A027037_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200907T112418_A027080_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T164841_A018200_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T231350_A018243_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200908T004503_A027180_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200911T172010_A027223_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200911T225319_A018343_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201001T085757_A018629_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201004T193351_A018672_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201102T211503_A019101_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201109T194252_A019201_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201123T062422_A019387_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201203T103952_A019530_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20210113T180913_A019916_T10TET_N02.12'], dtype='<U62')
array([ 0.551698, 0.949986, 1.010717, 0.750271, 0.649873, 0.981145, 0.833694, 0.871897, 0.859027, 1.331455, 0.927462, 1.698198, 1.154426, 1.693115, 1.369677, 2.047128, 1.709112, 1.665192, 1.754655, 2.994806, 2.97027 , 6.86717 , 11.21957 , 11.64913 , 13.50642 , 14.55939 ])
array([13, 56, 56, 13, 13, 56, 13, 13, 13, 56, 13, 56, 13, 56, 13, 56, 13, 56, 13, 13, 56, 56, 13, 56, 56, 13])
array([26.92230609, 28.02159918, 28.86440904, 30.05688459, 31.04824418, 30.91420557, 32.15474265, 33.35257573, 34.65230402, 34.77139642, 36.03408415, 37.78401298, 39.04290975, 39.39861229, 40.65297976, 41.07906148, 42.31869862, 42.81163815, 44.04000347, 51.25564906, 51.97344607, 62.51174953, 64.89541828, 67.92303888, 69.81589416, 71.84870255])
array('INS-NOBS', dtype='<U8')
array([73.603088, 68.675959, 72.683269, 76.473564, 77.052945, 76.423806, 70.652926, 73.470461, 75.761062, 66.351765, 75.416315, 74.643224, 73.5847 , 74.396992, 71.554184, 66.638041, 70.813137, 62.234098, 72.071505, 74.461645, 60.075766, 70.821804, 60.614246, 36.894995, 47.506449, 32.162049])
array('Sentinel 2', dtype='<U10')
array(0.)
array([0.96797835, 0.96756284, 0.96798717, 0.96822101, 0.96896789, 0.96952584, 0.96993992, 0.97113095, 0.97253332, 0.97347475, 0.97413802, 0.9771026 , 0.97791134, 0.97918147, 0.98005514, 0.98141892, 0.98235171, 0.98380003, 0.98478558, 0.99554701, 0.99725851, 1.01421506, 1.01784208, 1.02390093, 1.02778005, 1.03388801])
array(['S2A_OPER_MSI_L2A_DS_ESRI_20200824T044422_S20200626T190834_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171908_S20200714T191949_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200816T174919_S20200719T191624_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200817T013020_S20200721T190421_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201024T183835_S20200726T190505_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T003746_S20200729T191317_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200818T085557_S20200731T190527_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201025T023208_S20200805T190700_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200814T140817_S20200810T190422_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201025T101155_S20200813T191815_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T093651_S20200815T190251_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171913_S20200823T191123_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200827T175052_S20200825T190743_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200907T112418_S20200828T191522_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T164841_S20200830T190346_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T231350_S20200902T191252_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200908T004503_S20200904T190750_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200911T172010_S20200907T191727_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200911T225319_S20200909T191047_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201001T085757_S20200929T190122_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201004T193351_S20201002T192031_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201102T211503_S20201101T191542_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201109T194252_S20201108T190937_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201123T062422_S20201121T191908_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201203T103952_S20201201T191748_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20210113T180913_S20201228T191049_N02.12'], dtype='<U64')
array([147.98616803, 152.66586214, 153.10842649, 148.86916411, 149.63456111, 154.44531626, 150.50706819, 151.54902338, 152.65280533, 157.37977495, 153.86608818, 159.69344332, 156.39362624, 160.90162296, 157.67449547, 162.08618713, 158.9674703 , 163.27013149, 160.21257042, 164.67388951, 168.34785842, 171.49511126, 169.05422731, 171.45575446, 170.86169793, 165.6035432 ])
array(['GS2A_20200626T185921_026179_N02.12', 'GS2B_20200714T190919_017528_N02.12', 'GS2A_20200719T190921_026508_N02.12', 'GS2B_20200721T185919_017628_N02.12', 'GS2A_20200726T185921_026608_N02.12', 'GS2A_20200729T190921_026651_N02.12', 'GS2B_20200731T185919_017771_N02.12', 'GS2A_20200805T185921_026751_N02.12', 'GS2B_20200810T185919_017914_N02.12', 'GS2B_20200813T190919_017957_N02.12', 'GS2A_20200815T185921_026894_N02.12', 'GS2B_20200823T190919_018100_N02.12', 'GS2A_20200825T185921_027037_N02.12', 'GS2A_20200828T190921_027080_N02.12', 'GS2B_20200830T185919_018200_N02.12', 'GS2B_20200902T190919_018243_N02.12', 'GS2A_20200904T185921_027180_N02.12', 'GS2A_20200907T190931_027223_N02.12', 'GS2B_20200909T185929_018343_N02.12', 'GS2B_20200929T190109_018629_N02.12', 'GS2B_20201002T191229_018672_N02.12', 'GS2B_20201101T191539_019101_N02.12', 'GS2B_20201108T190619_019201_N02.12', 'GS2B_20201121T191719_019387_N02.12', 'GS2B_20201201T191749_019530_N02.12', 'GS2B_20201228T190809_019916_N02.12'], dtype='<U34')
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array(['Band 4 - Red - 10m', 'Band 3 - Green - 10m', 'Band 2 - Blue - 10m'], dtype='<U20')
array(10)
array(['red', 'green', 'blue'], dtype='<U5')
array([0.665, 0.56 , 0.49 ])
array([0.038, 0.045, 0.098])
array(32610)
Unfortunately, this median
computation requires an expensive shuffle. Currently we have chunk sizes of (time=1, band=1, y=2048, x=2048)
. To compute the median, all of the values in time
need to be in the same chunk. Dask will automatically rechunk to something like (time=36, band=1, y=256, x=256)
. This means we won't blow up memory on any single task, but it requires shuffling a bunch of data, which can be dangerous to your cluster's health.
bad_result = bad_data.median(dim="time")
bad_result
<xarray.DataArray 'stackstac-6add7ccc542226180faed750e3208a58' (band: 3, y: 10980, x: 10980)> dask.array<nanmedian, shape=(3, 10980, 10980), dtype=float64, chunksize=(1, 512, 512), chunktype=numpy.ndarray> Coordinates: * band (band) <U3 'B04' 'B03' 'B02' * x (x) float64 5e+05 ... 6.098e+05 * y (y) float64 5.3e+06 ... 5.19e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 sat:orbit_state <U10 'descending' s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:datatake_type <U8 'INS-NOBS' constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title (band) <U20 'Band 4 - Red - 10m'... gsd int64 10 common_name (band) <U5 'red' 'green' 'blue' center_wavelength (band) float64 0.665 0.56 0.49 full_width_half_max (band) float64 0.038 0.045 0.098 epsg int64 32610
|
array(['B04', 'B03', 'B02'], dtype='<U3')
array([499980., 499990., 500000., ..., 609750., 609760., 609770.])
array([5300040., 5300030., 5300020., ..., 5190270., 5190260., 5190250.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array('descending', dtype='<U10')
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array('INS-NOBS', dtype='<U8')
array('Sentinel 2', dtype='<U10')
array(0.)
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array(['Band 4 - Red - 10m', 'Band 3 - Green - 10m', 'Band 2 - Blue - 10m'], dtype='<U20')
array(10)
array(['red', 'green', 'blue'], dtype='<U5')
array([0.665, 0.56 , 0.49 ])
array([0.038, 0.045, 0.098])
array(32610)
As a secondary issue, this task graph is also relatively complex. The bad_result
DataArray has ~25,000 tasks, which reflects the intermediate rechunk
operations. Can we do better?
What if we loaded the data how we want it, rather than rechunking after the fact? GDAL / COGs support windowed reads, it's technically feasible to "push" the rechunking operation into the I/O operation.
In the "old" workflow, each task roughly looks like
In this proposed workflow, each data reading task will instead look like:
And that's it. No rechunking, no communication and (hopefully) no memory issues.
Unforunately, the user-level code for this is much more complicated than a simple stackstac.median
! I'm hopeful that Dask could become aware of this type of optimization in the future, to push this kind of rechunk down to the I/O layer if the I/O layer supports it (COG does; I think there's proposed work in Zarr to support something like this). Then we might be able to have our cake (store a single copy of the data) and eat it too (fast-ish access for both spatial and timeseries analysis).
The next section implements this stragegy. If you're just intersted in the result, I recommend skipping to comparison below.
First we need the slices. We know we want chunks of size something like (len(items), 1, ..., ...)
. We can let Dask figure that out for us.
import dask.array
chunks = dask.array.empty(bad_data.shape, chunks=(-1, 1, "auto", "auto"))[0, 0].chunks
slices = dask.array.core.slices_from_chunks(chunks)
slices[:2]
[(slice(0, 732, None), slice(0, 732, None)), (slice(0, 732, None), slice(732, 1464, None))]
We have a few ways to handle reading the actual data. We could use stackstac
, rioxarray
, rasterio directly, etc. We'll use stackstac
since it will handle the time dimension and other metadata for us. It supports cropping with a bounds
argument, so we need to find the bounding box (in native CRS) for each window.
bounds = []
for x_slice, y_slice in slices:
x = bad_data.x[x_slice]
y = bad_data.y[y_slice]
# TODO: our meta is off by 1; maybe backwards?
x_range = x.min().item(), x.max().item() + 0.1
y_range = y.min().item(), y.max().item() + 0.1
bounds.append((x_range[0], y_range[0], x_range[1] + 1, y_range[1] + 1))
Now we need a DataArray per window. This is a bit awkward, since the data will be coming from a lazy / delayed Dask Array, but the metadata needs to be computed eagerly. This could be improved, but seems to work.
@dask.delayed
def read_window(stac_items, asset, bounds):
return stackstac.stack(stac_items.to_dict()["features"], assets=[asset], bounds=bounds).compute(scheduler="single-threaded").where(lambda x: x > 0).data
def read_metadata(stac_items, asset, bounds):
return stackstac.stack(stac_items.to_dict()["features"], assets=[asset], bounds=bounds).where(lambda x: x > 0)
import pystac
%time ic = pystac.ItemCollection(signed_items, clone_items=True)
CPU times: user 23.2 ms, sys: 7.57 ms, total: 30.8 ms Wall time: 28.6 ms
Next, let's get the List of DataArrays. We'll have one DataArray per "timeseries" / window.
This section needs to be optimzied / parallelized. We're nominally just operating on metadata here, but it's still taking too long for interactive analysis.
metas[0].time
<xarray.DataArray 'time' (time: 26)> array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]') Coordinates: * time (time) datetime64[ns] 2020-06-26... id (time) <U54 'S2A_MSIL2A_20200626... s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 s2:generation_time (time) <U24 '2020-08-24T04:44:17... s2:not_vegetated_percentage (time) float64 6.29 6.48 ... 1.764 s2:cloud_shadow_percentage (time) float64 0.095 ... 8.791 s2:snow_ice_percentage (time) float64 1.324 ... 1.404 sat:orbit_state <U10 'descending' s2:thin_cirrus_percentage (time) float64 5.034 ... 0.1651 s2:nodata_pixel_percentage (time) float64 3.652 ... 3.947 s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:unclassified_percentage (time) float64 1.278 0.992 ... 8.58 s2:water_percentage (time) float64 10.82 ... 9.798 s2:medium_proba_clouds_percentage (time) float64 0.366 ... 6.466 s2:product_uri (time) <U65 'S2A_MSIL2A_20200626... platform (time) <U11 'Sentinel-2A' ... 'S... eo:cloud_cover (time) float64 6.042 ... 22.94 s2:high_proba_clouds_percentage (time) float64 0.6417 ... 16.31 s2:granule_id (time) <U62 'S2A_OPER_MSI_L2A_TL... s2:dark_features_percentage (time) float64 0.5517 ... 14.56 sat:relative_orbit (time) int64 13 56 56 ... 56 56 13 s2:mean_solar_zenith (time) float64 26.92 ... 71.85 s2:datatake_type <U8 'INS-NOBS' s2:vegetation_percentage (time) float64 73.6 68.68 ... 32.16 constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 s2:reflectance_conversion_factor (time) float64 0.968 ... 1.034 s2:datastrip_id (time) <U64 'S2A_OPER_MSI_L2A_DS... s2:mean_solar_azimuth (time) float64 148.0 ... 165.6 s2:datatake_id (time) <U34 'GS2A_20200626T18592... proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title <U18 'Band 4 - Red - 10m' gsd int64 10 common_name <U3 'red' center_wavelength float64 0.665 full_width_half_max float64 0.038 epsg int64 32610
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['S2A_MSIL2A_20200626T185921_R013_T10TET_20200824T044417', 'S2B_MSIL2A_20200714T190919_R056_T10TET_20200918T171907', 'S2A_MSIL2A_20200719T190921_R056_T10TET_20200816T174917', 'S2B_MSIL2A_20200721T185919_R013_T10TET_20200817T013018', 'S2A_MSIL2A_20200726T185921_R013_T10TET_20201024T183833', 'S2A_MSIL2A_20200729T190921_R056_T10TET_20200818T003739', 'S2B_MSIL2A_20200731T185919_R013_T10TET_20200818T085554', 'S2A_MSIL2A_20200805T185921_R013_T10TET_20201025T023207', 'S2B_MSIL2A_20200810T185919_R013_T10TET_20200814T140814', 'S2B_MSIL2A_20200813T190919_R056_T10TET_20201025T101153', 'S2A_MSIL2A_20200815T185921_R013_T10TET_20200818T093648', 'S2B_MSIL2A_20200823T190919_R056_T10TET_20200918T171910', 'S2A_MSIL2A_20200825T185921_R013_T10TET_20200827T175050', 'S2A_MSIL2A_20200828T190921_R056_T10TET_20200907T112416', 'S2B_MSIL2A_20200830T185919_R013_T10TET_20200907T164839', 'S2B_MSIL2A_20200902T190919_R056_T10TET_20200907T231347', 'S2A_MSIL2A_20200904T185921_R013_T10TET_20200908T004502', 'S2A_MSIL2A_20200907T190931_R056_T10TET_20200911T172006', 'S2B_MSIL2A_20200909T185929_R013_T10TET_20200911T225318', 'S2B_MSIL2A_20200929T190109_R013_T10TET_20201001T085751', 'S2B_MSIL2A_20201002T191229_R056_T10TET_20201004T193349', 'S2B_MSIL2A_20201101T191539_R056_T10TET_20201102T211503', 'S2B_MSIL2A_20201108T190619_R013_T10TET_20201109T194251', 'S2B_MSIL2A_20201121T191719_R056_T10TET_20201123T062421', 'S2B_MSIL2A_20201201T191749_R056_T10TET_20201203T103951', 'S2B_MSIL2A_20201228T190809_R013_T10TET_20210113T180911'], dtype='<U54')
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array(['2020-08-24T04:44:17.115Z', '2020-09-18T17:19:07.543Z', '2020-08-16T17:49:17.368Z', '2020-08-17T01:30:18.783Z', '2020-10-24T18:38:33.928Z', '2020-08-18T00:37:39.827Z', '2020-08-18T08:55:54.939Z', '2020-10-25T02:32:07.311Z', '2020-08-14T14:08:14.944Z', '2020-10-25T10:11:53.422Z', '2020-08-18T09:36:48.464Z', '2020-09-18T17:19:10.769Z', '2020-08-27T17:50:50.878Z', '2020-09-07T11:24:16.977Z', '2020-09-07T16:48:39.196Z', '2020-09-07T23:13:47.965Z', '2020-09-08T00:45:02.187Z', '2020-09-11T17:20:06.830Z', '2020-09-11T22:53:18.279Z', '2020-10-01T08:57:51.731Z', '2020-10-04T19:33:49.388Z', '2020-11-02T21:15:03.594Z', '2020-11-09T19:42:51.793Z', '2020-11-23T06:24:21.864Z', '2020-12-03T10:39:51.912Z', '2021-01-13T18:09:11.872Z'], dtype='<U24')
array([ 6.290432, 6.480319, 6.767954, 7.708924, 7.928471, 7.950327, 9.535755, 9.016984, 9.12929 , 9.060695, 9.453898, 9.139152, 9.787615, 9.285574, 10.141966, 9.488664, 12.374111, 8.90085 , 11.759762, 7.954067, 6.086313, 4.860784, 4.797184, 3.894184, 3.469761, 1.764327])
array([0.094999, 0.059137, 0.076277, 0.232951, 0.072096, 0.079162, 0.326765, 0.456621, 0.104632, 1.205356, 0.075554, 0.100743, 0.501472, 0.147678, 0.472829, 0.66556 , 0.145095, 0.258632, 0.111284, 0.204145, 0.789139, 1.041254, 2.714972, 9.856695, 9.011336, 8.79128 ])
array([1.323742, 0.799668, 0.655901, 0.630841, 0.54568 , 0.392374, 0.428297, 0.357225, 0.331375, 0.279197, 0.291267, 0.210515, 0.231054, 0.183132, 0.203165, 0.150668, 0.183767, 0.155032, 0.130765, 0.254027, 0.18461 , 0.164027, 1.587358, 1.2792 , 1.234377, 1.404385])
array('descending', dtype='<U10')
array([5.0338030e+00, 1.0001393e+01, 7.0697800e+00, 0.0000000e+00, 2.4000000e-05, 1.7100000e-04, 2.4887230e+00, 4.7091800e-01, 1.5200000e-04, 5.8644800e+00, 2.1700000e-04, 1.3173900e-01, 3.4712000e-02, 3.4000000e-05, 3.0941860e+00, 4.7900000e-04, 6.8915000e-02, 1.5246893e+01, 4.6500000e-04, 1.6390000e-03, 3.0000000e-06, 1.8400000e-04, 3.6979000e-02, 1.3144411e+01, 3.2467100e-01, 1.6510300e-01])
array([3.652413, 0.863242, 1.065909, 4.176993, 3.690336, 1.121065, 4.044588, 3.621408, 3.894635, 1.003202, 3.553024, 1.040657, 3.453157, 1.243095, 3.742994, 1.045133, 3.456634, 1.268738, 3.60455 , 3.834702, 1.011267, 1.07412 , 3.727648, 1.124625, 1.109927, 3.946998])
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array([1.277646, 0.991991, 1.167407, 1.26263 , 0.923307, 0.932377, 2.562061, 1.394824, 0.984245, 1.738879, 1.035986, 0.982437, 1.275216, 1.049667, 1.4299 , 1.756933, 2.124291, 1.210631, 1.313668, 1.603998, 3.394891, 3.067507, 4.377814, 5.895722, 6.460319, 8.579691])
array([10.816842, 11.918814, 10.358963, 11.832625, 12.329768, 12.724151, 9.589529, 11.699309, 12.326572, 11.031749, 12.305065, 12.745297, 12.474465, 12.78944 , 11.116999, 12.473881, 12.214094, 8.251854, 12.486327, 12.196962, 7.055665, 12.891929, 12.825294, 8.046945, 12.740107, 9.798116])
array([0.366022, 0.069933, 0.105276, 0.454663, 0.151699, 0.120276, 1.940389, 0.73282 , 0.15053 , 1.072746, 0.151356, 0.074142, 0.339427, 0.114976, 0.235713, 1.149968, 0.115034, 1.699547, 0.097726, 0.082752, 4.575134, 0.065712, 0.680831, 3.296361, 2.071489, 6.466416])
array(['S2A_MSIL2A_20200626T185921_N0212_R013_T10TET_20200824T044417.SAFE', 'S2B_MSIL2A_20200714T190919_N0212_R056_T10TET_20200918T171907.SAFE', 'S2A_MSIL2A_20200719T190921_N0212_R056_T10TET_20200816T174917.SAFE', 'S2B_MSIL2A_20200721T185919_N0212_R013_T10TET_20200817T013018.SAFE', 'S2A_MSIL2A_20200726T185921_N0212_R013_T10TET_20201024T183833.SAFE', 'S2A_MSIL2A_20200729T190921_N0212_R056_T10TET_20200818T003739.SAFE', 'S2B_MSIL2A_20200731T185919_N0212_R013_T10TET_20200818T085554.SAFE', 'S2A_MSIL2A_20200805T185921_N0212_R013_T10TET_20201025T023207.SAFE', 'S2B_MSIL2A_20200810T185919_N0212_R013_T10TET_20200814T140814.SAFE', 'S2B_MSIL2A_20200813T190919_N0212_R056_T10TET_20201025T101153.SAFE', 'S2A_MSIL2A_20200815T185921_N0212_R013_T10TET_20200818T093648.SAFE', 'S2B_MSIL2A_20200823T190919_N0212_R056_T10TET_20200918T171910.SAFE', 'S2A_MSIL2A_20200825T185921_N0212_R013_T10TET_20200827T175050.SAFE', 'S2A_MSIL2A_20200828T190921_N0212_R056_T10TET_20200907T112416.SAFE', 'S2B_MSIL2A_20200830T185919_N0212_R013_T10TET_20200907T164839.SAFE', 'S2B_MSIL2A_20200902T190919_N0212_R056_T10TET_20200907T231347.SAFE', 'S2A_MSIL2A_20200904T185921_N0212_R013_T10TET_20200908T004502.SAFE', 'S2A_MSIL2A_20200907T190931_N0212_R056_T10TET_20200911T172006.SAFE', 'S2B_MSIL2A_20200909T185929_N0212_R013_T10TET_20200911T225318.SAFE', 'S2B_MSIL2A_20200929T190109_N0212_R013_T10TET_20201001T085751.SAFE', 'S2B_MSIL2A_20201002T191229_N0212_R056_T10TET_20201004T193349.SAFE', 'S2B_MSIL2A_20201101T191539_N0212_R056_T10TET_20201102T211503.SAFE', 'S2B_MSIL2A_20201108T190619_N0212_R013_T10TET_20201109T194251.SAFE', 'S2B_MSIL2A_20201121T191719_N0212_R056_T10TET_20201123T062421.SAFE', 'S2B_MSIL2A_20201201T191749_N0212_R056_T10TET_20201203T103951.SAFE', 'S2B_MSIL2A_20201228T190809_N0212_R013_T10TET_20210113T180911.SAFE'], dtype='<U65')
array(['Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B'], dtype='<U11')
array([ 6.041552, 10.124131, 7.27951 , 1.108193, 0.49786 , 0.516656, 6.070975, 2.732675, 0.5038 , 9.000901, 0.494444, 0.480433, 0.991054, 0.454406, 3.71128 , 6.77912 , 0.436394, 17.323714, 0.372039, 0.330355, 19.443338, 0.285518, 1.863562, 22.483132, 6.071228, 22.940759])
array([ 0.641728, 0.052805, 0.104454, 0.65353 , 0.346137, 0.396209, 1.641863, 1.528937, 0.353118, 2.063675, 0.342871, 0.274552, 0.616915, 0.339397, 0.381381, 5.628673, 0.252445, 0.377274, 0.273848, 0.245964, 14.868201, 0.219621, 1.145752, 6.04236 , 3.675069, 16.30924 ])
array(['S2A_OPER_MSI_L2A_TL_ESRI_20200824T044422_A026179_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171908_A017528_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200816T174919_A026508_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200817T013020_A017628_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201024T183835_A026608_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T003746_A026651_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200818T085557_A017771_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201025T023208_A026751_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200814T140817_A017914_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201025T101155_A017957_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T093651_A026894_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171913_A018100_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200827T175052_A027037_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200907T112418_A027080_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T164841_A018200_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T231350_A018243_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200908T004503_A027180_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200911T172010_A027223_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200911T225319_A018343_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201001T085757_A018629_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201004T193351_A018672_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201102T211503_A019101_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201109T194252_A019201_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201123T062422_A019387_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201203T103952_A019530_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20210113T180913_A019916_T10TET_N02.12'], dtype='<U62')
array([ 0.551698, 0.949986, 1.010717, 0.750271, 0.649873, 0.981145, 0.833694, 0.871897, 0.859027, 1.331455, 0.927462, 1.698198, 1.154426, 1.693115, 1.369677, 2.047128, 1.709112, 1.665192, 1.754655, 2.994806, 2.97027 , 6.86717 , 11.21957 , 11.64913 , 13.50642 , 14.55939 ])
array([13, 56, 56, 13, 13, 56, 13, 13, 13, 56, 13, 56, 13, 56, 13, 56, 13, 56, 13, 13, 56, 56, 13, 56, 56, 13])
array([26.92230609, 28.02159918, 28.86440904, 30.05688459, 31.04824418, 30.91420557, 32.15474265, 33.35257573, 34.65230402, 34.77139642, 36.03408415, 37.78401298, 39.04290975, 39.39861229, 40.65297976, 41.07906148, 42.31869862, 42.81163815, 44.04000347, 51.25564906, 51.97344607, 62.51174953, 64.89541828, 67.92303888, 69.81589416, 71.84870255])
array('INS-NOBS', dtype='<U8')
array([73.603088, 68.675959, 72.683269, 76.473564, 77.052945, 76.423806, 70.652926, 73.470461, 75.761062, 66.351765, 75.416315, 74.643224, 73.5847 , 74.396992, 71.554184, 66.638041, 70.813137, 62.234098, 72.071505, 74.461645, 60.075766, 70.821804, 60.614246, 36.894995, 47.506449, 32.162049])
array('Sentinel 2', dtype='<U10')
array(0.)
array([0.96797835, 0.96756284, 0.96798717, 0.96822101, 0.96896789, 0.96952584, 0.96993992, 0.97113095, 0.97253332, 0.97347475, 0.97413802, 0.9771026 , 0.97791134, 0.97918147, 0.98005514, 0.98141892, 0.98235171, 0.98380003, 0.98478558, 0.99554701, 0.99725851, 1.01421506, 1.01784208, 1.02390093, 1.02778005, 1.03388801])
array(['S2A_OPER_MSI_L2A_DS_ESRI_20200824T044422_S20200626T190834_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171908_S20200714T191949_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200816T174919_S20200719T191624_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200817T013020_S20200721T190421_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201024T183835_S20200726T190505_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T003746_S20200729T191317_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200818T085557_S20200731T190527_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201025T023208_S20200805T190700_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200814T140817_S20200810T190422_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201025T101155_S20200813T191815_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T093651_S20200815T190251_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171913_S20200823T191123_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200827T175052_S20200825T190743_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200907T112418_S20200828T191522_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T164841_S20200830T190346_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T231350_S20200902T191252_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200908T004503_S20200904T190750_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200911T172010_S20200907T191727_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200911T225319_S20200909T191047_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201001T085757_S20200929T190122_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201004T193351_S20201002T192031_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201102T211503_S20201101T191542_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201109T194252_S20201108T190937_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201123T062422_S20201121T191908_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201203T103952_S20201201T191748_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20210113T180913_S20201228T191049_N02.12'], dtype='<U64')
array([147.98616803, 152.66586214, 153.10842649, 148.86916411, 149.63456111, 154.44531626, 150.50706819, 151.54902338, 152.65280533, 157.37977495, 153.86608818, 159.69344332, 156.39362624, 160.90162296, 157.67449547, 162.08618713, 158.9674703 , 163.27013149, 160.21257042, 164.67388951, 168.34785842, 171.49511126, 169.05422731, 171.45575446, 170.86169793, 165.6035432 ])
array(['GS2A_20200626T185921_026179_N02.12', 'GS2B_20200714T190919_017528_N02.12', 'GS2A_20200719T190921_026508_N02.12', 'GS2B_20200721T185919_017628_N02.12', 'GS2A_20200726T185921_026608_N02.12', 'GS2A_20200729T190921_026651_N02.12', 'GS2B_20200731T185919_017771_N02.12', 'GS2A_20200805T185921_026751_N02.12', 'GS2B_20200810T185919_017914_N02.12', 'GS2B_20200813T190919_017957_N02.12', 'GS2A_20200815T185921_026894_N02.12', 'GS2B_20200823T190919_018100_N02.12', 'GS2A_20200825T185921_027037_N02.12', 'GS2A_20200828T190921_027080_N02.12', 'GS2B_20200830T185919_018200_N02.12', 'GS2B_20200902T190919_018243_N02.12', 'GS2A_20200904T185921_027180_N02.12', 'GS2A_20200907T190931_027223_N02.12', 'GS2B_20200909T185929_018343_N02.12', 'GS2B_20200929T190109_018629_N02.12', 'GS2B_20201002T191229_018672_N02.12', 'GS2B_20201101T191539_019101_N02.12', 'GS2B_20201108T190619_019201_N02.12', 'GS2B_20201121T191719_019387_N02.12', 'GS2B_20201201T191749_019530_N02.12', 'GS2B_20201228T190809_019916_N02.12'], dtype='<U34')
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array('Band 4 - Red - 10m', dtype='<U18')
array(10)
array('red', dtype='<U3')
array(0.665)
array(0.038)
array(32610)
%%time
import dask.array as da
import xarray as xr
# might want to parallize this
timeseries = []
assets = ["B04", "B03", "B02"]
for bound in bounds:
metas = [read_metadata(ic, asset, bound) for asset in assets]
data = [read_window(ic, asset, bound) for asset in assets]
xarrays = []
for m, d in zip(metas, data):
xarrays.append(xr.DataArray(
da.from_delayed(d, shape=m.shape, dtype=m.dtype),
coords=m.coords,
dims=m.dims,
attrs=m.attrs,
))
ts = xr.concat(xarrays, dim="band")
timeseries.append(ts)
CPU times: user 23.6 s, sys: 1.17 s, total: 24.8 s Wall time: 23.2 s
Now that we have a List[DataArray]
, we need to assemble them into a single large DataArray. To do that, we'll make a series of "strips" where each strip shares the same x coordinates. We'll then concatenate those strips together to get our final DataArray.
stac_items = ic
asset = "B03"
m = stackstac.stack(stac_items.to_dict()["features"], assets=[asset], bounds=bounds[0]).where(lambda x: x > 0)
m
<xarray.DataArray 'stackstac-e3d8fc4409a42a643b4985fd3694f302' (time: 26, band: 1, y: 732, x: 732)> dask.array<where, shape=(26, 1, 732, 732), dtype=float64, chunksize=(1, 1, 732, 732), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2020-06-26... id (time) <U54 'S2A_MSIL2A_20200626... * band (band) <U3 'B03' * x (x) float64 5e+05 ... 5.073e+05 * y (y) float64 5.3e+06 ... 5.293e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 s2:generation_time (time) <U24 '2020-08-24T04:44:17... s2:not_vegetated_percentage (time) float64 6.29 6.48 ... 1.764 s2:cloud_shadow_percentage (time) float64 0.095 ... 8.791 s2:snow_ice_percentage (time) float64 1.324 ... 1.404 sat:orbit_state <U10 'descending' s2:thin_cirrus_percentage (time) float64 5.034 ... 0.1651 s2:nodata_pixel_percentage (time) float64 3.652 ... 3.947 s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:unclassified_percentage (time) float64 1.278 0.992 ... 8.58 s2:water_percentage (time) float64 10.82 ... 9.798 s2:medium_proba_clouds_percentage (time) float64 0.366 ... 6.466 s2:product_uri (time) <U65 'S2A_MSIL2A_20200626... platform (time) <U11 'Sentinel-2A' ... 'S... eo:cloud_cover (time) float64 6.042 ... 22.94 s2:high_proba_clouds_percentage (time) float64 0.6417 ... 16.31 s2:granule_id (time) <U62 'S2A_OPER_MSI_L2A_TL... s2:dark_features_percentage (time) float64 0.5517 ... 14.56 sat:relative_orbit (time) int64 13 56 56 ... 56 56 13 s2:mean_solar_zenith (time) float64 26.92 ... 71.85 s2:datatake_type <U8 'INS-NOBS' s2:vegetation_percentage (time) float64 73.6 68.68 ... 32.16 constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 s2:reflectance_conversion_factor (time) float64 0.968 ... 1.034 s2:datastrip_id (time) <U64 'S2A_OPER_MSI_L2A_DS... s2:mean_solar_azimuth (time) float64 148.0 ... 165.6 s2:datatake_id (time) <U34 'GS2A_20200626T18592... proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title <U20 'Band 3 - Green - 10m' gsd int64 10 common_name <U5 'green' center_wavelength float64 0.56 full_width_half_max float64 0.045 epsg int64 32610 Attributes: spec: RasterSpec(epsg=32610, bounds=(499980.0, 5292730.0, 507300.0... crs: epsg:32610 transform: | 10.00, 0.00, 499980.00|\n| 0.00,-10.00, 5300050.00|\n| 0.0... resolution: 10.0
|
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['S2A_MSIL2A_20200626T185921_R013_T10TET_20200824T044417', 'S2B_MSIL2A_20200714T190919_R056_T10TET_20200918T171907', 'S2A_MSIL2A_20200719T190921_R056_T10TET_20200816T174917', 'S2B_MSIL2A_20200721T185919_R013_T10TET_20200817T013018', 'S2A_MSIL2A_20200726T185921_R013_T10TET_20201024T183833', 'S2A_MSIL2A_20200729T190921_R056_T10TET_20200818T003739', 'S2B_MSIL2A_20200731T185919_R013_T10TET_20200818T085554', 'S2A_MSIL2A_20200805T185921_R013_T10TET_20201025T023207', 'S2B_MSIL2A_20200810T185919_R013_T10TET_20200814T140814', 'S2B_MSIL2A_20200813T190919_R056_T10TET_20201025T101153', 'S2A_MSIL2A_20200815T185921_R013_T10TET_20200818T093648', 'S2B_MSIL2A_20200823T190919_R056_T10TET_20200918T171910', 'S2A_MSIL2A_20200825T185921_R013_T10TET_20200827T175050', 'S2A_MSIL2A_20200828T190921_R056_T10TET_20200907T112416', 'S2B_MSIL2A_20200830T185919_R013_T10TET_20200907T164839', 'S2B_MSIL2A_20200902T190919_R056_T10TET_20200907T231347', 'S2A_MSIL2A_20200904T185921_R013_T10TET_20200908T004502', 'S2A_MSIL2A_20200907T190931_R056_T10TET_20200911T172006', 'S2B_MSIL2A_20200909T185929_R013_T10TET_20200911T225318', 'S2B_MSIL2A_20200929T190109_R013_T10TET_20201001T085751', 'S2B_MSIL2A_20201002T191229_R056_T10TET_20201004T193349', 'S2B_MSIL2A_20201101T191539_R056_T10TET_20201102T211503', 'S2B_MSIL2A_20201108T190619_R013_T10TET_20201109T194251', 'S2B_MSIL2A_20201121T191719_R056_T10TET_20201123T062421', 'S2B_MSIL2A_20201201T191749_R056_T10TET_20201203T103951', 'S2B_MSIL2A_20201228T190809_R013_T10TET_20210113T180911'], dtype='<U54')
array(['B03'], dtype='<U3')
array([499980., 499990., 500000., ..., 507270., 507280., 507290.])
array([5300050., 5300040., 5300030., ..., 5292760., 5292750., 5292740.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array(['2020-08-24T04:44:17.115Z', '2020-09-18T17:19:07.543Z', '2020-08-16T17:49:17.368Z', '2020-08-17T01:30:18.783Z', '2020-10-24T18:38:33.928Z', '2020-08-18T00:37:39.827Z', '2020-08-18T08:55:54.939Z', '2020-10-25T02:32:07.311Z', '2020-08-14T14:08:14.944Z', '2020-10-25T10:11:53.422Z', '2020-08-18T09:36:48.464Z', '2020-09-18T17:19:10.769Z', '2020-08-27T17:50:50.878Z', '2020-09-07T11:24:16.977Z', '2020-09-07T16:48:39.196Z', '2020-09-07T23:13:47.965Z', '2020-09-08T00:45:02.187Z', '2020-09-11T17:20:06.830Z', '2020-09-11T22:53:18.279Z', '2020-10-01T08:57:51.731Z', '2020-10-04T19:33:49.388Z', '2020-11-02T21:15:03.594Z', '2020-11-09T19:42:51.793Z', '2020-11-23T06:24:21.864Z', '2020-12-03T10:39:51.912Z', '2021-01-13T18:09:11.872Z'], dtype='<U24')
array([ 6.290432, 6.480319, 6.767954, 7.708924, 7.928471, 7.950327, 9.535755, 9.016984, 9.12929 , 9.060695, 9.453898, 9.139152, 9.787615, 9.285574, 10.141966, 9.488664, 12.374111, 8.90085 , 11.759762, 7.954067, 6.086313, 4.860784, 4.797184, 3.894184, 3.469761, 1.764327])
array([0.094999, 0.059137, 0.076277, 0.232951, 0.072096, 0.079162, 0.326765, 0.456621, 0.104632, 1.205356, 0.075554, 0.100743, 0.501472, 0.147678, 0.472829, 0.66556 , 0.145095, 0.258632, 0.111284, 0.204145, 0.789139, 1.041254, 2.714972, 9.856695, 9.011336, 8.79128 ])
array([1.323742, 0.799668, 0.655901, 0.630841, 0.54568 , 0.392374, 0.428297, 0.357225, 0.331375, 0.279197, 0.291267, 0.210515, 0.231054, 0.183132, 0.203165, 0.150668, 0.183767, 0.155032, 0.130765, 0.254027, 0.18461 , 0.164027, 1.587358, 1.2792 , 1.234377, 1.404385])
array('descending', dtype='<U10')
array([5.0338030e+00, 1.0001393e+01, 7.0697800e+00, 0.0000000e+00, 2.4000000e-05, 1.7100000e-04, 2.4887230e+00, 4.7091800e-01, 1.5200000e-04, 5.8644800e+00, 2.1700000e-04, 1.3173900e-01, 3.4712000e-02, 3.4000000e-05, 3.0941860e+00, 4.7900000e-04, 6.8915000e-02, 1.5246893e+01, 4.6500000e-04, 1.6390000e-03, 3.0000000e-06, 1.8400000e-04, 3.6979000e-02, 1.3144411e+01, 3.2467100e-01, 1.6510300e-01])
array([3.652413, 0.863242, 1.065909, 4.176993, 3.690336, 1.121065, 4.044588, 3.621408, 3.894635, 1.003202, 3.553024, 1.040657, 3.453157, 1.243095, 3.742994, 1.045133, 3.456634, 1.268738, 3.60455 , 3.834702, 1.011267, 1.07412 , 3.727648, 1.124625, 1.109927, 3.946998])
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array([1.277646, 0.991991, 1.167407, 1.26263 , 0.923307, 0.932377, 2.562061, 1.394824, 0.984245, 1.738879, 1.035986, 0.982437, 1.275216, 1.049667, 1.4299 , 1.756933, 2.124291, 1.210631, 1.313668, 1.603998, 3.394891, 3.067507, 4.377814, 5.895722, 6.460319, 8.579691])
array([10.816842, 11.918814, 10.358963, 11.832625, 12.329768, 12.724151, 9.589529, 11.699309, 12.326572, 11.031749, 12.305065, 12.745297, 12.474465, 12.78944 , 11.116999, 12.473881, 12.214094, 8.251854, 12.486327, 12.196962, 7.055665, 12.891929, 12.825294, 8.046945, 12.740107, 9.798116])
array([0.366022, 0.069933, 0.105276, 0.454663, 0.151699, 0.120276, 1.940389, 0.73282 , 0.15053 , 1.072746, 0.151356, 0.074142, 0.339427, 0.114976, 0.235713, 1.149968, 0.115034, 1.699547, 0.097726, 0.082752, 4.575134, 0.065712, 0.680831, 3.296361, 2.071489, 6.466416])
array(['S2A_MSIL2A_20200626T185921_N0212_R013_T10TET_20200824T044417.SAFE', 'S2B_MSIL2A_20200714T190919_N0212_R056_T10TET_20200918T171907.SAFE', 'S2A_MSIL2A_20200719T190921_N0212_R056_T10TET_20200816T174917.SAFE', 'S2B_MSIL2A_20200721T185919_N0212_R013_T10TET_20200817T013018.SAFE', 'S2A_MSIL2A_20200726T185921_N0212_R013_T10TET_20201024T183833.SAFE', 'S2A_MSIL2A_20200729T190921_N0212_R056_T10TET_20200818T003739.SAFE', 'S2B_MSIL2A_20200731T185919_N0212_R013_T10TET_20200818T085554.SAFE', 'S2A_MSIL2A_20200805T185921_N0212_R013_T10TET_20201025T023207.SAFE', 'S2B_MSIL2A_20200810T185919_N0212_R013_T10TET_20200814T140814.SAFE', 'S2B_MSIL2A_20200813T190919_N0212_R056_T10TET_20201025T101153.SAFE', 'S2A_MSIL2A_20200815T185921_N0212_R013_T10TET_20200818T093648.SAFE', 'S2B_MSIL2A_20200823T190919_N0212_R056_T10TET_20200918T171910.SAFE', 'S2A_MSIL2A_20200825T185921_N0212_R013_T10TET_20200827T175050.SAFE', 'S2A_MSIL2A_20200828T190921_N0212_R056_T10TET_20200907T112416.SAFE', 'S2B_MSIL2A_20200830T185919_N0212_R013_T10TET_20200907T164839.SAFE', 'S2B_MSIL2A_20200902T190919_N0212_R056_T10TET_20200907T231347.SAFE', 'S2A_MSIL2A_20200904T185921_N0212_R013_T10TET_20200908T004502.SAFE', 'S2A_MSIL2A_20200907T190931_N0212_R056_T10TET_20200911T172006.SAFE', 'S2B_MSIL2A_20200909T185929_N0212_R013_T10TET_20200911T225318.SAFE', 'S2B_MSIL2A_20200929T190109_N0212_R013_T10TET_20201001T085751.SAFE', 'S2B_MSIL2A_20201002T191229_N0212_R056_T10TET_20201004T193349.SAFE', 'S2B_MSIL2A_20201101T191539_N0212_R056_T10TET_20201102T211503.SAFE', 'S2B_MSIL2A_20201108T190619_N0212_R013_T10TET_20201109T194251.SAFE', 'S2B_MSIL2A_20201121T191719_N0212_R056_T10TET_20201123T062421.SAFE', 'S2B_MSIL2A_20201201T191749_N0212_R056_T10TET_20201203T103951.SAFE', 'S2B_MSIL2A_20201228T190809_N0212_R013_T10TET_20210113T180911.SAFE'], dtype='<U65')
array(['Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B'], dtype='<U11')
array([ 6.041552, 10.124131, 7.27951 , 1.108193, 0.49786 , 0.516656, 6.070975, 2.732675, 0.5038 , 9.000901, 0.494444, 0.480433, 0.991054, 0.454406, 3.71128 , 6.77912 , 0.436394, 17.323714, 0.372039, 0.330355, 19.443338, 0.285518, 1.863562, 22.483132, 6.071228, 22.940759])
array([ 0.641728, 0.052805, 0.104454, 0.65353 , 0.346137, 0.396209, 1.641863, 1.528937, 0.353118, 2.063675, 0.342871, 0.274552, 0.616915, 0.339397, 0.381381, 5.628673, 0.252445, 0.377274, 0.273848, 0.245964, 14.868201, 0.219621, 1.145752, 6.04236 , 3.675069, 16.30924 ])
array(['S2A_OPER_MSI_L2A_TL_ESRI_20200824T044422_A026179_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171908_A017528_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200816T174919_A026508_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200817T013020_A017628_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201024T183835_A026608_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T003746_A026651_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200818T085557_A017771_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201025T023208_A026751_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200814T140817_A017914_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201025T101155_A017957_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T093651_A026894_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171913_A018100_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200827T175052_A027037_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200907T112418_A027080_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T164841_A018200_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T231350_A018243_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200908T004503_A027180_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200911T172010_A027223_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200911T225319_A018343_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201001T085757_A018629_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201004T193351_A018672_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201102T211503_A019101_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201109T194252_A019201_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201123T062422_A019387_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201203T103952_A019530_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20210113T180913_A019916_T10TET_N02.12'], dtype='<U62')
array([ 0.551698, 0.949986, 1.010717, 0.750271, 0.649873, 0.981145, 0.833694, 0.871897, 0.859027, 1.331455, 0.927462, 1.698198, 1.154426, 1.693115, 1.369677, 2.047128, 1.709112, 1.665192, 1.754655, 2.994806, 2.97027 , 6.86717 , 11.21957 , 11.64913 , 13.50642 , 14.55939 ])
array([13, 56, 56, 13, 13, 56, 13, 13, 13, 56, 13, 56, 13, 56, 13, 56, 13, 56, 13, 13, 56, 56, 13, 56, 56, 13])
array([26.92230609, 28.02159918, 28.86440904, 30.05688459, 31.04824418, 30.91420557, 32.15474265, 33.35257573, 34.65230402, 34.77139642, 36.03408415, 37.78401298, 39.04290975, 39.39861229, 40.65297976, 41.07906148, 42.31869862, 42.81163815, 44.04000347, 51.25564906, 51.97344607, 62.51174953, 64.89541828, 67.92303888, 69.81589416, 71.84870255])
array('INS-NOBS', dtype='<U8')
array([73.603088, 68.675959, 72.683269, 76.473564, 77.052945, 76.423806, 70.652926, 73.470461, 75.761062, 66.351765, 75.416315, 74.643224, 73.5847 , 74.396992, 71.554184, 66.638041, 70.813137, 62.234098, 72.071505, 74.461645, 60.075766, 70.821804, 60.614246, 36.894995, 47.506449, 32.162049])
array('Sentinel 2', dtype='<U10')
array(0.)
array([0.96797835, 0.96756284, 0.96798717, 0.96822101, 0.96896789, 0.96952584, 0.96993992, 0.97113095, 0.97253332, 0.97347475, 0.97413802, 0.9771026 , 0.97791134, 0.97918147, 0.98005514, 0.98141892, 0.98235171, 0.98380003, 0.98478558, 0.99554701, 0.99725851, 1.01421506, 1.01784208, 1.02390093, 1.02778005, 1.03388801])
array(['S2A_OPER_MSI_L2A_DS_ESRI_20200824T044422_S20200626T190834_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171908_S20200714T191949_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200816T174919_S20200719T191624_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200817T013020_S20200721T190421_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201024T183835_S20200726T190505_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T003746_S20200729T191317_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200818T085557_S20200731T190527_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201025T023208_S20200805T190700_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200814T140817_S20200810T190422_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201025T101155_S20200813T191815_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T093651_S20200815T190251_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171913_S20200823T191123_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200827T175052_S20200825T190743_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200907T112418_S20200828T191522_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T164841_S20200830T190346_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T231350_S20200902T191252_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200908T004503_S20200904T190750_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200911T172010_S20200907T191727_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200911T225319_S20200909T191047_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201001T085757_S20200929T190122_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201004T193351_S20201002T192031_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201102T211503_S20201101T191542_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201109T194252_S20201108T190937_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201123T062422_S20201121T191908_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201203T103952_S20201201T191748_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20210113T180913_S20201228T191049_N02.12'], dtype='<U64')
array([147.98616803, 152.66586214, 153.10842649, 148.86916411, 149.63456111, 154.44531626, 150.50706819, 151.54902338, 152.65280533, 157.37977495, 153.86608818, 159.69344332, 156.39362624, 160.90162296, 157.67449547, 162.08618713, 158.9674703 , 163.27013149, 160.21257042, 164.67388951, 168.34785842, 171.49511126, 169.05422731, 171.45575446, 170.86169793, 165.6035432 ])
array(['GS2A_20200626T185921_026179_N02.12', 'GS2B_20200714T190919_017528_N02.12', 'GS2A_20200719T190921_026508_N02.12', 'GS2B_20200721T185919_017628_N02.12', 'GS2A_20200726T185921_026608_N02.12', 'GS2A_20200729T190921_026651_N02.12', 'GS2B_20200731T185919_017771_N02.12', 'GS2A_20200805T185921_026751_N02.12', 'GS2B_20200810T185919_017914_N02.12', 'GS2B_20200813T190919_017957_N02.12', 'GS2A_20200815T185921_026894_N02.12', 'GS2B_20200823T190919_018100_N02.12', 'GS2A_20200825T185921_027037_N02.12', 'GS2A_20200828T190921_027080_N02.12', 'GS2B_20200830T185919_018200_N02.12', 'GS2B_20200902T190919_018243_N02.12', 'GS2A_20200904T185921_027180_N02.12', 'GS2A_20200907T190931_027223_N02.12', 'GS2B_20200909T185929_018343_N02.12', 'GS2B_20200929T190109_018629_N02.12', 'GS2B_20201002T191229_018672_N02.12', 'GS2B_20201101T191539_019101_N02.12', 'GS2B_20201108T190619_019201_N02.12', 'GS2B_20201121T191719_019387_N02.12', 'GS2B_20201201T191749_019530_N02.12', 'GS2B_20201228T190809_019916_N02.12'], dtype='<U34')
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array('Band 3 - Green - 10m', dtype='<U20')
array(10)
array('green', dtype='<U5')
array(0.56)
array(0.045)
array(32610)
bad_data[:, 0, :732, :732]
<xarray.DataArray 'stackstac-6add7ccc542226180faed750e3208a58' (time: 26, y: 732, x: 732)> dask.array<getitem, shape=(26, 732, 732), dtype=float64, chunksize=(1, 732, 732), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2020-06-26... id (time) <U54 'S2A_MSIL2A_20200626... band <U3 'B04' * x (x) float64 5e+05 ... 5.073e+05 * y (y) float64 5.3e+06 ... 5.293e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 s2:generation_time (time) <U24 '2020-08-24T04:44:17... s2:not_vegetated_percentage (time) float64 6.29 6.48 ... 1.764 s2:cloud_shadow_percentage (time) float64 0.095 ... 8.791 s2:snow_ice_percentage (time) float64 1.324 ... 1.404 sat:orbit_state <U10 'descending' s2:thin_cirrus_percentage (time) float64 5.034 ... 0.1651 s2:nodata_pixel_percentage (time) float64 3.652 ... 3.947 s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:unclassified_percentage (time) float64 1.278 0.992 ... 8.58 s2:water_percentage (time) float64 10.82 ... 9.798 s2:medium_proba_clouds_percentage (time) float64 0.366 ... 6.466 s2:product_uri (time) <U65 'S2A_MSIL2A_20200626... platform (time) <U11 'Sentinel-2A' ... 'S... eo:cloud_cover (time) float64 6.042 ... 22.94 s2:high_proba_clouds_percentage (time) float64 0.6417 ... 16.31 s2:granule_id (time) <U62 'S2A_OPER_MSI_L2A_TL... s2:dark_features_percentage (time) float64 0.5517 ... 14.56 sat:relative_orbit (time) int64 13 56 56 ... 56 56 13 s2:mean_solar_zenith (time) float64 26.92 ... 71.85 s2:datatake_type <U8 'INS-NOBS' s2:vegetation_percentage (time) float64 73.6 68.68 ... 32.16 constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 s2:reflectance_conversion_factor (time) float64 0.968 ... 1.034 s2:datastrip_id (time) <U64 'S2A_OPER_MSI_L2A_DS... s2:mean_solar_azimuth (time) float64 148.0 ... 165.6 s2:datatake_id (time) <U34 'GS2A_20200626T18592... proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title <U20 'Band 4 - Red - 10m' gsd int64 10 common_name <U5 'red' center_wavelength float64 0.665 full_width_half_max float64 0.038 epsg int64 32610 Attributes: spec: RasterSpec(epsg=32610, bounds=(499980.0, 5190240.0, 609780.0... crs: epsg:32610 transform: | 10.00, 0.00, 499980.00|\n| 0.00,-10.00, 5300040.00|\n| 0.0... resolution: 10.0
|
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['S2A_MSIL2A_20200626T185921_R013_T10TET_20200824T044417', 'S2B_MSIL2A_20200714T190919_R056_T10TET_20200918T171907', 'S2A_MSIL2A_20200719T190921_R056_T10TET_20200816T174917', 'S2B_MSIL2A_20200721T185919_R013_T10TET_20200817T013018', 'S2A_MSIL2A_20200726T185921_R013_T10TET_20201024T183833', 'S2A_MSIL2A_20200729T190921_R056_T10TET_20200818T003739', 'S2B_MSIL2A_20200731T185919_R013_T10TET_20200818T085554', 'S2A_MSIL2A_20200805T185921_R013_T10TET_20201025T023207', 'S2B_MSIL2A_20200810T185919_R013_T10TET_20200814T140814', 'S2B_MSIL2A_20200813T190919_R056_T10TET_20201025T101153', 'S2A_MSIL2A_20200815T185921_R013_T10TET_20200818T093648', 'S2B_MSIL2A_20200823T190919_R056_T10TET_20200918T171910', 'S2A_MSIL2A_20200825T185921_R013_T10TET_20200827T175050', 'S2A_MSIL2A_20200828T190921_R056_T10TET_20200907T112416', 'S2B_MSIL2A_20200830T185919_R013_T10TET_20200907T164839', 'S2B_MSIL2A_20200902T190919_R056_T10TET_20200907T231347', 'S2A_MSIL2A_20200904T185921_R013_T10TET_20200908T004502', 'S2A_MSIL2A_20200907T190931_R056_T10TET_20200911T172006', 'S2B_MSIL2A_20200909T185929_R013_T10TET_20200911T225318', 'S2B_MSIL2A_20200929T190109_R013_T10TET_20201001T085751', 'S2B_MSIL2A_20201002T191229_R056_T10TET_20201004T193349', 'S2B_MSIL2A_20201101T191539_R056_T10TET_20201102T211503', 'S2B_MSIL2A_20201108T190619_R013_T10TET_20201109T194251', 'S2B_MSIL2A_20201121T191719_R056_T10TET_20201123T062421', 'S2B_MSIL2A_20201201T191749_R056_T10TET_20201203T103951', 'S2B_MSIL2A_20201228T190809_R013_T10TET_20210113T180911'], dtype='<U54')
array('B04', dtype='<U3')
array([499980., 499990., 500000., ..., 507270., 507280., 507290.])
array([5300040., 5300030., 5300020., ..., 5292750., 5292740., 5292730.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array(['2020-08-24T04:44:17.115Z', '2020-09-18T17:19:07.543Z', '2020-08-16T17:49:17.368Z', '2020-08-17T01:30:18.783Z', '2020-10-24T18:38:33.928Z', '2020-08-18T00:37:39.827Z', '2020-08-18T08:55:54.939Z', '2020-10-25T02:32:07.311Z', '2020-08-14T14:08:14.944Z', '2020-10-25T10:11:53.422Z', '2020-08-18T09:36:48.464Z', '2020-09-18T17:19:10.769Z', '2020-08-27T17:50:50.878Z', '2020-09-07T11:24:16.977Z', '2020-09-07T16:48:39.196Z', '2020-09-07T23:13:47.965Z', '2020-09-08T00:45:02.187Z', '2020-09-11T17:20:06.830Z', '2020-09-11T22:53:18.279Z', '2020-10-01T08:57:51.731Z', '2020-10-04T19:33:49.388Z', '2020-11-02T21:15:03.594Z', '2020-11-09T19:42:51.793Z', '2020-11-23T06:24:21.864Z', '2020-12-03T10:39:51.912Z', '2021-01-13T18:09:11.872Z'], dtype='<U24')
array([ 6.290432, 6.480319, 6.767954, 7.708924, 7.928471, 7.950327, 9.535755, 9.016984, 9.12929 , 9.060695, 9.453898, 9.139152, 9.787615, 9.285574, 10.141966, 9.488664, 12.374111, 8.90085 , 11.759762, 7.954067, 6.086313, 4.860784, 4.797184, 3.894184, 3.469761, 1.764327])
array([0.094999, 0.059137, 0.076277, 0.232951, 0.072096, 0.079162, 0.326765, 0.456621, 0.104632, 1.205356, 0.075554, 0.100743, 0.501472, 0.147678, 0.472829, 0.66556 , 0.145095, 0.258632, 0.111284, 0.204145, 0.789139, 1.041254, 2.714972, 9.856695, 9.011336, 8.79128 ])
array([1.323742, 0.799668, 0.655901, 0.630841, 0.54568 , 0.392374, 0.428297, 0.357225, 0.331375, 0.279197, 0.291267, 0.210515, 0.231054, 0.183132, 0.203165, 0.150668, 0.183767, 0.155032, 0.130765, 0.254027, 0.18461 , 0.164027, 1.587358, 1.2792 , 1.234377, 1.404385])
array('descending', dtype='<U10')
array([5.0338030e+00, 1.0001393e+01, 7.0697800e+00, 0.0000000e+00, 2.4000000e-05, 1.7100000e-04, 2.4887230e+00, 4.7091800e-01, 1.5200000e-04, 5.8644800e+00, 2.1700000e-04, 1.3173900e-01, 3.4712000e-02, 3.4000000e-05, 3.0941860e+00, 4.7900000e-04, 6.8915000e-02, 1.5246893e+01, 4.6500000e-04, 1.6390000e-03, 3.0000000e-06, 1.8400000e-04, 3.6979000e-02, 1.3144411e+01, 3.2467100e-01, 1.6510300e-01])
array([3.652413, 0.863242, 1.065909, 4.176993, 3.690336, 1.121065, 4.044588, 3.621408, 3.894635, 1.003202, 3.553024, 1.040657, 3.453157, 1.243095, 3.742994, 1.045133, 3.456634, 1.268738, 3.60455 , 3.834702, 1.011267, 1.07412 , 3.727648, 1.124625, 1.109927, 3.946998])
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array([1.277646, 0.991991, 1.167407, 1.26263 , 0.923307, 0.932377, 2.562061, 1.394824, 0.984245, 1.738879, 1.035986, 0.982437, 1.275216, 1.049667, 1.4299 , 1.756933, 2.124291, 1.210631, 1.313668, 1.603998, 3.394891, 3.067507, 4.377814, 5.895722, 6.460319, 8.579691])
array([10.816842, 11.918814, 10.358963, 11.832625, 12.329768, 12.724151, 9.589529, 11.699309, 12.326572, 11.031749, 12.305065, 12.745297, 12.474465, 12.78944 , 11.116999, 12.473881, 12.214094, 8.251854, 12.486327, 12.196962, 7.055665, 12.891929, 12.825294, 8.046945, 12.740107, 9.798116])
array([0.366022, 0.069933, 0.105276, 0.454663, 0.151699, 0.120276, 1.940389, 0.73282 , 0.15053 , 1.072746, 0.151356, 0.074142, 0.339427, 0.114976, 0.235713, 1.149968, 0.115034, 1.699547, 0.097726, 0.082752, 4.575134, 0.065712, 0.680831, 3.296361, 2.071489, 6.466416])
array(['S2A_MSIL2A_20200626T185921_N0212_R013_T10TET_20200824T044417.SAFE', 'S2B_MSIL2A_20200714T190919_N0212_R056_T10TET_20200918T171907.SAFE', 'S2A_MSIL2A_20200719T190921_N0212_R056_T10TET_20200816T174917.SAFE', 'S2B_MSIL2A_20200721T185919_N0212_R013_T10TET_20200817T013018.SAFE', 'S2A_MSIL2A_20200726T185921_N0212_R013_T10TET_20201024T183833.SAFE', 'S2A_MSIL2A_20200729T190921_N0212_R056_T10TET_20200818T003739.SAFE', 'S2B_MSIL2A_20200731T185919_N0212_R013_T10TET_20200818T085554.SAFE', 'S2A_MSIL2A_20200805T185921_N0212_R013_T10TET_20201025T023207.SAFE', 'S2B_MSIL2A_20200810T185919_N0212_R013_T10TET_20200814T140814.SAFE', 'S2B_MSIL2A_20200813T190919_N0212_R056_T10TET_20201025T101153.SAFE', 'S2A_MSIL2A_20200815T185921_N0212_R013_T10TET_20200818T093648.SAFE', 'S2B_MSIL2A_20200823T190919_N0212_R056_T10TET_20200918T171910.SAFE', 'S2A_MSIL2A_20200825T185921_N0212_R013_T10TET_20200827T175050.SAFE', 'S2A_MSIL2A_20200828T190921_N0212_R056_T10TET_20200907T112416.SAFE', 'S2B_MSIL2A_20200830T185919_N0212_R013_T10TET_20200907T164839.SAFE', 'S2B_MSIL2A_20200902T190919_N0212_R056_T10TET_20200907T231347.SAFE', 'S2A_MSIL2A_20200904T185921_N0212_R013_T10TET_20200908T004502.SAFE', 'S2A_MSIL2A_20200907T190931_N0212_R056_T10TET_20200911T172006.SAFE', 'S2B_MSIL2A_20200909T185929_N0212_R013_T10TET_20200911T225318.SAFE', 'S2B_MSIL2A_20200929T190109_N0212_R013_T10TET_20201001T085751.SAFE', 'S2B_MSIL2A_20201002T191229_N0212_R056_T10TET_20201004T193349.SAFE', 'S2B_MSIL2A_20201101T191539_N0212_R056_T10TET_20201102T211503.SAFE', 'S2B_MSIL2A_20201108T190619_N0212_R013_T10TET_20201109T194251.SAFE', 'S2B_MSIL2A_20201121T191719_N0212_R056_T10TET_20201123T062421.SAFE', 'S2B_MSIL2A_20201201T191749_N0212_R056_T10TET_20201203T103951.SAFE', 'S2B_MSIL2A_20201228T190809_N0212_R013_T10TET_20210113T180911.SAFE'], dtype='<U65')
array(['Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B'], dtype='<U11')
array([ 6.041552, 10.124131, 7.27951 , 1.108193, 0.49786 , 0.516656, 6.070975, 2.732675, 0.5038 , 9.000901, 0.494444, 0.480433, 0.991054, 0.454406, 3.71128 , 6.77912 , 0.436394, 17.323714, 0.372039, 0.330355, 19.443338, 0.285518, 1.863562, 22.483132, 6.071228, 22.940759])
array([ 0.641728, 0.052805, 0.104454, 0.65353 , 0.346137, 0.396209, 1.641863, 1.528937, 0.353118, 2.063675, 0.342871, 0.274552, 0.616915, 0.339397, 0.381381, 5.628673, 0.252445, 0.377274, 0.273848, 0.245964, 14.868201, 0.219621, 1.145752, 6.04236 , 3.675069, 16.30924 ])
array(['S2A_OPER_MSI_L2A_TL_ESRI_20200824T044422_A026179_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171908_A017528_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200816T174919_A026508_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200817T013020_A017628_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201024T183835_A026608_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T003746_A026651_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200818T085557_A017771_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201025T023208_A026751_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200814T140817_A017914_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201025T101155_A017957_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T093651_A026894_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171913_A018100_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200827T175052_A027037_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200907T112418_A027080_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T164841_A018200_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T231350_A018243_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200908T004503_A027180_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200911T172010_A027223_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200911T225319_A018343_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201001T085757_A018629_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201004T193351_A018672_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201102T211503_A019101_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201109T194252_A019201_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201123T062422_A019387_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201203T103952_A019530_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20210113T180913_A019916_T10TET_N02.12'], dtype='<U62')
array([ 0.551698, 0.949986, 1.010717, 0.750271, 0.649873, 0.981145, 0.833694, 0.871897, 0.859027, 1.331455, 0.927462, 1.698198, 1.154426, 1.693115, 1.369677, 2.047128, 1.709112, 1.665192, 1.754655, 2.994806, 2.97027 , 6.86717 , 11.21957 , 11.64913 , 13.50642 , 14.55939 ])
array([13, 56, 56, 13, 13, 56, 13, 13, 13, 56, 13, 56, 13, 56, 13, 56, 13, 56, 13, 13, 56, 56, 13, 56, 56, 13])
array([26.92230609, 28.02159918, 28.86440904, 30.05688459, 31.04824418, 30.91420557, 32.15474265, 33.35257573, 34.65230402, 34.77139642, 36.03408415, 37.78401298, 39.04290975, 39.39861229, 40.65297976, 41.07906148, 42.31869862, 42.81163815, 44.04000347, 51.25564906, 51.97344607, 62.51174953, 64.89541828, 67.92303888, 69.81589416, 71.84870255])
array('INS-NOBS', dtype='<U8')
array([73.603088, 68.675959, 72.683269, 76.473564, 77.052945, 76.423806, 70.652926, 73.470461, 75.761062, 66.351765, 75.416315, 74.643224, 73.5847 , 74.396992, 71.554184, 66.638041, 70.813137, 62.234098, 72.071505, 74.461645, 60.075766, 70.821804, 60.614246, 36.894995, 47.506449, 32.162049])
array('Sentinel 2', dtype='<U10')
array(0.)
array([0.96797835, 0.96756284, 0.96798717, 0.96822101, 0.96896789, 0.96952584, 0.96993992, 0.97113095, 0.97253332, 0.97347475, 0.97413802, 0.9771026 , 0.97791134, 0.97918147, 0.98005514, 0.98141892, 0.98235171, 0.98380003, 0.98478558, 0.99554701, 0.99725851, 1.01421506, 1.01784208, 1.02390093, 1.02778005, 1.03388801])
array(['S2A_OPER_MSI_L2A_DS_ESRI_20200824T044422_S20200626T190834_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171908_S20200714T191949_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200816T174919_S20200719T191624_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200817T013020_S20200721T190421_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201024T183835_S20200726T190505_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T003746_S20200729T191317_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200818T085557_S20200731T190527_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201025T023208_S20200805T190700_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200814T140817_S20200810T190422_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201025T101155_S20200813T191815_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T093651_S20200815T190251_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171913_S20200823T191123_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200827T175052_S20200825T190743_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200907T112418_S20200828T191522_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T164841_S20200830T190346_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T231350_S20200902T191252_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200908T004503_S20200904T190750_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200911T172010_S20200907T191727_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200911T225319_S20200909T191047_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201001T085757_S20200929T190122_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201004T193351_S20201002T192031_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201102T211503_S20201101T191542_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201109T194252_S20201108T190937_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201123T062422_S20201121T191908_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201203T103952_S20201201T191748_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20210113T180913_S20201228T191049_N02.12'], dtype='<U64')
array([147.98616803, 152.66586214, 153.10842649, 148.86916411, 149.63456111, 154.44531626, 150.50706819, 151.54902338, 152.65280533, 157.37977495, 153.86608818, 159.69344332, 156.39362624, 160.90162296, 157.67449547, 162.08618713, 158.9674703 , 163.27013149, 160.21257042, 164.67388951, 168.34785842, 171.49511126, 169.05422731, 171.45575446, 170.86169793, 165.6035432 ])
array(['GS2A_20200626T185921_026179_N02.12', 'GS2B_20200714T190919_017528_N02.12', 'GS2A_20200719T190921_026508_N02.12', 'GS2B_20200721T185919_017628_N02.12', 'GS2A_20200726T185921_026608_N02.12', 'GS2A_20200729T190921_026651_N02.12', 'GS2B_20200731T185919_017771_N02.12', 'GS2A_20200805T185921_026751_N02.12', 'GS2B_20200810T185919_017914_N02.12', 'GS2B_20200813T190919_017957_N02.12', 'GS2A_20200815T185921_026894_N02.12', 'GS2B_20200823T190919_018100_N02.12', 'GS2A_20200825T185921_027037_N02.12', 'GS2A_20200828T190921_027080_N02.12', 'GS2B_20200830T185919_018200_N02.12', 'GS2B_20200902T190919_018243_N02.12', 'GS2A_20200904T185921_027180_N02.12', 'GS2A_20200907T190931_027223_N02.12', 'GS2B_20200909T185929_018343_N02.12', 'GS2B_20200929T190109_018629_N02.12', 'GS2B_20201002T191229_018672_N02.12', 'GS2B_20201101T191539_019101_N02.12', 'GS2B_20201108T190619_019201_N02.12', 'GS2B_20201121T191719_019387_N02.12', 'GS2B_20201201T191749_019530_N02.12', 'GS2B_20201228T190809_019916_N02.12'], dtype='<U34')
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array('Band 4 - Red - 10m', dtype='<U20')
array(10)
array('red', dtype='<U5')
array(0.665)
array(0.038)
array(32610)
import itertools
key = lambda arr: arr.x[0].item()
strips = [
xr.concat(list(v), dim="y")
for _, v in itertools.groupby(timeseries, key=key)
]
good_data = xr.concat(strips, dim="x")
good_data
<xarray.DataArray 'from-value-5bb16d51b8ec4f402aed7f070a7fbdc8' (time: 26, band: 3, y: 10980, x: 10980)> dask.array<concatenate, shape=(26, 3, 10980, 10980), dtype=float64, chunksize=(26, 1, 732, 732), chunktype=numpy.ndarray> Coordinates: * time (time) datetime64[ns] 2020-06-26... id (time) <U54 'S2A_MSIL2A_20200626... * band (band) <U3 'B04' 'B03' 'B02' * x (x) float64 5e+05 ... 6.098e+05 * y (y) float64 5.3e+06 ... 5.19e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 s2:generation_time (time) <U24 '2020-08-24T04:44:17... s2:not_vegetated_percentage (time) float64 6.29 6.48 ... 1.764 s2:cloud_shadow_percentage (time) float64 0.095 ... 8.791 s2:snow_ice_percentage (time) float64 1.324 ... 1.404 sat:orbit_state <U10 'descending' s2:thin_cirrus_percentage (time) float64 5.034 ... 0.1651 s2:nodata_pixel_percentage (time) float64 3.652 ... 3.947 s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:unclassified_percentage (time) float64 1.278 0.992 ... 8.58 s2:water_percentage (time) float64 10.82 ... 9.798 s2:medium_proba_clouds_percentage (time) float64 0.366 ... 6.466 s2:product_uri (time) <U65 'S2A_MSIL2A_20200626... platform (time) <U11 'Sentinel-2A' ... 'S... eo:cloud_cover (time) float64 6.042 ... 22.94 s2:high_proba_clouds_percentage (time) float64 0.6417 ... 16.31 s2:granule_id (time) <U62 'S2A_OPER_MSI_L2A_TL... s2:dark_features_percentage (time) float64 0.5517 ... 14.56 sat:relative_orbit (time) int64 13 56 56 ... 56 56 13 s2:mean_solar_zenith (time) float64 26.92 ... 71.85 s2:datatake_type <U8 'INS-NOBS' s2:vegetation_percentage (time) float64 73.6 68.68 ... 32.16 constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 s2:reflectance_conversion_factor (time) float64 0.968 ... 1.034 s2:datastrip_id (time) <U64 'S2A_OPER_MSI_L2A_DS... s2:mean_solar_azimuth (time) float64 148.0 ... 165.6 s2:datatake_id (time) <U34 'GS2A_20200626T18592... proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title (band) <U20 'Band 4 - Red - 10m'... gsd int64 10 common_name (band) <U5 'red' 'green' 'blue' center_wavelength (band) float64 0.665 0.56 0.49 full_width_half_max (band) float64 0.038 0.045 0.098 epsg int64 32610 Attributes: spec: RasterSpec(epsg=32610, bounds=(499980.0, 5292730.0, 507300.0... crs: epsg:32610 transform: | 10.00, 0.00, 499980.00|\n| 0.00,-10.00, 5300050.00|\n| 0.0... resolution: 10.0
|
array(['2020-06-26T18:59:21.024000000', '2020-07-14T19:09:19.024000000', '2020-07-19T19:09:21.024000000', '2020-07-21T18:59:19.024000000', '2020-07-26T18:59:21.024000000', '2020-07-29T19:09:21.024000000', '2020-07-31T18:59:19.024000000', '2020-08-05T18:59:21.024000000', '2020-08-10T18:59:19.024000000', '2020-08-13T19:09:19.024000000', '2020-08-15T18:59:21.024000000', '2020-08-23T19:09:19.024000000', '2020-08-25T18:59:21.024000000', '2020-08-28T19:09:21.024000000', '2020-08-30T18:59:19.024000000', '2020-09-02T19:09:19.024000000', '2020-09-04T18:59:21.024000000', '2020-09-07T19:09:31.024000000', '2020-09-09T18:59:29.024000000', '2020-09-29T19:01:09.024000000', '2020-10-02T19:12:29.024000000', '2020-11-01T19:15:39.024000000', '2020-11-08T19:06:19.024000000', '2020-11-21T19:17:19.024000000', '2020-12-01T19:17:49.024000000', '2020-12-28T19:08:09.024000000'], dtype='datetime64[ns]')
array(['S2A_MSIL2A_20200626T185921_R013_T10TET_20200824T044417', 'S2B_MSIL2A_20200714T190919_R056_T10TET_20200918T171907', 'S2A_MSIL2A_20200719T190921_R056_T10TET_20200816T174917', 'S2B_MSIL2A_20200721T185919_R013_T10TET_20200817T013018', 'S2A_MSIL2A_20200726T185921_R013_T10TET_20201024T183833', 'S2A_MSIL2A_20200729T190921_R056_T10TET_20200818T003739', 'S2B_MSIL2A_20200731T185919_R013_T10TET_20200818T085554', 'S2A_MSIL2A_20200805T185921_R013_T10TET_20201025T023207', 'S2B_MSIL2A_20200810T185919_R013_T10TET_20200814T140814', 'S2B_MSIL2A_20200813T190919_R056_T10TET_20201025T101153', 'S2A_MSIL2A_20200815T185921_R013_T10TET_20200818T093648', 'S2B_MSIL2A_20200823T190919_R056_T10TET_20200918T171910', 'S2A_MSIL2A_20200825T185921_R013_T10TET_20200827T175050', 'S2A_MSIL2A_20200828T190921_R056_T10TET_20200907T112416', 'S2B_MSIL2A_20200830T185919_R013_T10TET_20200907T164839', 'S2B_MSIL2A_20200902T190919_R056_T10TET_20200907T231347', 'S2A_MSIL2A_20200904T185921_R013_T10TET_20200908T004502', 'S2A_MSIL2A_20200907T190931_R056_T10TET_20200911T172006', 'S2B_MSIL2A_20200909T185929_R013_T10TET_20200911T225318', 'S2B_MSIL2A_20200929T190109_R013_T10TET_20201001T085751', 'S2B_MSIL2A_20201002T191229_R056_T10TET_20201004T193349', 'S2B_MSIL2A_20201101T191539_R056_T10TET_20201102T211503', 'S2B_MSIL2A_20201108T190619_R013_T10TET_20201109T194251', 'S2B_MSIL2A_20201121T191719_R056_T10TET_20201123T062421', 'S2B_MSIL2A_20201201T191749_R056_T10TET_20201203T103951', 'S2B_MSIL2A_20201228T190809_R013_T10TET_20210113T180911'], dtype='<U54')
array(['B04', 'B03', 'B02'], dtype='<U3')
array([499980., 499990., 500000., ..., 609750., 609760., 609770.])
array([5300050., 5300040., 5300030., ..., 5190280., 5190270., 5190260.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array(['2020-08-24T04:44:17.115Z', '2020-09-18T17:19:07.543Z', '2020-08-16T17:49:17.368Z', '2020-08-17T01:30:18.783Z', '2020-10-24T18:38:33.928Z', '2020-08-18T00:37:39.827Z', '2020-08-18T08:55:54.939Z', '2020-10-25T02:32:07.311Z', '2020-08-14T14:08:14.944Z', '2020-10-25T10:11:53.422Z', '2020-08-18T09:36:48.464Z', '2020-09-18T17:19:10.769Z', '2020-08-27T17:50:50.878Z', '2020-09-07T11:24:16.977Z', '2020-09-07T16:48:39.196Z', '2020-09-07T23:13:47.965Z', '2020-09-08T00:45:02.187Z', '2020-09-11T17:20:06.830Z', '2020-09-11T22:53:18.279Z', '2020-10-01T08:57:51.731Z', '2020-10-04T19:33:49.388Z', '2020-11-02T21:15:03.594Z', '2020-11-09T19:42:51.793Z', '2020-11-23T06:24:21.864Z', '2020-12-03T10:39:51.912Z', '2021-01-13T18:09:11.872Z'], dtype='<U24')
array([ 6.290432, 6.480319, 6.767954, 7.708924, 7.928471, 7.950327, 9.535755, 9.016984, 9.12929 , 9.060695, 9.453898, 9.139152, 9.787615, 9.285574, 10.141966, 9.488664, 12.374111, 8.90085 , 11.759762, 7.954067, 6.086313, 4.860784, 4.797184, 3.894184, 3.469761, 1.764327])
array([0.094999, 0.059137, 0.076277, 0.232951, 0.072096, 0.079162, 0.326765, 0.456621, 0.104632, 1.205356, 0.075554, 0.100743, 0.501472, 0.147678, 0.472829, 0.66556 , 0.145095, 0.258632, 0.111284, 0.204145, 0.789139, 1.041254, 2.714972, 9.856695, 9.011336, 8.79128 ])
array([1.323742, 0.799668, 0.655901, 0.630841, 0.54568 , 0.392374, 0.428297, 0.357225, 0.331375, 0.279197, 0.291267, 0.210515, 0.231054, 0.183132, 0.203165, 0.150668, 0.183767, 0.155032, 0.130765, 0.254027, 0.18461 , 0.164027, 1.587358, 1.2792 , 1.234377, 1.404385])
array('descending', dtype='<U10')
array([5.0338030e+00, 1.0001393e+01, 7.0697800e+00, 0.0000000e+00, 2.4000000e-05, 1.7100000e-04, 2.4887230e+00, 4.7091800e-01, 1.5200000e-04, 5.8644800e+00, 2.1700000e-04, 1.3173900e-01, 3.4712000e-02, 3.4000000e-05, 3.0941860e+00, 4.7900000e-04, 6.8915000e-02, 1.5246893e+01, 4.6500000e-04, 1.6390000e-03, 3.0000000e-06, 1.8400000e-04, 3.6979000e-02, 1.3144411e+01, 3.2467100e-01, 1.6510300e-01])
array([3.652413, 0.863242, 1.065909, 4.176993, 3.690336, 1.121065, 4.044588, 3.621408, 3.894635, 1.003202, 3.553024, 1.040657, 3.453157, 1.243095, 3.742994, 1.045133, 3.456634, 1.268738, 3.60455 , 3.834702, 1.011267, 1.07412 , 3.727648, 1.124625, 1.109927, 3.946998])
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array([1.277646, 0.991991, 1.167407, 1.26263 , 0.923307, 0.932377, 2.562061, 1.394824, 0.984245, 1.738879, 1.035986, 0.982437, 1.275216, 1.049667, 1.4299 , 1.756933, 2.124291, 1.210631, 1.313668, 1.603998, 3.394891, 3.067507, 4.377814, 5.895722, 6.460319, 8.579691])
array([10.816842, 11.918814, 10.358963, 11.832625, 12.329768, 12.724151, 9.589529, 11.699309, 12.326572, 11.031749, 12.305065, 12.745297, 12.474465, 12.78944 , 11.116999, 12.473881, 12.214094, 8.251854, 12.486327, 12.196962, 7.055665, 12.891929, 12.825294, 8.046945, 12.740107, 9.798116])
array([0.366022, 0.069933, 0.105276, 0.454663, 0.151699, 0.120276, 1.940389, 0.73282 , 0.15053 , 1.072746, 0.151356, 0.074142, 0.339427, 0.114976, 0.235713, 1.149968, 0.115034, 1.699547, 0.097726, 0.082752, 4.575134, 0.065712, 0.680831, 3.296361, 2.071489, 6.466416])
array(['S2A_MSIL2A_20200626T185921_N0212_R013_T10TET_20200824T044417.SAFE', 'S2B_MSIL2A_20200714T190919_N0212_R056_T10TET_20200918T171907.SAFE', 'S2A_MSIL2A_20200719T190921_N0212_R056_T10TET_20200816T174917.SAFE', 'S2B_MSIL2A_20200721T185919_N0212_R013_T10TET_20200817T013018.SAFE', 'S2A_MSIL2A_20200726T185921_N0212_R013_T10TET_20201024T183833.SAFE', 'S2A_MSIL2A_20200729T190921_N0212_R056_T10TET_20200818T003739.SAFE', 'S2B_MSIL2A_20200731T185919_N0212_R013_T10TET_20200818T085554.SAFE', 'S2A_MSIL2A_20200805T185921_N0212_R013_T10TET_20201025T023207.SAFE', 'S2B_MSIL2A_20200810T185919_N0212_R013_T10TET_20200814T140814.SAFE', 'S2B_MSIL2A_20200813T190919_N0212_R056_T10TET_20201025T101153.SAFE', 'S2A_MSIL2A_20200815T185921_N0212_R013_T10TET_20200818T093648.SAFE', 'S2B_MSIL2A_20200823T190919_N0212_R056_T10TET_20200918T171910.SAFE', 'S2A_MSIL2A_20200825T185921_N0212_R013_T10TET_20200827T175050.SAFE', 'S2A_MSIL2A_20200828T190921_N0212_R056_T10TET_20200907T112416.SAFE', 'S2B_MSIL2A_20200830T185919_N0212_R013_T10TET_20200907T164839.SAFE', 'S2B_MSIL2A_20200902T190919_N0212_R056_T10TET_20200907T231347.SAFE', 'S2A_MSIL2A_20200904T185921_N0212_R013_T10TET_20200908T004502.SAFE', 'S2A_MSIL2A_20200907T190931_N0212_R056_T10TET_20200911T172006.SAFE', 'S2B_MSIL2A_20200909T185929_N0212_R013_T10TET_20200911T225318.SAFE', 'S2B_MSIL2A_20200929T190109_N0212_R013_T10TET_20201001T085751.SAFE', 'S2B_MSIL2A_20201002T191229_N0212_R056_T10TET_20201004T193349.SAFE', 'S2B_MSIL2A_20201101T191539_N0212_R056_T10TET_20201102T211503.SAFE', 'S2B_MSIL2A_20201108T190619_N0212_R013_T10TET_20201109T194251.SAFE', 'S2B_MSIL2A_20201121T191719_N0212_R056_T10TET_20201123T062421.SAFE', 'S2B_MSIL2A_20201201T191749_N0212_R056_T10TET_20201203T103951.SAFE', 'S2B_MSIL2A_20201228T190809_N0212_R013_T10TET_20210113T180911.SAFE'], dtype='<U65')
array(['Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2A', 'Sentinel-2A', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B', 'Sentinel-2B'], dtype='<U11')
array([ 6.041552, 10.124131, 7.27951 , 1.108193, 0.49786 , 0.516656, 6.070975, 2.732675, 0.5038 , 9.000901, 0.494444, 0.480433, 0.991054, 0.454406, 3.71128 , 6.77912 , 0.436394, 17.323714, 0.372039, 0.330355, 19.443338, 0.285518, 1.863562, 22.483132, 6.071228, 22.940759])
array([ 0.641728, 0.052805, 0.104454, 0.65353 , 0.346137, 0.396209, 1.641863, 1.528937, 0.353118, 2.063675, 0.342871, 0.274552, 0.616915, 0.339397, 0.381381, 5.628673, 0.252445, 0.377274, 0.273848, 0.245964, 14.868201, 0.219621, 1.145752, 6.04236 , 3.675069, 16.30924 ])
array(['S2A_OPER_MSI_L2A_TL_ESRI_20200824T044422_A026179_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171908_A017528_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200816T174919_A026508_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200817T013020_A017628_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201024T183835_A026608_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T003746_A026651_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200818T085557_A017771_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20201025T023208_A026751_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200814T140817_A017914_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201025T101155_A017957_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200818T093651_A026894_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200918T171913_A018100_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200827T175052_A027037_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200907T112418_A027080_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T164841_A018200_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200907T231350_A018243_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200908T004503_A027180_T10TET_N02.12', 'S2A_OPER_MSI_L2A_TL_ESRI_20200911T172010_A027223_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20200911T225319_A018343_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201001T085757_A018629_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201004T193351_A018672_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201102T211503_A019101_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201109T194252_A019201_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201123T062422_A019387_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20201203T103952_A019530_T10TET_N02.12', 'S2B_OPER_MSI_L2A_TL_ESRI_20210113T180913_A019916_T10TET_N02.12'], dtype='<U62')
array([ 0.551698, 0.949986, 1.010717, 0.750271, 0.649873, 0.981145, 0.833694, 0.871897, 0.859027, 1.331455, 0.927462, 1.698198, 1.154426, 1.693115, 1.369677, 2.047128, 1.709112, 1.665192, 1.754655, 2.994806, 2.97027 , 6.86717 , 11.21957 , 11.64913 , 13.50642 , 14.55939 ])
array([13, 56, 56, 13, 13, 56, 13, 13, 13, 56, 13, 56, 13, 56, 13, 56, 13, 56, 13, 13, 56, 56, 13, 56, 56, 13])
array([26.92230609, 28.02159918, 28.86440904, 30.05688459, 31.04824418, 30.91420557, 32.15474265, 33.35257573, 34.65230402, 34.77139642, 36.03408415, 37.78401298, 39.04290975, 39.39861229, 40.65297976, 41.07906148, 42.31869862, 42.81163815, 44.04000347, 51.25564906, 51.97344607, 62.51174953, 64.89541828, 67.92303888, 69.81589416, 71.84870255])
array('INS-NOBS', dtype='<U8')
array([73.603088, 68.675959, 72.683269, 76.473564, 77.052945, 76.423806, 70.652926, 73.470461, 75.761062, 66.351765, 75.416315, 74.643224, 73.5847 , 74.396992, 71.554184, 66.638041, 70.813137, 62.234098, 72.071505, 74.461645, 60.075766, 70.821804, 60.614246, 36.894995, 47.506449, 32.162049])
array('Sentinel 2', dtype='<U10')
array(0.)
array([0.96797835, 0.96756284, 0.96798717, 0.96822101, 0.96896789, 0.96952584, 0.96993992, 0.97113095, 0.97253332, 0.97347475, 0.97413802, 0.9771026 , 0.97791134, 0.97918147, 0.98005514, 0.98141892, 0.98235171, 0.98380003, 0.98478558, 0.99554701, 0.99725851, 1.01421506, 1.01784208, 1.02390093, 1.02778005, 1.03388801])
array(['S2A_OPER_MSI_L2A_DS_ESRI_20200824T044422_S20200626T190834_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171908_S20200714T191949_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200816T174919_S20200719T191624_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200817T013020_S20200721T190421_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201024T183835_S20200726T190505_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T003746_S20200729T191317_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200818T085557_S20200731T190527_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20201025T023208_S20200805T190700_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200814T140817_S20200810T190422_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201025T101155_S20200813T191815_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200818T093651_S20200815T190251_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200918T171913_S20200823T191123_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200827T175052_S20200825T190743_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200907T112418_S20200828T191522_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T164841_S20200830T190346_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200907T231350_S20200902T191252_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200908T004503_S20200904T190750_N02.12', 'S2A_OPER_MSI_L2A_DS_ESRI_20200911T172010_S20200907T191727_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20200911T225319_S20200909T191047_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201001T085757_S20200929T190122_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201004T193351_S20201002T192031_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201102T211503_S20201101T191542_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201109T194252_S20201108T190937_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201123T062422_S20201121T191908_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20201203T103952_S20201201T191748_N02.12', 'S2B_OPER_MSI_L2A_DS_ESRI_20210113T180913_S20201228T191049_N02.12'], dtype='<U64')
array([147.98616803, 152.66586214, 153.10842649, 148.86916411, 149.63456111, 154.44531626, 150.50706819, 151.54902338, 152.65280533, 157.37977495, 153.86608818, 159.69344332, 156.39362624, 160.90162296, 157.67449547, 162.08618713, 158.9674703 , 163.27013149, 160.21257042, 164.67388951, 168.34785842, 171.49511126, 169.05422731, 171.45575446, 170.86169793, 165.6035432 ])
array(['GS2A_20200626T185921_026179_N02.12', 'GS2B_20200714T190919_017528_N02.12', 'GS2A_20200719T190921_026508_N02.12', 'GS2B_20200721T185919_017628_N02.12', 'GS2A_20200726T185921_026608_N02.12', 'GS2A_20200729T190921_026651_N02.12', 'GS2B_20200731T185919_017771_N02.12', 'GS2A_20200805T185921_026751_N02.12', 'GS2B_20200810T185919_017914_N02.12', 'GS2B_20200813T190919_017957_N02.12', 'GS2A_20200815T185921_026894_N02.12', 'GS2B_20200823T190919_018100_N02.12', 'GS2A_20200825T185921_027037_N02.12', 'GS2A_20200828T190921_027080_N02.12', 'GS2B_20200830T185919_018200_N02.12', 'GS2B_20200902T190919_018243_N02.12', 'GS2A_20200904T185921_027180_N02.12', 'GS2A_20200907T190931_027223_N02.12', 'GS2B_20200909T185929_018343_N02.12', 'GS2B_20200929T190109_018629_N02.12', 'GS2B_20201002T191229_018672_N02.12', 'GS2B_20201101T191539_019101_N02.12', 'GS2B_20201108T190619_019201_N02.12', 'GS2B_20201121T191719_019387_N02.12', 'GS2B_20201201T191749_019530_N02.12', 'GS2B_20201228T190809_019916_N02.12'], dtype='<U34')
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array(['Band 4 - Red - 10m', 'Band 3 - Green - 10m', 'Band 2 - Blue - 10m'], dtype='<U20')
array(10)
array(['red', 'green', 'blue'], dtype='<U5')
array([0.665, 0.56 , 0.49 ])
array([0.038, 0.045, 0.098])
array(32610)
x = read_window(ic, "B02", bounds[0]).compute()
a = bad_data.data.rechunk((-1, 1, 732, 732)).blocks[0, 0, 0, 0]
b = good_data.data.blocks[0, 0, 0, 0]
%time aa = a.compute()
%time bb = b.compute()
CPU times: user 545 ms, sys: 164 ms, total: 710 ms Wall time: 1.94 s CPU times: user 331 ms, sys: 139 ms, total: 471 ms Wall time: 2.95 s
And now we can compute the median:
good_result = good_data.median(dim="time")
good_result
<xarray.DataArray 'from-value-546cce3c085aed0303a22d26a0a6d390' (band: 3, y: 10980, x: 10980)> dask.array<nanmedian, shape=(3, 10980, 10980), dtype=float64, chunksize=(1, 732, 732), chunktype=numpy.ndarray> Coordinates: * band (band) <U3 'B04' 'B03' 'B02' * x (x) float64 5e+05 ... 6.098e+05 * y (y) float64 5.3e+06 ... 5.19e+06 s2:mgrs_tile <U5 '10TET' instruments <U3 'msi' proj:epsg int64 32610 sat:orbit_state <U10 'descending' s2:degraded_msi_data_percentage float64 0.0 s2:processing_baseline <U5 '02.12' s2:product_type <U7 'S2MSI2A' s2:datatake_type <U8 'INS-NOBS' constellation <U10 'Sentinel 2' s2:saturated_defective_pixel_percentage float64 0.0 proj:transform object {0.0, 5300040.0, 10.0, 49... proj:bbox object {5190240.0, 609780.0, 499... proj:shape object {10980} title (band) <U20 'Band 4 - Red - 10m'... gsd int64 10 common_name (band) <U5 'red' 'green' 'blue' center_wavelength (band) float64 0.665 0.56 0.49 full_width_half_max (band) float64 0.038 0.045 0.098 epsg int64 32610
|
array(['B04', 'B03', 'B02'], dtype='<U3')
array([499980., 499990., 500000., ..., 609750., 609760., 609770.])
array([5300050., 5300040., 5300030., ..., 5190280., 5190270., 5190260.])
array('10TET', dtype='<U5')
array('msi', dtype='<U3')
array(32610)
array('descending', dtype='<U10')
array(0.)
array('02.12', dtype='<U5')
array('S2MSI2A', dtype='<U7')
array('INS-NOBS', dtype='<U8')
array('Sentinel 2', dtype='<U10')
array(0.)
array({0.0, 5300040.0, 10.0, 499980.0, -10.0}, dtype=object)
array({5190240.0, 609780.0, 499980.0, 5300040.0}, dtype=object)
array({10980}, dtype=object)
array(['Band 4 - Red - 10m', 'Band 3 - Green - 10m', 'Band 2 - Blue - 10m'], dtype='<U20')
array(10)
array(['red', 'green', 'blue'], dtype='<U5')
array([0.665, 0.56 , 0.49 ])
array([0.038, 0.045, 0.098])
array(32610)
A few things to point out:
median
would require many input chunks, as data is gathered from all many arrays that were read individually.client.wait_for_workers(24)
bad_result.data.blocks[0, 0, 0].visualize(optimize_graph=True)
By contrast, each output chunk of the good_result
median is extremely simple:
good_result.data.blocks[0, 0, 0].visualize(optimize_graph=True)
Simpler tasks mean less (or no) communication, which tends to be the bane of Dask clusters everywhere.
That said, it's not a panacea. This kind of "read small bits from many files" is slower than reading a large byte stream and then using Dask to move data around. I haven't profiled it yet, but it's like some combination of 1.) per file overhead (high latency filesystem, parsing metada, etc.) 2.) HTTPs vs. TCP. So if your computation does work
from distributed import performance_report
with performance_report("good-median.html"):
a = good_result.compute()
with performance_report("bad-median.html"):
b = bad_result.compute()
cluster.close()
assert a.equals(b)
...