Python API
xcube.core.store.new_data_store(data_store_id, extension_registry=None, **data_store_params)
Create a new data store instance for given data_store_id and data_store_params.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_id
|
str
|
A data store identifier. |
required |
extension_registry
|
Optional[ExtensionRegistry]
|
Optional extension registry. If not given, the global extension registry will be used. |
None
|
**data_store_params
|
Data store specific parameters. |
{}
|
Returns:
Type | Description |
---|---|
Union[DataStore, MutableDataStore, PreloadDataStore]
|
A new data store instance |
Source code in xcube/core/store/store.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
xcube.core.store.list_data_store_ids(detail=False)
List the identifiers of installed xcube data stores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detail
|
bool
|
Whether to return a dictionary with data store metadata or just a list of data store identifiers. |
False
|
Returns:
Type | Description |
---|---|
Union[list[str], dict[str, Any]]
|
If detail is |
Union[list[str], dict[str, Any]]
|
to data store metadata. Otherwise, a list of data store identifiers. |
Source code in xcube/core/store/store.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
xcube.core.store.get_data_store_params_schema(data_store_id, extension_registry=None)
Get the JSON schema for instantiating a new data store identified by data_store_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_id
|
str
|
A data store identifier. |
required |
extension_registry
|
Optional[ExtensionRegistry]
|
Optional extension registry. If not given, the global extension registry will be used. |
None
|
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
The JSON schema for the data store's parameters. |
Source code in xcube/core/store/store.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
xcube_eopf.store.EOPFZarrDataStore
Bases: DataStore
EOPF-Zarr implementation of the data store.
Source code in xcube_eopf/store.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
xcube.core.store.DataStore
Bases: DataOpener
, DataSearcher
, DataPreloader
, ABC
A data store represents a collection of data resources that can be enumerated, queried, and opened in order to obtain in-memory representations of the data. The same data resource may be made available using different data types. Therefore, many methods allow specifying a data_type parameter.
A store implementation may use any existing openers/writers, or define its own, or not use any openers/writers at all.
Store implementers should follow the conventions outlined in https://xcube.readthedocs.io/en/latest/storeconv.html .
The :class:DataStore
is an abstract base class that both read-only and
mutable data stores must implement.
Source code in xcube/core/store/store.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
|
get_data_ids(data_type=None, include_attrs=False)
abstractmethod
Get an iterator over the data resource identifiers for the given type data_type. If data_type is omitted, all data resource identifiers are returned.
If a store implementation supports only a single data type, it should verify that data_type is either None or compatible with the supported data type.
If include_attrs is provided, it must be a sequence of names of metadata attributes. The store will then return extra metadata for each returned data resource identifier according to the names of the metadata attributes as tuples (data_id, attrs).
Hence, the type of the returned iterator items depends on the value of include_attrs:
- If include_attrs is False (the default), the method returns
an iterator of dataset identifiers data_id of type
str
. - If include_attrs is True, the method returns an iterator of tuples
(data_id, attrs) of type
Tuple[str, Dict]
, where attrs is a dictionary filled with all the attributes available respectively for each data_id. - If include_attrs is a sequence of attribute names, even an
empty one, the method returns an iterator of tuples
(data_id, attrs) of type
Tuple[str, Dict]
, where attrs is a dictionary filled according to the names in include_attrs. If a store cannot provide a given attribute, it should simply ignore it. This may even yield to an empty dictionary for a given data_id.
The individual attributes do not have to exist in the dataset's
metadata, they may also be generated on-the-fly.
An example for a generic attribute name is "title".
A store should try to resolve include_attrs=["title"]
by returning items such as
("ESACCI-L4_GHRSST-SSTdepth-OSTIA-GLOB_CDR2.1-v02.0-fv01.0.zarr",
{"title": "Level-4 GHRSST Analysed Sea Surface Temperature"})
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_type
|
DataTypeLike
|
If given, only data identifiers that are available as this type are returned. If this is omitted, all available data identifiers are returned. |
None
|
include_attrs
|
Container[str] | bool
|
A sequence of names of attributes to be returned for each dataset identifier. If given, the store will attempt to provide the set of requested dataset attributes in addition to the data ids. (added in xcube 0.8.0) |
False
|
Returns:
Type | Description |
---|---|
Union[Iterator[str], Iterator[tuple[str, dict[str, Any]]]]
|
An iterator over the identifiers and titles of data |
Union[Iterator[str], Iterator[tuple[str, dict[str, Any]]]]
|
resources provided by this data store. |
Raises:
Type | Description |
---|---|
DataStoreError
|
If an error occurs. |
Source code in xcube/core/store/store.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
list_data_ids(data_type=None, include_attrs=False)
Convenience version of get_data_ids()
that returns a list rather
than an iterator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_type
|
DataTypeLike
|
If given, only data identifiers that are available as this type are returned. If this is omitted, all available data identifiers are returned. |
None
|
include_attrs
|
Container[str] | bool
|
A boolean or sequence of names of attributes to be returned for each dataset identifier. If a sequence of names of attributes given, the store will attempt to provide the set of requested dataset attributes in addition to the data ids. (added in xcube 0.8.0). If True, all the attributes for each dataset identifier will be returned. If False (default), only the data_ids are returned. |
False
|
Returns:
Type | Description |
---|---|
Union[list[str], list[tuple[str, dict[str, Any]]]]
|
A list comprising the identifiers and titles of data |
Union[list[str], list[tuple[str, dict[str, Any]]]]
|
resources provided by this data store. |
Raises:
Type | Description |
---|---|
DataStoreError
|
If an error occurs. |
Source code in xcube/core/store/store.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
has_data(data_id, data_type=None)
abstractmethod
Check if the data resource given by data_id is available in this store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
str
|
A data identifier |
required |
data_type
|
DataTypeLike
|
An optional data type. If given, it will also be
checked whether the data is available as the specified
type. May be given as type alias name, as a type, or as
a :class: |
None
|
Returns:
Type | Description |
---|---|
bool
|
True, if the data resource is available in this store, False |
bool
|
otherwise. |
Source code in xcube/core/store/store.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
get_open_data_params_schema(data_id=None, opener_id=None)
abstractmethod
Get the schema for the parameters passed as open_params to
:meth:open_data
.
If data_id is given, the returned schema will be tailored to the constraints implied by the identified data resource. Some openers might not support this, therefore data_id is optional, and if it is omitted, the returned schema will be less restrictive. If given, the method raises if data_id does not exist in this store.
If opener_id is given, the returned schema will be tailored to the constraints implied by the identified opener. Some openers might not support this, therefore opener_id is optional, and if it is omitted, the returned schema will be less restrictive.
For maximum compatibility of stores, it is strongly encouraged to apply the following conventions on parameter names, types, and their interpretation.
Let P be the value of an optional, data constraining open parameter, then it should be interpreted as follows:
- if P is None means, parameter not given, hence no constraint applies, hence no additional restrictions on requested data.
- if not P means, we exclude data that would be included by default.
- else, the given constraint applies.
Given here are names, types, and descriptions of common, constraining open parameters for gridded datasets. Note, whether any of these is optional or mandatory depends on the individual data store. A store may also define other open parameters or support only a subset of the following. Note all parameters may be optional, the Python-types given here refer to given, non-Null parameters:
variable_names: List[str]
: Included data variables. Available coordinate variables will be auto-included for any dimension of the data variables.bbox: Tuple[float, float, float, float]
: Spatial coverage as xmin, ymin, xmax, ymax.crs: str
: Spatial CRS, e.g. "EPSG:4326" or OGC CRS URI.spatial_res: float
: Spatial resolution in coordinates of the spatial CRS.time_range: Tuple[Optional[str], Optional[str]]
: Time range interval in UTC date/time units using ISO format. Start or end time may be missing which means everything until available start or end time.`time_period: str
: Pandas-compatible period/frequency string, e.g. "8D", "2W".
E.g. applied to an optional variable_names
parameter, this means
variable_names is None
- include all data variablesvariable_names == []
- do not include data variables (schema only)variable_names == ["<var_1>", "<var_2>", ...]
only include data variables named "", " ", ...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
str
|
An optional data identifier that is known to exist in this data store. |
None
|
opener_id
|
str
|
An optional data opener identifier. |
None
|
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
The schema for the parameters in open_params. |
Raises:
Type | Description |
---|---|
DataStoreError
|
If an error occurs. |
Source code in xcube/core/store/store.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
open_data(data_id, opener_id=None, **open_params)
abstractmethod
Open the data given by the data resource identifier data_id using the supplied open_params.
If opener_id is given, the identified data opener will be used to open the data resource and open_params must comply with the schema of the opener's parameters. Note that some store implementations may not support using different openers or just support a single one.
Implementations are advised to support an additional optional keyword
argument data_type: DataTypeLike = None
.
If data_type is provided, the return value will be in the specified
data type. If no data opener exists for the given data_type and format
extracted from the data_id, the default data type alias 'dataset' will
be used. Note that opener_id includes the data_type at its first
position and will override the date_type argument.
Raises if data_id does not exist in this store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_id
|
str
|
The data identifier that is known to exist in this data store. |
required |
opener_id
|
str
|
An optional data opener identifier. |
None
|
**open_params
|
Opener-specific parameters. Note that
|
{}
|
Returns:
Type | Description |
---|---|
Any
|
An in-memory representation of the data resources identified |
Any
|
by data_id and open_params. |
Raises:
Type | Description |
---|---|
DataStoreError
|
If an error occurs. |
Source code in xcube/core/store/store.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
|