Skip to content

Commit 99701fd

Browse files
committed
Merge remote-tracking branch 'origin/master' into toniof-516-unify-datasetio2
# Conflicts: # xcube/webapi/context.py
2 parents 8338adf + ca1718a commit 99701fd

File tree

9 files changed

+475
-236
lines changed

9 files changed

+475
-236
lines changed

CHANGES.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Changes in 0.9.3 (in development)
22

3-
### New features
3+
### Enhancements
44

55
* It is now possible to use environment variables in most
66
xcube configuration files. Unix bash syntax is used, i.e.
@@ -13,12 +13,24 @@
1313

1414
* Changed the `xcube gen` tool to extract metadata for pre-sorting inputs
1515
from other than NetCDF inputs, e.g. GeoTIFF.
16+
17+
* Optimized function `xcube.core.geom.rasterize_features()`.
18+
It is now twice as fast while its memory usage dropped to the half. (#593)
1619

1720
### Fixes
1821

1922
* `xcube serve` now also serves datasets that are located in
2023
subdirectories of filesystem-based data stores such as
2124
"file", "s3", "memory". (#579)
25+
26+
* xcube serve now accepts datasets whose spatial
27+
resolutions differ up to 1%. (#590)
28+
It also no longer rejects datasets with large dimension
29+
sizes. (Formerly, an integer-overflow occurred in size
30+
computation.)
31+
32+
* `DatasetChunkCacheSize` is now optional in `xcube serve`
33+
configuration. (Formerly, when omitted, the server crashed.)
2234

2335
* Fixed bug that would cause that requesting data ids on some s3 stores would
2436
fail with a confusing ValueError.

test/core/test_geom.py

Lines changed: 177 additions & 95 deletions
Large diffs are not rendered by default.

test/webapi/test_s3buckethandlers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ class S3BucketHandlersTest(unittest.TestCase):
3131
def test_open_cube_from_xube_server_rel_path(self):
3232
ds = open_cube('s3bucket/local',
3333
format_name='zarr',
34+
s3_kwargs={
35+
'anon': True
36+
},
3437
s3_client_kwargs=dict(endpoint_url=SERVER_URL))
3538
self.assertCubeOk(ds)
3639

3740
@unittest.skipUnless(XCUBE_SERVER_IS_RUNNING, SKIP_HELP)
3841
def test_open_cube_from_xube_server_abs_path(self):
3942
ds = open_cube('http://localhost:8080/s3bucket/local',
40-
format_name='zarr')
43+
format_name='zarr',
44+
s3_kwargs={
45+
'anon': True
46+
})
4147
self.assertCubeOk(ds)
4248

4349
def assertCubeOk(self, ds):

xcube/cli/extract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def extract(cube,
6060
time_col_names = ["time"]
6161

6262
points = pd.read_csv(points_path, parse_dates=time_col_names, infer_datetime_format=True)
63+
points.time = points.time.dt.tz_localize(tz=None)
6364
with open_dataset(cube_path) as cube:
6465
values = get_cube_values_for_points(cube,
6566
points,

xcube/core/geom.py

Lines changed: 264 additions & 130 deletions
Large diffs are not rendered by default.

xcube/core/gridmapping/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,10 @@ def _repr_markdown_(self) -> str:
773773

774774
@property
775775
def tile_grid(self) -> TileGrid:
776-
assert_true(math.isclose(self.x_res, self.y_res),
776+
# we allow up to 1% dev
777+
assert_true(math.isclose(self.x_res,
778+
self.y_res,
779+
rel_tol=0.01),
777780
message='spatial resolutions must be'
778781
' same in both directions')
779782
return ImageTileGrid(image_size=self.size,

xcube/core/normalize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def decode_cube(dataset: xr.Dataset,
214214
and var.dims[0] == time_name \
215215
and var.dims[-2] == y_dim_name \
216216
and var.dims[-1] == x_dim_name \
217-
and np.product(var.shape) > 0 \
217+
and np.all(var.shape) \
218218
and var.shape[-2] > 1 \
219219
and var.shape[-1] > 1:
220220
cube_vars.add(var_name)

xcube/webapi/context.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,10 @@ def _open_ml_dataset(self, dataset_config: DatasetConfigDict) \
585585
chunk_cache_capacity = self.get_dataset_chunk_cache_capacity(
586586
dataset_config
587587
)
588-
if (data_id.endswith('.zarr') or data_id.endswith('.levels')) \
589-
and 'cache_size' not in open_params \
590-
and chunk_cache_capacity is not None:
588+
if chunk_cache_capacity \
589+
and (ds_id.endswith('.zarr')
590+
or ds_id.endswith('.levels')) \
591+
and 'cache_size' not in open_params:
591592
open_params['cache_size'] = chunk_cache_capacity
592593
with self.measure_time(tag=f"opened dataset {ds_id!r}"
593594
f" from data store"

xcube/webapi/controllers/catalogue.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_datasets(ctx: ServiceContext,
110110
)
111111
filtered_dataset_dicts.append(dataset_dict)
112112
except (DatasetIsNotACubeError, CubeIsNotDisplayable) as e:
113-
LOG.warn(f'skipping dataset {ds_id}: {e}')
113+
LOG.warning(f'skipping dataset {ds_id}: {e}')
114114
dataset_dicts = filtered_dataset_dicts
115115
if point:
116116
is_point_in_dataset_bbox = functools.partial(
@@ -143,15 +143,15 @@ def get_dataset(ctx: ServiceContext,
143143
f' {grid_mapping.crs.srs}')
144144
if not math.isclose(grid_mapping.x_res,
145145
grid_mapping.y_res,
146-
abs_tol=0.01):
146+
rel_tol=0.01): # we allow up to 1% dev
147147
raise CubeIsNotDisplayable(f'spatial resolutions are'
148148
f' different in x, y:'
149149
f' {grid_mapping.x_res}'
150150
f' and {grid_mapping.y_res}')
151151
try:
152152
# Make sure we have a valid tile grid
153-
# noinspection PyStatementEffect
154-
assert_instance(ml_ds.tile_grid, TileGrid)
153+
tile_grid = ml_ds.tile_grid
154+
assert_instance(tile_grid, TileGrid)
155155
except ValueError as e:
156156
raise CubeIsNotDisplayable(f'could not create tile grid: {e}')
157157

0 commit comments

Comments
 (0)