Skip to content

Commit ca4eda9

Browse files
authored
Merge pull request #61 from earthdaily/dev
v0.1.0
2 parents 79e3df9 + 13d9a09 commit ca4eda9

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.1.0] - 2024-04-19
8+
9+
### Fixed
10+
11+
- Scaled/asset when duplicated datetimes.
12+
- Chunks asked in datacube are not the same as the output (due du smallest dims).
13+
- Autoconverting list/dict coords to string for zarr compatibility
14+
15+
716
## [0.0.17] - 2024-04-15
817

918
### Fixed

earthdaily/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# to hide warnings from rioxarray or nano seconds conversion
66
warnings.filterwarnings("ignore")
77

8-
__version__ = "0.0.17"
8+
__version__ = "0.1.0"

earthdaily/earthdatastore/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,6 @@ def datacube(
746746

747747
if clear_cover:
748748
xr_datacube = mask.filter_clear_cover(xr_datacube, clear_cover)
749-
750749
return xr_datacube
751750

752751
def _update_search_for_assets(self, assets):

earthdaily/earthdatastore/cube_utils/__init__.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import logging
2-
from datetime import datetime
31
from collections import defaultdict
2+
import logging
43
import pandas as pd
54
import geopandas as gpd
65
import numpy as np
7-
import pytz
86
import xarray as xr
97
from rasterio.enums import Resampling
108
from shapely.geometry import box
@@ -14,6 +12,7 @@
1412
from .asset_mapper import AssetMapper
1513
import rioxarray
1614
from functools import wraps
15+
import json
1716

1817
__all__ = ["GeometryManager", "rioxarray", "zonal_stats", "zonal_stats_numpy"]
1918

@@ -118,6 +117,8 @@ def _cube_odc(
118117
metadata = {k: ("time", v.tolist()) for k, v in df.items()}
119118
# assign metadata as coords
120119
ds = ds.assign_coords(**metadata)
120+
ds = ds.chunk(kwargs["chunks"])
121+
121122
return ds
122123

123124

@@ -249,6 +250,16 @@ def datacube(
249250

250251
if isinstance(assets, dict):
251252
ds = ds.rename(assets)
253+
254+
for coord in ds.coords:
255+
if ds.coords[coord].values.shape == ():
256+
continue
257+
if isinstance(ds.coords[coord].values[0], (list, dict)):
258+
ds.coords[coord].values = [
259+
json.dumps(ds.coords[coord].values[idx])
260+
for idx in range(ds.coords[coord].size)
261+
]
262+
252263
return ds
253264

254265

@@ -358,14 +369,9 @@ def rescale_assets_with_items(
358369
ds_scaled[asset] = []
359370
for scale in scales[asset].keys():
360371
for offset in scales[asset][scale].keys():
361-
times = list(set(scales[asset][scale][offset]))
362-
if len(times) != len(scales[asset][scale][offset]):
363-
for time in times:
364-
d = ds[[asset]].loc[dict(time=time)] * scale + offset
365-
ds_scaled[asset].append(d)
366-
else:
367-
d = ds[[asset]].loc[dict(time=times)] * scale + offset
368-
ds_scaled[asset].append(d)
372+
times = np.in1d(ds.time, list(set(scales[asset][scale][offset])))
373+
asset_scaled = ds[[asset]].isel(time=times) * scale + offset
374+
ds_scaled[asset].append(asset_scaled)
369375
ds_ = []
370376
for k, v in ds_scaled.items():
371377
ds_k = []

earthdaily/earthdatastore/mask/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def compute_clear_coverage(
162162
)
163163
}
164164
)
165+
# self._obj = self._obj.reset_coords(names=['clear_pixels','clear_percent'])
165166

166167
return self._obj
167168

0 commit comments

Comments
 (0)