@@ -3227,7 +3227,7 @@ def copy(self, deep=False):
32273227 @docstrings .dedent
32283228 def from_dataset (cls , base , method = 'isel' , default_slice = None ,
32293229 decoder = None , auto_update = None , prefer_list = False ,
3230- squeeze = True , attrs = None , ** kwargs ):
3230+ squeeze = True , attrs = None , load = False , ** kwargs ):
32313231 """
32323232 Construct an ArrayList instance from an existing base dataset
32333233
@@ -3254,6 +3254,10 @@ def from_dataset(cls, base, method='isel', default_slice=None,
32543254 attrs: dict, optional
32553255 Meta attributes that shall be assigned to the selected data arrays
32563256 (additional to those stored in the `base` dataset)
3257+ load: bool or dict
3258+ If True, load the data from the dataset using the
3259+ :meth:`xarray.DataArray.load` method. If :class:`dict`, those will
3260+ be given to the above mentioned ``load`` method
32573261
32583262 Other Parameters
32593263 ----------------
@@ -3264,6 +3268,15 @@ def from_dataset(cls, base, method='isel', default_slice=None,
32643268 ArrayList
32653269 The list with the specified :class:`InteractiveArray` instances
32663270 that hold a reference to the given `base`"""
3271+ try :
3272+ load = dict (load )
3273+ except (TypeError , ValueError ):
3274+ def maybe_load (arr ):
3275+ return arr .load () if load else arr
3276+ else :
3277+ def maybe_load (arr ):
3278+ return arr .load (** load )
3279+
32673280 def iter_dims (dims ):
32683281 """Split the given dictionary into multiples and iterate over it"""
32693282 if not dims :
@@ -3342,7 +3355,7 @@ def sel_method(key, dims, name=None):
33423355 # delete the variable dimension for the idims
33433356 dims .pop ('variable' , None )
33443357 ret .psy .init_accessor (arr_name = key , base = base , idims = dims )
3345- return ret
3358+ return maybe_load ( ret )
33463359 else :
33473360 def sel_method (key , dims , name = None ):
33483361 if name is None :
@@ -3369,7 +3382,7 @@ def sel_method(key, dims, name=None):
33693382 else :
33703383 ret = squeeze_array (arr .sel (method = method , ** dims ))
33713384 ret .psy .init_accessor (arr_name = key , base = base )
3372- return ret
3385+ return maybe_load ( ret )
33733386 kwargs .setdefault (
33743387 'name' , sorted (
33753388 key for key in base .variables if key not in base .coords ))
0 commit comments