Replacing a dictionary of Datasets by a DataTree means you can simplify some code:
ds_all_mf = read_model_output(
data_dir,
file_type="concentration",
species=species,
models=models,
config_data=config_data,
period=period,
)
mf_dt = xr.DataTree.from_dict(ds_all_mf)
mf_dt.sel(platform="MHD") # select from all Datasets at once
To convert back to the dictionary of datasets:
{m: v.to_dataset() for m, v in mf_dt.items()}
I think if you don't do reset_index("index") in edit_vars_and_attributes, you could probably also do
mf_dt.sel(time=slice(start_date, end_date))
but resetting index also removes the time dimension it seems. (Also resetting index means you can't unstack it... leaving index as a coordinate would probably simplify other code.)
Replacing a dictionary of Datasets by a DataTree means you can simplify some code:
To convert back to the dictionary of datasets:
I think if you don't do
reset_index("index")inedit_vars_and_attributes, you could probably also dobut resetting
indexalso removes thetimedimension it seems. (Also resetting index means you can't unstack it... leavingindexas a coordinate would probably simplify other code.)