MCPcopy
hub / github.com/pydata/xarray / load

Method load

xarray/core/dataset.py:531–579  ·  view source on GitHub ↗

Trigger loading data into memory and return this dataset. Data will be computed and/or loaded from disk or a remote source. Unlike ``.compute``, the original dataset is modified and returned. Normally, it should not be necessary to call this method in user code, be

(self, **kwargs)

Source from the content-addressed store, hash-verified

529 )
530
531 def load(self, **kwargs) -> Self:
532 """Trigger loading data into memory and return this dataset.
533
534 Data will be computed and/or loaded from disk or a remote source.
535
536 Unlike ``.compute``, the original dataset is modified and returned.
537
538 Normally, it should not be necessary to call this method in user code,
539 because all xarray functions should either work on deferred data or
540 load data automatically. However, this method can be necessary when
541 working with many file objects on disk.
542
543 Parameters
544 ----------
545 **kwargs : dict
546 Additional keyword arguments passed on to ``dask.compute``.
547
548 Returns
549 -------
550 object : Dataset
551 Same object but with lazy data variables and coordinates as in-memory arrays.
552
553 See Also
554 --------
555 dask.compute
556 Dataset.compute
557 Dataset.load_async
558 DataArray.load
559 Variable.load
560 """
561 # access .data to coerce everything to numpy or dask arrays
562 chunked_data = {
563 k: v._data for k, v in self.variables.items() if is_chunked_array(v._data)
564 }
565 if chunked_data:
566 chunkmanager = get_chunked_array_type(*chunked_data.values())
567
568 # evaluate all the chunked arrays simultaneously
569 evaluated_data: tuple[np.ndarray[Any, Any], ...] = chunkmanager.compute(
570 *chunked_data.values(), **kwargs
571 )
572
573 for k, data in zip(chunked_data, evaluated_data, strict=False):
574 self.variables[k].data = data
575
576 # load everything else sequentially
577 [v.load() for k, v in self.variables.items() if k not in chunked_data]
578
579 return self
580
581 async def load_async(self, **kwargs) -> Self:
582 """Trigger and await asynchronous loading of data into memory and return this dataset.

Callers 15

open_datasetFunction · 0.45
load_datasetFunction · 0.45
open_datatreeFunction · 0.45
load_datatreeFunction · 0.45
decode_cfFunction · 0.45
load_chunkmanagersFunction · 0.45
load_storeMethod · 0.45
computeMethod · 0.45
process_subset_optFunction · 0.45
test_isnull_with_daskFunction · 0.45

Calls 5

is_chunked_arrayFunction · 0.90
get_chunked_array_typeFunction · 0.90
itemsMethod · 0.80
valuesMethod · 0.45
computeMethod · 0.45

Tested by 15

test_isnull_with_daskFunction · 0.36
test_interpolate_ndFunction · 0.36
test_groupby_scansFunction · 0.36
test_dask_is_lazyMethod · 0.36
test_lazy_loadMethod · 0.36
test_chunkMethod · 0.36
test_loadMethod · 0.36