Python API reference
xcube_multistore.multistore.MultiSourceDataStore
Manages access to multiple data sources and their configurations for generating data cubes.
This class utilizes xcube data store plugins for data access, supports data harmonization, and enables visualization of data cube generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
str | dict[str, Any]
|
Configuration settings, provided as a dictionary or a string reference to a YAML configuration file. |
required |
Notes
Detailed instructions on setting up the configuration can be found in the Configuration Guide.
Source code in xcube_multistore/multistore.py
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 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 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
get_config_schema()
classmethod
Retrieves the configuration schema for the multi-source data store.
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
A schema object defining the expected structure of the configuration. |
Source code in xcube_multistore/multistore.py
103 104 105 106 107 108 109 110 |
|
list_data_store_ids()
classmethod
List the identifiers of all available data stores.
Returns:
Type | Description |
---|---|
list[str]
|
A list of data store identifiers. |
Note
If a data store identifier is missing, ensure that the respective xcube plugin is installed in the environment.
Source code in xcube_multistore/multistore.py
119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
get_data_store_params_schema(data_store_ids=None)
classmethod
Get the parameter schema for one or more data stores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_ids
|
str | list[str] | None
|
A single data store identifier, a list of identifiers, or None. If None, all available data store identifiers are used. |
None
|
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
A JSON object schema containing the parameter schemas for the |
JsonObjectSchema
|
requested data stores. Each key corresponds to a data store ID, |
JsonObjectSchema
|
and each value is its parameter schema. |
Source code in xcube_multistore/multistore.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
list_data_ids(data_store_ids_params)
classmethod
List available data IDs for one or more data stores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_ids_params
|
Mapping[str, dict]
|
A mapping of data store identifiers to their data store parameters for initialization. |
required |
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
A JSON object schema containing available data IDs for each data store. |
Logs
A warning is logged if data IDs cannot be listed for a given store.
Source code in xcube_multistore/multistore.py
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 |
|
get_open_data_params_schema(data_store_id, data_store_params, data_id)
classmethod
Get the parameter schema to open a specific dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_id
|
str
|
The identifier of the data store. |
required |
data_store_params
|
dict
|
Parameters used to initialize the data store. |
required |
data_id
|
str
|
The identifier of the dataset within the data store. |
required |
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
A JSON object schema describing the parameters available for opening |
JsonObjectSchema
|
the specified dataset. |
Source code in xcube_multistore/multistore.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
search_data_ids(data_store_ids_params)
classmethod
Search for available data IDs across multiple data stores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_ids_params
|
Mapping[str, tuple[Mapping[str, Any], Mapping[str, Any]]]
|
A mapping from data store identifiers ( |
required |
Returns:
Name | Type | Description |
---|---|---|
JsonObjectSchema |
JsonObjectSchema
|
Contains one property per data store, each holding a |
JsonObjectSchema
|
JsonArraySchema of found data IDs. |
Logs
Warnings are logged for any data store where the search fails. This can happen if the store does not support searching or if there is an error retrieving the data IDs.
Note
Ensure that the search parameters match the expected format for each store.
To see the expected search parameters, use get_search_params_schema
.
Source code in xcube_multistore/multistore.py
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 |
|
get_search_params_schema(data_store_ids_params)
classmethod
Retrieve the search parameter schemas for one or more data stores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_ids_params
|
Mapping[str, dict]
|
A mapping of data store identifiers to their initialization parameters. |
required |
Returns:
Type | Description |
---|---|
JsonObjectSchema
|
A JSON object schema containing the search parameter |
JsonObjectSchema
|
schemas for each data store. Each key is a data store identifier, |
JsonObjectSchema
|
and its value is the corresponding search parameter schema. |
Logs
A warning is logged if the search parameter schema cannot be retrieved for a given store.
Source code in xcube_multistore/multistore.py
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 |
|
describe_data(data_store_id, data_store_params, data_id)
classmethod
Describe a dataset from a data store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_store_id
|
str
|
The identifier of the data store. |
required |
data_store_params
|
dict
|
Parameters used to initialize the data store. |
required |
data_id
|
str
|
The identifier of the dataset within the data store. |
required |
Returns:
Type | Description |
---|---|
DataDescriptor
|
An object describing the dataset, including |
DataDescriptor
|
metadata such as its spatial, temporal, and variable information. |
Source code in xcube_multistore/multistore.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
xcube_multistore.utils.prepare_dataset_for_netcdf(ds)
Prepares an xarray Dataset for NetCDF serialization.
Converts non-serializable attributes (lists, tuples, and dictionaries) into strings to ensure compatibility with NetCDF format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds
|
Dataset
|
The input xarray Dataset. |
required |
Returns:
Type | Description |
---|---|
Dataset
|
A dataset with updated attributes, ensuring compatibility with NetCDF. |
Source code in xcube_multistore/utils.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
xcube_multistore.utils.get_utm_zone(lat, lon)
Determines the UTM (Universal Transverse Mercator) zone for given coordinates.
Computes the UTM zone based on longitude and returns the corresponding EPSG code. Northern hemisphere zones use EPSG codes in the 32600 range, while southern hemisphere zones use EPSG codes in the 32700 range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lat
|
float
|
Latitude in degrees. |
required |
lon
|
float
|
Longitude in degrees. |
required |
Returns:
Type | Description |
---|---|
str
|
The EPSG code for the corresponding UTM zone (e.g., "epsg:32633"). |
Source code in xcube_multistore/utils.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
xcube_multistore.utils.get_bbox(lat, lon, cube_width, crs_final='utm')
Generates a bounding box around a specified latitude and longitude.
Given a point (latitude, longitude) and the desired width of a cube, this function computes the bounding box in the specified coordinate reference system (CRS). The bounding box is returned as a list of coordinates, and the CRS is returned as well.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lat
|
float
|
Latitude of the central point in degrees. |
required |
lon
|
float
|
Longitude of the central point in degrees. |
required |
cube_width
|
float
|
The width of the cube in units of crs_final, used to define the extent of the bounding box. |
required |
crs_final
|
CRS or str
|
The target CRS for the bounding box. Defaults to "utm", which automatically determines the UTM zone based on the latitude and longitude. |
'utm'
|
Returns:
Type | Description |
---|---|
(list[int], CRS)
|
A list of four integers representing the bounding box in the format [west, south, east, north]. |
(list[int], CRS)
|
The final CRS used for the bounding box, returned as a |
Source code in xcube_multistore/utils.py
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 |
|
xcube_multistore.utils.clean_dataset(ds)
Cleans an xarray Dataset by removing boundary variables and normalizing the grid mapping.
This function removes specific variables related to bounds (e.g., "x_bnds", "y_bnds", "lat_bnds", "lon_bnds", "time_bnds") and normalizes the grid mapping by adding a spatial reference coordinate called "spatial_ref" and assigning it to the relevant data variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds
|
Dataset
|
The input xarray dataset to be cleaned. |
required |
Returns:
Type | Description |
---|---|
Dataset
|
A cleaned version of the dataset with boundary variables removed and grid |
Dataset
|
mapping normalized. |
Source code in xcube_multistore/utils.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|