Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
These openers and writers are available to any file system data store,
e.g., `"file"`, `"s3"`.

* `xcube serve` now provides new metadata details of a multilevel dataset:
- The spatial unit of the dataset is now given by property `spatialUnits`
- The resolutions are now given by property `resolutions` and provide
the average x,y resolutions for each level of the dataset given in
the spatial units of the dataset's CRS.


### Other changes

* Added two new versions of the xcube logo, one for dark and one for light themes,
Expand Down
40 changes: 13 additions & 27 deletions test/cli/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,20 @@ def test_dump_ds(self):
with xr.set_options(display_width=80):
result = self.invoke_cli(["dump", TEST_NC_FILE])

# Use a regex to accommodate the differing output formats produced by
# various xarray versions.
output_regex = r"""<xarray.Dataset>( Size: 8MB)?
Dimensions:\s+\((?=.*lon: 360)(?=.*lat: 180)(?=.*time: 5)(?=.*bnds: 2).*?\)
Coordinates:
\* lon \(lon\) float64 (3kB )?-179\.5 -178\.5 -177\.5 \.\.\. 177\.5 178\.5 179\.5
\* lat \(lat\) float64 (1kB )?-89\.5 -88\.5 -87\.5 -86\.5 \.\.\. (86\.5 )?87\.5 88\.5 89\.5
\* time \(time\) datetime64\[ns\] (40B )?2010-01-01T12:00:00 \.\.\. 2010-01-(05T1)?\.\.\.
lon_bnds \(lon, bnds\) float64 (6kB )?\.\.\.
lat_bnds \(lat, bnds\) float64 (3kB )?\.\.\.
time_bnds \(time, bnds\) datetime64\[ns\] (80B )?\.\.\.
Dimensions without coordinates: bnds
self.assertIn("<xarray.Dataset>", result.output)
self.assertIn("Coordinates:\n", result.output)
self.assertIn(" * lon (lon) float64 ", result.output)
self.assertIn("Data variables:\n", result.output)
self.assertIn(" precipitation (time, lat, lon) float64 ", result.output)
self.assertIn("Attributes:\n", result.output)
self.assertIn("title: Test Cube", result.output)

variables_regex = r"""
Data variables:
precipitation \(time, lat, lon\) float64 (3MB )?...
temperature \(time, lat, lon\) float64 (3MB )?...
soil_moisture \(time, lat, lon\) float64 (3MB )?...
Attributes:
Conventions: CF-1.7
title: Test Cube
time_coverage_start: 2010-01-01T00:00:00.000000000
time_coverage_end: 2010-01-06T00:00:00.000000000
geospatial_lon_min: -180.0
geospatial_lon_max: 180.0
geospatial_lon_units: degrees_east
geospatial_lat_min: -90.0
geospatial_lat_max: 90.0
geospatial_lat_units: degrees_north
precipitation \(time, lat, lon\) float64 (3MB)? ...
temperature \(time, lat, lon\) float64 (3MB)? ...
soil_moisture \(time, lat, lon\) float64 (3MB)? ...
"""

self.assertRegex(result.output, output_regex)
self.assertRegex(result.output, variables_regex)
self.assertEqual(0, result.exit_code)
4 changes: 2 additions & 2 deletions test/core/resampling/test_reproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def test_reproject_complex_dask_array(self):
source_ds, target_gm=target_gm, interpolation="bilinear"
)
self.assertCountEqual(["temperature"], list(target_ds.data_vars))
self.assertEqual(target_ds.temperature.values[0, 0, 0], 6427.718652710034)
self.assertEqual(target_ds.temperature.values[0, -1, -1], 3085.9507290783004)
self.assertAlmostEqual(target_ds.temperature.values[0, 0, 0], 6427.718652710034)
self.assertAlmostEqual(target_ds.temperature.values[0, -1, -1], 3085.9507290783004)
self.assertEqual(
[2, 5, 5],
[
Expand Down
2 changes: 2 additions & 0 deletions test/webapi/datasets/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def test_dataset_with_details(self):
self.assertIsInstance(dataset.get("bbox"), (tuple, list))
self.assertIsInstance(dataset.get("geometry"), dict)
self.assertIsInstance(dataset.get("spatialRef"), str)
self.assertIsInstance(dataset.get("resolutions"), (tuple, list))
self.assertIsInstance(dataset.get("spatialUnits"), str)
self.assertNotIn("rgbSchema", dataset)
if dataset["id"] == "demo":
demo_dataset = dataset
Expand Down
6 changes: 6 additions & 0 deletions test/webapi/ows/stac/demo-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@
]
},
"spatialRef": "EPSG:4326",
"resolutions": [
0.0025,
0.005,
0.01
],
"spatialUnits": "degree",
"variables": [
{
"id": "demo.conc_chl",
Expand Down
6 changes: 6 additions & 0 deletions test/webapi/ows/stac/stac-datacubes-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@
]
},
"spatialRef": "EPSG:4326",
"resolutions": [
0.0025,
0.005,
0.01
],
"spatialUnits": "degree",
"variables": [
{
"id": "demo-1w.conc_chl",
Expand Down
6 changes: 6 additions & 0 deletions test/webapi/ows/stac/stac-single-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@
]
},
"spatialRef": "EPSG:4326",
"resolutions": [
0.0025,
0.005,
0.01
],
"spatialUnits": "degree",
"variables": [
{
"id": "demo-1w.conc_chl",
Expand Down
2 changes: 2 additions & 0 deletions xcube/webapi/datasets/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ def get_dataset(
dataset_dict["bbox"] = list(ds_bbox)
dataset_dict["geometry"] = get_bbox_geometry(dataset_bounds, transformer)
dataset_dict["spatialRef"] = crs.to_string()
dataset_dict["resolutions"] = list(ml_ds.avg_resolutions)
dataset_dict["spatialUnits"] = ml_ds.grid_mapping.spatial_unit_name

variable_dicts = []
dim_names = set()
Expand Down