Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step away from "type specifiers" introduced in xcube 0.6 #509

Closed
forman opened this issue Aug 26, 2021 · 0 comments · Fixed by #510
Closed

Step away from "type specifiers" introduced in xcube 0.6 #509

forman opened this issue Aug 26, 2021 · 0 comments · Fixed by #510
Assignees
Labels
enhancement New feature or request in progress The assignee is working on it

Comments

@forman
Copy link
Member

forman commented Aug 26, 2021

Is your feature request related to a problem? Please describe.

The "type specifiers" (class xcube.core.store.TypeSpecifier) concept introduced in xcube 0.6 is no longer required in the light of the data cube convention, see #488. It complicates the data store API, where simple data type names are sufficient and less confusing.

Describe the solution you'd like

We can now simply use a parameter data_type: DataTypeLike where type_specifier: str was expected, wIth

  • DataType = Union[xr.Dataset, xcube.core.multilevel.MultiLevelDataset, gpd.GeoDataFrame, Any] and
  • DataTypeLike = Union[str, DataType].

Function implementation can use a new utility function normalize_data_type(data_type: DataTypeLike) -> DataType to get the actual type.

When users really need a cube in terms of (time, ..., y, x) dimensions, they use the new dataset’s cube subset function xcube.core.normalize.get_dataset_cube_subset() -> Tuple[xr.Dataset, GridMapping] or simply xr.Dataset.xcube.xcube.to_cube() (the xcube property is an xarray dataset extension), therefore there is no more need to use type specifiers with flags, e.g. "dataset[cube]":

dataset = store.open_data(…, data_type=xr.Dataset)
cube, grid_mapping = dataset.xcube.to_cube()

Same for multi-level datasets:

ml_dataset, grid_mapping = dataset.xcube.to_ml_dataset(num_levels=5, tile_size=512)

Original type specifier names with flags now become simple data type names:

  • From "dataset[cube]" to "dataset" or "xarray.Dataset"
  • From "dataset[multilevel]" and "dataset[multilevel, cube]" to "ml_dataset" or "xcube.core.multilevel.MultiLevelDataset"
  • Allow "geodataframe" and also "geopandas.GeoDataFrame"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress The assignee is working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant