diff --git a/tzis/tzis.py b/tzis/tzis.py index 0edb0d2e3f1e48bfe311f116db002d48698afa9d..f1d5befa22ae3996fb66a22618185d31c2469cbe 100644 --- a/tzis/tzis.py +++ b/tzis/tzis.py @@ -34,6 +34,16 @@ class Tzis(): #if type(mf) != list and type(mf) != str : # raise ValueError("Dataset '{0}' must either be a string or a list of strings") if mf: + tracking_ids=[] + if type(mf) == str : + mf = [mf] + try : + for dset in mf : + dset = xarray.open_dataset(dset) + tracking_ids.append(dset.attrs["tracking_id"]) + except : + if self.verbose : + print("Could not collect 'tracking_ids'.") if xarray_kwargs: mf_dset = xarray.open_mfdataset(mf, decode_cf=True, @@ -51,6 +61,8 @@ class Tzis(): data_vars='minimal', coords='minimal', compat='override') + if tracking_ids : + mf_dset.attrs["tracking_id"]=tracking_ids if not self.varname : self.varname = mf_dset.variables[0]