DatasetMapping
- class glotaran.utils.io.DatasetMapping(init_map: Mapping[str, Dataset] | None = None)[source]
Bases:
MutableMapping
Wrapper class for a mapping of datasets which can be used for a
file_loadable_field
.Initialize an instance of
DatasetMapping
.- Parameters:
init_dict (dict[str, xr.Dataset] | None) – Mapping to initially populate the instance. Defaults to
None
.
Attributes Summary
Map the
source_path
attribute of each dataset to a standalone mapping.Methods Summary
Loader function utilized by
file_loadable_field
.If key is not found, d is returned if given, otherwise KeyError is raised.
as a 2-tuple; but raise KeyError if D is empty.
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
Methods Documentation
- clear() None. Remove all items from D.
- get(k[, d]) D[k] if k in D, else d. d defaults to None.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- classmethod loader(dataset_mappable: str | Path | Dataset | DataArray | Sequence[str | Path | Dataset | DataArray] | Mapping[str, str | Path | Dataset | DataArray]) DatasetMapping [source]
Loader function utilized by
file_loadable_field
.- Parameters:
dataset_mappable (DatasetMappable) – Mapping of datasets to initialize
DatasetMapping
.- Returns:
Populated instance of
DatasetMapping
.- Return type:
- pop(k[, d]) v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
- property source_path
Map the
source_path
attribute of each dataset to a standalone mapping.Note
When the
source_path
attribute of the dataset gets updated (e.g. by callingsave_dataset
with the defaultupdate_source_path=True
) this value will be updated as well.
- update([E, ]**F) None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values