-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
I work a lot with climate model output and often loop over several models, of which some have a 'member' dimension and others don't.
I end up writing many lines like this:
for ds in model_datasets:
if 'member_id' in ds.dims:
ds = ds.mean('member_id)
Which often makes for very lengthy code blocks.
I recently noticed that .isel()
actually has a nifty keyword argument 'missing_dims', which enables the user to apply isel
and it just doesn't do anything when the dimension is not present.
I'd love to be able to do:
for ds in model_datasets:
ds = ds.mean('member_id', missing_dims='ignore')
Is there a way to implement this generally for xarray aggregation methods (mean/max/min/std/...). Or is there a reason this should be avoided?